lkml.org 
[lkml]   [2023]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] x86/lib: Fix overflow of variable m when val >= 1410065408
From
On 11/1/23 08:32, Colin Ian King wrote:
...
> int num_digits(int val)
> {
> - int m = 10;
> + long m = 10;
> int d = 1;
>
> if (val < 0) {

Isn't this still broken on 32-bit where sizeof(long) == sizeof(int)?
Seems like we need 'm' to be able to hold values that are ~10x larger
than 'val' if we need this to work for the entire int range.

Also, performance doesn't matter here at *all* with the current use in
a couple of printk()'s. Just making 'm' 'long long' or u64 probably be
just fine.

\
 
 \ /
  Last update: 2023-11-02 17:40    [W:0.075 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site