Re: [tip:x86/mm] x86, mm: Use a bitfield to mask nuisance get_user() warnings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Subject: Re: [tip:x86/mm] x86, mm: Use a bitfield to mask nuisance get_user() warnings
- From: "H. Peter Anvin" <hpa@xxxxxxxxx>
- Date: Tue, 12 Feb 2013 10:25:38 -0800
- Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Jamie Lokier <jamie@xxxxxxxxxxxxx>, ville.syrjala@xxxxxxxxxxxxxxx, Borislav Petkov <bp@xxxxxxxxx>, Russell King - ARM Linux <linux@xxxxxxxxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, linux-tip-commits@xxxxxxxxxxxxxxx
- In-reply-to: <CAMe9rOrqDjBQjLyDRWJqRKdzQf1zMXHwXxFk2DekC+EeCHa8UA@mail.gmail.com>
- User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2
I just thought up this variant, I'm about to test it, but H.J., do you
see any problems with it?
#define itype(x) \
__typeof__(__builtin_choose_expr(sizeof(*(x)) > sizeof(0UL), 0ULL, 0UL))
I tried it out with a small test program (attached), and it seems to
work. Next for using it in the kernel...
-hpa
#include <stdio.h>
#include <stdlib.h>
#define itype(x) __typeof__(__builtin_choose_expr(sizeof(*(x)) > sizeof(0UL), 0ULL, 0UL))
int main(void)
{
const char *a;
const short *b;
const int *c;
const long *d;
const long long *e;
const void **p;
itype(a) aa;
itype(b) bb;
itype(c) cc;
itype(d) dd;
itype(e) ee;
itype(p) pp;
aa = 1;
bb = 2;
cc = 3;
dd = 4;
ee = 5;
pp = 6;
printf("a = %zu\n", sizeof(aa));
printf("b = %zu\n", sizeof(bb));
printf("c = %zu\n", sizeof(cc));
printf("d = %zu\n", sizeof(dd));
printf("e = %zu\n", sizeof(ee));
printf("p = %zu\n", sizeof(pp));
return 0;
}
[Index of Archives]
[Linux Stable Commits]
[Linux Stable Kernel]
[Linux Kernel]
[Linux USB Devel]
[Linux Video &Media]
[Linux Audio Users]
[Yosemite News]
[Linux SCSI]