Skip to content

Commit 9c133c7

Browse files
lifeixwenlingz
authored andcommitted
hv: lib: refine print_decimal
Align the calculate logic to make it simpler. Tracked-On: #861 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
1 parent 7a62154 commit 9c133c7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

hypervisor/lib/sprintf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,17 +348,17 @@ static void print_decimal(struct print_param *param, int64_t value)
348348
v.qword = v.qword / 10UL;
349349
}
350350

351+
nv.dwords.low = v.dwords.low;
351352
/* process 32 bit (or reduced 64 bit) value */
352353
do {
353354
/* determine digits from right to left. The compiler should be
354355
* able to handle a division and multiplication by the constant
355356
* 10.
356357
*/
357-
nv.dwords.low = v.dwords.low / 10U;
358358
pos--;
359-
*pos = (v.dwords.low - (10U * nv.dwords.low)) + '0';
360-
v.dwords.low = nv.dwords.low;
361-
} while (v.dwords.low != 0U);
359+
*pos = (char)(nv.dwords.low % 10U) + '0';
360+
nv.dwords.low = nv.dwords.low / 10U;
361+
} while (nv.dwords.low != 0U);
362362

363363
/* assign parameter and apply width and precision */
364364
param->vars.value = pos;

0 commit comments

Comments
 (0)