* warning: division by zero
@ 2018-02-14 0:26 Randy Dunlap
2018-02-14 0:39 ` Luc Van Oostenryck
0 siblings, 1 reply; 3+ messages in thread
From: Randy Dunlap @ 2018-02-14 0:26 UTC (permalink / raw)
To: Linux-Sparse
In Linux kernel, we get that message 2 times (in x86_64 allmodconfig):
../fs/exofs/ore_raid.c:95:64: warning: division by zero
../fs/exofs/ore_raid.c:116:36: warning: division by zero
when dividing by variable sizeof_a1pa, where that is:
const unsigned sizeof__a1pa = sizeof(_aab->__a1pa[0]);
which is in this struct:
struct _alloc_all_bytes {
struct __alloc_stripe_pages_2d {
struct __stripe_pages_2d sp2d;
struct __1_page_stripe _1p_stripes[pages_in_unit];
} __asp2d;
struct __alloc_1p_arrays {
struct page *pages[group_width];
struct page *scribble[group_width];
char page_is_read[data_devs];
} __a1pa[pages_in_unit];
} *_aab;
where 'pages_in_unit' is a function parameter. So, yes, it could have a value
of zero.
Is the warning message considered correct or useful as is? If so, OK, no problem.
Although I would rather see something more like:
warning: variable length array on stack
thanks,
--
~Randy
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: warning: division by zero
2018-02-14 0:26 warning: division by zero Randy Dunlap
@ 2018-02-14 0:39 ` Luc Van Oostenryck
2018-02-14 0:43 ` Randy Dunlap
0 siblings, 1 reply; 3+ messages in thread
From: Luc Van Oostenryck @ 2018-02-14 0:39 UTC (permalink / raw)
To: Randy Dunlap; +Cc: Linux-Sparse
On Tue, Feb 13, 2018 at 04:26:04PM -0800, Randy Dunlap wrote:
> In Linux kernel, we get that message 2 times (in x86_64 allmodconfig):
>
> ../fs/exofs/ore_raid.c:95:64: warning: division by zero
> ../fs/exofs/ore_raid.c:116:36: warning: division by zero
>
> when dividing by variable sizeof_a1pa, where that is:
> const unsigned sizeof__a1pa = sizeof(_aab->__a1pa[0]);
>
> which is in this struct:
> struct _alloc_all_bytes {
> struct __alloc_stripe_pages_2d {
> struct __stripe_pages_2d sp2d;
> struct __1_page_stripe _1p_stripes[pages_in_unit];
> } __asp2d;
> struct __alloc_1p_arrays {
> struct page *pages[group_width];
> struct page *scribble[group_width];
> char page_is_read[data_devs];
> } __a1pa[pages_in_unit];
> } *_aab;
>
> where 'pages_in_unit' is a function parameter. So, yes, it could have a value
> of zero.
>
> Is the warning message considered correct or useful as is? If so, OK, no problem.
It's a division by zero, not because the parameter can be zero
but because currently sparse doesn't handle the size of VLAs which
are always considered as zero-sized.
So, no I don't consider this warning as correct and even less useful.
I have a WIP series to handle VLA's sizeof, if there is some interests
I can boost a bit its priority.
> Although I would rather see something more like:
> warning: variable length array on stack
That's of course something different that could indeed be quite useful.
-- Luc
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: warning: division by zero
2018-02-14 0:39 ` Luc Van Oostenryck
@ 2018-02-14 0:43 ` Randy Dunlap
0 siblings, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2018-02-14 0:43 UTC (permalink / raw)
To: Luc Van Oostenryck; +Cc: Linux-Sparse
On 02/13/2018 04:39 PM, Luc Van Oostenryck wrote:
> On Tue, Feb 13, 2018 at 04:26:04PM -0800, Randy Dunlap wrote:
>> In Linux kernel, we get that message 2 times (in x86_64 allmodconfig):
>>
>> ../fs/exofs/ore_raid.c:95:64: warning: division by zero
>> ../fs/exofs/ore_raid.c:116:36: warning: division by zero
>>
>> when dividing by variable sizeof_a1pa, where that is:
>> const unsigned sizeof__a1pa = sizeof(_aab->__a1pa[0]);
>>
>> which is in this struct:
>> struct _alloc_all_bytes {
>> struct __alloc_stripe_pages_2d {
>> struct __stripe_pages_2d sp2d;
>> struct __1_page_stripe _1p_stripes[pages_in_unit];
>> } __asp2d;
>> struct __alloc_1p_arrays {
>> struct page *pages[group_width];
>> struct page *scribble[group_width];
>> char page_is_read[data_devs];
>> } __a1pa[pages_in_unit];
>> } *_aab;
>>
>> where 'pages_in_unit' is a function parameter. So, yes, it could have a value
>> of zero.
>>
>> Is the warning message considered correct or useful as is? If so, OK, no problem.
>
> It's a division by zero, not because the parameter can be zero
> but because currently sparse doesn't handle the size of VLAs which
> are always considered as zero-sized.
> So, no I don't consider this warning as correct and even less useful.
>
> I have a WIP series to handle VLA's sizeof, if there is some interests
> I can boost a bit its priority.
No hurry. Thanks for your comments.
>> Although I would rather see something more like:
>> warning: variable length array on stack
>
> That's of course something different that could indeed be quite useful.
--
~Randy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-14 0:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-14 0:26 warning: division by zero Randy Dunlap
2018-02-14 0:39 ` Luc Van Oostenryck
2018-02-14 0:43 ` Randy Dunlap
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).