linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: Linux-Sparse <linux-sparse@vger.kernel.org>
Subject: warning: division by zero
Date: Tue, 13 Feb 2018 16:26:04 -0800	[thread overview]
Message-ID: <8708546d-78da-622d-bc26-d2a0cf40cda4@infradead.org> (raw)

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

             reply	other threads:[~2018-02-14  0:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14  0:26 Randy Dunlap [this message]
2018-02-14  0:39 ` warning: division by zero Luc Van Oostenryck
2018-02-14  0:43   ` Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8708546d-78da-622d-bc26-d2a0cf40cda4@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).