From: "Christopher Li" <sparse@chrisli.org>
To: Alexey Zaytsev <alexey.zaytsev@gmail.com>
Cc: linux-sparse@vger.kernel.org
Subject: Re: [PATCH] Null ctype should have ptr_ctype as its base type.
Date: Sun, 28 Dec 2008 23:32:24 -0800 [thread overview]
Message-ID: <70318cbf0812282332m1188f0bbm1097ced77583dc42@mail.gmail.com> (raw)
In-Reply-To: <f19298770812281338t698d10e6xf60b5d787896f04f@mail.gmail.com>
On Sun, Dec 28, 2008 at 1:38 PM, Alexey Zaytsev
<alexey.zaytsev@gmail.com> wrote:
> 11091a11093,11130
>> drivers/net/wireless/wavelan_cs.c:362:16: error: subtraction of different types can't work (different base types)
>> drivers/net/wireless/wavelan_cs.c:379:17: error: subtraction of different types can't work (different base types)
>> drivers/net/wireless/wavelan_cs.c:385:21: error: subtraction of different types can't work (different base types)
> [...]
>
> It looks like:
>
> ... mmroff(0, mmr_fee_status) ..
>
> #define mmroff(p,f) (unsigned short)((void *)(&((mmr_t *)((void
> *)0 + (p)))->f) - (void *)0)
That is one piece of ugly code.
>
> mmr_fee_status being an element in struct mmr.
> Here we end up substracting null from non-null void * pointer.
> Looks quite pointless, but I think sparse should be able to
> cope with this?
Do you have minimal code to duplicate this bug?
I try with the following testing code without much luck.
Chris
typedef struct mmr_t mmr_t;
struct mmr_t {
int a;
int mmr_fee_status;
};
#define mmroff(p,f) (unsigned short)((void *)(&((mmr_t *)((void
*)0 + (p)))->f) - (void *)0)
int b;
int foo(void)
{
return mmroff(0,mmr_fee_status);
}
next prev parent reply other threads:[~2008-12-29 7:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-25 2:09 [PATCH] Warn about explicit usage of sizeof(void) Christopher Li
2008-12-25 17:23 ` Tommy Thorn
2008-12-25 18:36 ` [PATCH] Warn about explicit usage of sizeof(void) and sizeof(function) Alexey Zaytsev
2008-12-25 19:45 ` Christopher Li
2008-12-25 20:10 ` [PATCH] Also warn about sizeof(function) Alexey Zaytsev
2008-12-26 0:48 ` Christopher Li
2008-12-28 15:14 ` [PATCH] Null ctype should have ptr_ctype as its base type Alexey Zaytsev
2008-12-28 20:52 ` Christopher Li
2008-12-28 21:38 ` Alexey Zaytsev
2008-12-29 7:32 ` Christopher Li [this message]
2008-12-29 9:03 ` Alexey Zaytsev
2008-12-25 18:48 ` [PATCH] Warn about explicit usage of sizeof(void) Christopher Li
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=70318cbf0812282332m1188f0bbm1097ced77583dc42@mail.gmail.com \
--to=sparse@chrisli.org \
--cc=alexey.zaytsev@gmail.com \
--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).