Browse code

statsc: use long long for rpc output value

Daniel-Constantin Mierla authored on 14/01/2022 15:19:03
Showing 1 changed files
... ...
@@ -354,7 +354,8 @@ static void statsc_rpc_report(rpc_t* rpc, void* ctx)
354 354
 	int cmode;
355 355
 	str sname;
356 356
 	int range;
357
-	int k, m, n, v;
357
+	int k, m, n;
358
+	int64_t v;
358 359
 	time_t tn;
359 360
 	void* th;
360 361
 	void* ts;
... ...
@@ -433,7 +434,7 @@ static void statsc_rpc_report(rpc_t* rpc, void* ctx)
433 434
 					rpc->fault(ctx, 500, "Error creating rpc (5)");
434 435
 					return;
435 436
 				}
436
-				v = (int)sm->vals[k];
437
+				v = sm->vals[k];
437 438
 				switch(cmode) {
438 439
 					case 1:
439 440
 						break;
... ...
@@ -442,13 +443,13 @@ static void statsc_rpc_report(rpc_t* rpc, void* ctx)
442 443
 							continue;
443 444
 						}
444 445
 						if(k==0) {
445
-							v -= (int)sm->vals[statsc_items-1];
446
+							v -= sm->vals[statsc_items-1];
446 447
 						} else {
447
-							v -= (int)sm->vals[k-1];
448
+							v -= sm->vals[k-1];
448 449
 						}
449 450
 						break;
450 451
 				}
451
-				if(rpc->struct_add(ti, "udd",
452
+				if(rpc->struct_add(ti, "uLd",
452 453
 						"timestamp", (unsigned int)_statsc_info->slist->vals[k],
453 454
 						"value", v,
454 455
 						"index", m++)<0) {
... ...
@@ -464,7 +465,7 @@ static void statsc_rpc_report(rpc_t* rpc, void* ctx)
464 465
 					rpc->fault(ctx, 500, "Error creating rpc (7)");
465 466
 					return;
466 467
 				}
467
-				v = (int)sm->vals[k];
468
+				v = sm->vals[k];
468 469
 				switch(cmode) {
469 470
 					case 1:
470 471
 						break;
... ...
@@ -472,10 +473,10 @@ static void statsc_rpc_report(rpc_t* rpc, void* ctx)
472 473
 						if(n==k-1) {
473 474
 							continue;
474 475
 						}
475
-						v -= (int)sm->vals[k-1];
476
+						v -= sm->vals[k-1];
476 477
 						break;
477 478
 				}
478
-				if(rpc->struct_add(ti, "udd",
479
+				if(rpc->struct_add(ti, "uLd",
479 480
 						"timestamp", (unsigned int)_statsc_info->slist->vals[k],
480 481
 						"value", v,
481 482
 						"index", m++)<0) {