* Re: [PATCH] staging: rtl8192u: initialize array in C compliant way [not found] <1399364528-3727-1-git-send-email-martink@posteo.de> @ 2014-05-06 8:47 ` Dan Carpenter 2014-05-06 19:59 ` Christopher Li 2014-05-10 9:09 ` Christopher Li 0 siblings, 2 replies; 3+ messages in thread From: Dan Carpenter @ 2014-05-06 8:47 UTC (permalink / raw) To: Martin Kepplinger; +Cc: gregkh, devel, linux-kernel, burzalodowa, linux-sparse On Tue, May 06, 2014 at 10:22:08AM +0200, Martin Kepplinger wrote: > Don't list elements to initialize. Remaining elements of a partly > initialized array are set to zero. Sparse complained here. > > Signed-off-by: Martin Kepplinger <martink@posteo.de> > --- > drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c > index 426f223..c96dbab 100644 > --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c > +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c > @@ -241,7 +241,7 @@ static PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, > { > //DIRECTION_VALUE dir; > u8 dir; > - bool search_dir[4] = {0, 0, 0, 0}; > + bool search_dir[4] = {0}; That's weird. The original code is valid but it generates a sparse warning. drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c:244:58: warning: Initializer entry defined twice drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c:244:61: also defined here It has something to do with "_Bool" types. Changing it to "int" will also make the warning disappear. I've CC'd the sparse list to see if anyone knows what's happening. regards, dan carpenter ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: rtl8192u: initialize array in C compliant way 2014-05-06 8:47 ` [PATCH] staging: rtl8192u: initialize array in C compliant way Dan Carpenter @ 2014-05-06 19:59 ` Christopher Li 2014-05-10 9:09 ` Christopher Li 1 sibling, 0 replies; 3+ messages in thread From: Christopher Li @ 2014-05-06 19:59 UTC (permalink / raw) To: Dan Carpenter Cc: Martin Kepplinger, Greg KH, devel, linux-kernel, burzalodowa, Linux-Sparse On Tue, May 6, 2014 at 1:47 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote: >> - bool search_dir[4] = {0, 0, 0, 0}; >> + bool search_dir[4] = {0}; > > That's weird. The original code is valid but it generates a sparse > warning. > > drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c:244:58: warning: Initializer entry defined twice > drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c:244:61: also defined here > > It has something to do with "_Bool" types. Changing it to "int" will > also make the warning disappear. I've CC'd the sparse list to see if > anyone knows what's happening. This is easy reproducible with a small test case. It is a sparse bug for sure. Let me take a look. Chris ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: rtl8192u: initialize array in C compliant way 2014-05-06 8:47 ` [PATCH] staging: rtl8192u: initialize array in C compliant way Dan Carpenter 2014-05-06 19:59 ` Christopher Li @ 2014-05-10 9:09 ` Christopher Li 1 sibling, 0 replies; 3+ messages in thread From: Christopher Li @ 2014-05-10 9:09 UTC (permalink / raw) To: Dan Carpenter Cc: devel, Greg KH, linux-kernel, Linux-Sparse, burzalodowa, Martin Kepplinger On Tue, May 6, 2014 at 1:47 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote: >> diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c >> index 426f223..c96dbab 100644 >> --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c >> +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c >> @@ -241,7 +241,7 @@ static PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, >> { >> //DIRECTION_VALUE dir; >> u8 dir; >> - bool search_dir[4] = {0, 0, 0, 0}; >> + bool search_dir[4] = {0}; > > That's weird. The original code is valid but it generates a sparse > warning. Sorry for the late reply. I see what is going on already. The bits_to_bytes() function is buggy for bool type. Bool is the only type has bits less than 8. It truncates the bool byte size to 0. As a result, the array layout function convert_index() always set the expr->init_offset to 0 for bool type: "e->init_offset = from * bits_to_bytes(e->ctype->bit_size);" Chris ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-10 9:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1399364528-3727-1-git-send-email-martink@posteo.de>
2014-05-06 8:47 ` [PATCH] staging: rtl8192u: initialize array in C compliant way Dan Carpenter
2014-05-06 19:59 ` Christopher Li
2014-05-10 9:09 ` Christopher Li
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox