Browse code

acc: simplify index shifting for adding time variants in db accounting

Daniel-Constantin Mierla authored on 11/11/2021 19:39:10
Showing 1 changed files
... ...
@@ -429,18 +429,19 @@ int acc_db_request( struct sip_msg *rq)
429 429
 	for(i=0; i<m; i++)
430 430
 		VAL_STR(db_vals+i) = val_arr[i];
431 431
 	/* time value */
432
-	VAL_TIME(db_vals+(m++)) = acc_env.ts;
432
+	VAL_TIME(db_vals+m) = acc_env.ts;
433
+	m++;
433 434
 	/* extra time value */
434 435
 	if(acc_time_mode==1) {
435
-		VAL_INT(db_vals+(m++)) = (int)acc_env.tv.tv_sec;
436
-		i++;
437
-		VAL_INT(db_vals+(m++)) = (int)acc_env.tv.tv_usec;
438
-		i++;
436
+		VAL_INT(db_vals+m) = (int)acc_env.tv.tv_sec;
437
+		m++;
438
+		VAL_INT(db_vals+m) = (int)acc_env.tv.tv_usec;
439
+		m++;
439 440
 	} else if(acc_time_mode==2) {
440 441
 		dtime = (double)acc_env.tv.tv_usec;
441 442
 		dtime = (dtime / 1000000) + (double)acc_env.tv.tv_sec;
442
-		VAL_DOUBLE(db_vals+(m++)) = dtime;
443
-		i++;
443
+		VAL_DOUBLE(db_vals+m) = dtime;
444
+		m++;
444 445
 	} else if(acc_time_mode==3 || acc_time_mode==4) {
445 446
 		if(acc_time_mode==3) {
446 447
 			localtime_r(&acc_env.ts, &t);
... ...
@@ -451,19 +452,21 @@ int acc_db_request( struct sip_msg *rq)
451 452
 					acc_time_format, &t)<=0) {
452 453
 			acc_time_format_buf[0] = '\0';
453 454
 		}
454
-		VAL_STRING(db_vals+(m++)) = acc_time_format_buf;
455
-		i++;
455
+		VAL_STRING(db_vals+m) = acc_time_format_buf;
456
+		m++;
456 457
 	}
458
+	i = m;
457 459
 
458 460
 	/* extra columns */
459 461
 	o = extra2strar( db_extra, rq, val_arr+m, int_arr+m, type_arr+m);
460 462
 	m += o;
461 463
 
462
-	for( i++ ; i<m; i++) {
464
+	for( ; i<m; i++) {
463 465
 		if (acc_extra_nullable == 1 && type_arr[i] == TYPE_NULL) {
464 466
 			LM_DBG("attr[%d] is NULL\n", i);
465 467
 			VAL_NULL(db_vals + i) = 1;
466 468
 		} else {
469
+			LM_DBG("attr[%d] is STR\n", i);
467 470
 			VAL_STR(db_vals+i) = val_arr[i];
468 471
 		}
469 472
 	}