lkml.org 
[lkml]   [2013]   [Sep]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: do_div() silently truncates "base" to 32bit
From
Hi

On Fri, Aug 30, 2013 at 5:50 PM, Anatol Pomozov
<anatol.pomozov@gmail.com> wrote:
> Hi, Joe
>
> On Fri, Aug 30, 2013 at 4:28 PM, Joe Perches <joe@perches.com> wrote:
>> On Fri, 2013-08-30 at 15:48 -0700, Randy Dunlap wrote:
>>> On 08/30/13 15:14, Anatol Pomozov wrote:
>>> > But another question still remains: why compiler does not warn that
>>> > size truncation happens? How to prevent bugs like CFQ one in the
>>> > future? Should we add a compile-time assert to do_div() to prevent
>>> > passing 64 numbers in "base" macro parameter?
>>> That sounds like a fine idea to me.
>>
>> Geert thought so too and submitted a patch
>>
>> http://www.spinics.net/lists/linux-btrfs/msg26788.html
>
> Thanks it works!
>
> block/cfq-iosched.c: In function 'cfqg_prfill_avg_queue_size':
> block/cfq-iosched.c:4423:3: error: size of unnamed array is negative
> make[2]: *** [block/gfq-iosched.s] Error 1
> make[1]: *** [block/gfq-iosched.s] Error 2
> I see a number of other truncation errors. We need to fix them as well.

I looked at the places where do_div() passes incorrect parameters and
it is quite a lot of them. It would be better to warn users until all
the places are fixed. Is there any BUILD_WARN_ON() macro?


\
 
 \ /
  Last update: 2013-09-04 18:21    [W:0.058 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site