Amirite? Signed-off-by: Alexey Zaytsev <alexey.zaytsev@xxxxxxxxx> --- On Thu, Dec 25, 2008 at 21:36, Alexey Zaytsev <alexey.zaytsev@xxxxxxxxx> wrote: > Tommy Thorn wrote: >> Christopher Li wrote: >>> So here is what I got. A patch address both of our need. It gives warning >>> of using sizeof(void) explicitly. void* + offset will continue to work without >>> warnings. It will also make is_byte_type() continue to work as it was >>> before. >>> >>> Here is my test script: >>> >>> void *p; >>> >>> int i = sizeof(void); >>> int j = sizeof(*p); >>> > >> I can't test it right now, but does it give a warning for both sizeof's >> above? If just first results in a warning, then I think that quite >> reasonable. > > Both trigger the warning. I'm not sure this is a problem, as there are > no such usage cases in the kernel. > > I added (hopefully the right way) handling of (sizeof(function)) to the > patch. function++ was already prohibited. > > Running the test on the kernel right now. > And it found something. 2158a2159 > fs/compat_ioctl.c:787:10: warning: expression using sizeof on a function 9524a9526,9543 > drivers/media/video/gspca/sonixb.c:494:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:494:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:494:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:495:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:495:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:495:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:496:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:498:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:498:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:498:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:500:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:500:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:502:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:502:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:502:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:504:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:504:1: warning: expression using sizeof(void) > drivers/media/video/gspca/sonixb.c:504:1: warning: expression using sizeof(void) 15293a15313,15325 > net/netfilter/nf_conntrack_sip.c:282:21: warning: expression using sizeof(void) > net/netfilter/nf_conntrack_sip.c:282:21: warning: expression using sizeof(void) > net/netfilter/nf_conntrack_sip.c:287:23: warning: expression using sizeof(void) > net/netfilter/nf_conntrack_sip.c:287:23: warning: expression using sizeof(void) > net/netfilter/nf_conntrack_sip.c:288:29: warning: expression using sizeof(void) > net/netfilter/nf_conntrack_sip.c:586:23: warning: expression using sizeof(void) > net/netfilter/nf_conntrack_sip.c:586:23: warning: expression using sizeof(void) > net/netfilter/nf_conntrack_sip.c:587:25: warning: expression using sizeof(void) > net/netfilter/nf_conntrack_sip.c:588:29: warning: expression using sizeof(void) > net/netfilter/nf_conntrack_sip.c:589:25: warning: expression using sizeof(void) > net/netfilter/nf_conntrack_sip.c:590:29: warning: expression using sizeof(void) > net/netfilter/nf_conntrack_sip.c:591:22: warning: expression using sizeof(void) > net/netfilter/nf_conntrack_sip.c:591:22: warning: expression using sizeof(void) The first one is if (copy_in_user(&sgio->status, sgio32->status, (4 * sizeof(unsigned char)) + (2 * sizeof(unsigned (short))) + <------- oops (3 * sizeof(int)))) return -EFAULT; a bug. So, if anyone ever missed his sgio.info, now we know why. Patch sent. drivers/media/video/gspca/sonixb.c looks like SENS(initHv7131, NULL, hv7131_sensor_init, NULL, NULL, 0, NO_EXPO|NO_FREQ, 0), #define SENS(bridge_1, bridge_3, sensor, sensor_1, \ sensor_3, _flags, _ctrl_dis, _sensor_addr) \ { \ .bridge_init = { bridge_1, bridge_3 }, \ .bridge_init_size = { sizeof(bridge_1), sizeof(bridge_3) }, \ So, we are getting a sizeof(NULL), or a sizeof((void *)0). It triggers here because we are getting a null_ctype, and it's base_type points to void_ctype. I'm not sure if this patch is correct, but it seems to do the trick, all void warnings are gone. Christopher? symbol.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/symbol.c b/symbol.c index 4da253b..df760d4 100644 --- a/symbol.c +++ b/symbol.c @@ -861,7 +861,7 @@ static const struct ctype_declare { { &string_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &char_ctype }, { &ptr_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &void_ctype }, - { &null_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &void_ctype }, + { &null_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &ptr_ctype }, { &label_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &void_ctype }, { &lazy_ptr_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &void_ctype }, { NULL, } -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html