arm: replace typeof() with __typeof__()
PATCH 1/1 arm: replace typeof() with __typeof__()
typeof() is available in Xen's build environment, which uses Xen's compiler. As these headers are public, they need strict standards conformance. Only __typeof__() is officially standardized.
A compiler in standards conformance mode should report:
warning: implicit declaration of function 'typeof' is invalid in C99 [-Wimplicit-function-declaration]
(this has been observed with FreeBSD's kernel build environment)
--- xen/include/public/arch-arm.h | 2 +- xen/include/public/hvm/save.h | 4 ++-- xen/include/public/io/ring.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
xen/include/public/arch-arm.h +1 -1
@@ -191,7 +191,7 @@#define XEN_GUEST_HANDLE_PARAM (name) __guest_handle_ ## name#define set_xen_guest_handle_raw (hnd, val) \ do { \ - typeof(&(hnd)) _sxghr_tmp = &(hnd); \ + __typeof__(&(hnd)) _sxghr_tmp = &(hnd); \ _sxghr_tmp->q = 0; \ _sxghr_tmp->p = val; \ } while ( 0 )
xen/include/public/hvm/save.h +2 -2
@@ -82,12 +82,12 @@ struct hvm_save_descriptor { struct __HVM_SAVE_TYPE_##_x { _type t; char c[_code]; char cpt[1];}#endif -#define HVM_SAVE_TYPE (_x) typeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->t) +#define HVM_SAVE_TYPE (_x) __typeof__ (((struct __HVM_SAVE_TYPE_##_x *)(0))->t)#define HVM_SAVE_LENGTH (_x) (sizeof (HVM_SAVE_TYPE(_x)))#define HVM_SAVE_CODE (_x) (sizeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->c))#ifdef __XEN__ -# define HVM_SAVE_TYPE_COMPAT (_x) typeof (((struct __HVM_SAVE_TYPE_COMPAT_##_x *)(0))->t) +# define HVM_SAVE_TYPE_COMPAT (_x) __typeof__ (((struct __HVM_SAVE_TYPE_COMPAT_##_x *)(0))->t)# define HVM_SAVE_LENGTH_COMPAT (_x) (sizeof (HVM_SAVE_TYPE_COMPAT(_x)))# define HVM_SAVE_HAS_COMPAT (_x) (sizeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->cpt)-1)
xen/include/public/io/ring.h +1 -1
@@ -242,7 +242,7 @@ typedef struct __name##_back_ring __name##_back_ring_t*/ #define RING_COPY_REQUEST (_r, _idx, _req) do { \/* Use volatile to force the copy into _req. */ \ - *(_req) = *(volatile typeof (_req ))RING_GET_REQUEST (_r, _idx); \ + *(_req) = *(volatile __typeof__ (_req ))RING_GET_REQUEST (_r, _idx); \ } while (0)#define RING_GET_RESPONSE (_r, _idx) \
Signature · 1 line
2.20.1
Quoted 6 lines · Elliott Mitchell
typeof()is available in Xen's build environment, which uses Xen's compiler. As these headers are public, they need strict standards conformance. Only__typeof__()is officially standardized.A compiler in standards conformance mode should report:
Quoted 7 lines
warning: implicit declaration of function 'typeof' is invalid in C99 [-Wimplicit-function-declaration]
(this has been observed with FreeBSD's kernel build environment)
Based-on-patch-by Julien Grall <[email protected]>, Sun Oct 4 20:33:04 2015 +0100Signed-off-by Elliott Mitchell <[email protected]>
s!arm!xen/public! in the subject seeing as two thirds of the modifications are in non-ARM headers.
This wants backporting as a build fix, so should be considered for 4.15 at this point.
I wonder why our header checks don't pick this up. Do we need to throw a -pedantic around?
Stefano Stabellini
Reviewed-byQuoted 12 lines · Andrew Cooper
Quoted 11 lines · Elliott Mitchell
typeof()is available in Xen's build environment, which uses Xen's compiler. As these headers are public, they need strict standards conformance. Only__typeof__()is officially standardized.A compiler in standards conformance mode should report:
warning: implicit declaration of function 'typeof' is invalid in C99 [-Wimplicit-function-declaration]
(this has been observed with FreeBSD's kernel build environment)
Quoted 7 lines
Quoted 2 lines
Based-on-patch-by Julien Grall <[email protected]>, Sun Oct 4 20:33:04 2015 +0100Signed-off-by Elliott Mitchell <[email protected]>s!arm!xen/public! in the subject seeing as two thirds of the modifications are in non-ARM headers.
Acked-by Andrew Cooper <[email protected]>
Quoted 2 lines
This wants backporting as a build fix, so should be considered for 4.15 at this point.
+1
Quoted 10 lines · Andrew Cooper
Quoted 9 lines · Elliott Mitchell
typeof()is available in Xen's build environment, which uses Xen's compiler. As these headers are public, they need strict standards conformance. Only__typeof__()is officially standardized.A compiler in standards conformance mode should report:
warning: implicit declaration of function 'typeof' is invalid in C99 [-Wimplicit-function-declaration]
Quoted 7 lines
Quoted 4 lines
(this has been observed with FreeBSD's kernel build environment)
Based-on-patch-by Julien Grall <[email protected]>, Sun Oct 4 20:33:04 2015 +0100Signed-off-by Elliott Mitchell <[email protected]>s!arm!xen/public! in the subject seeing as two thirds of the modifications are in non-ARM headers.
Gah! Crucial little detail missing when rewriting the subject line. Julien Grall's original patch/commit only did ARM, but when I checked I found the other two and I did them too.
Quoted 7 lines
Acked-by Andrew Cooper <[email protected]>This wants backporting as a build fix, so should be considered for 4.15 at this point.
I wonder why our header checks don't pick this up.?? Do we need to throw a -pedantic around?
This came up since FreeBSD's kernel build uses Clang with -std=iso9899:1999. When I found FreeBSD was simply copying Xen's headers it was clear this needed to be *here*.
Signature · 4 lines
(\___(\___(\______ --=> 8-) EHM <=-- ______/)___/)___/) \BS ( | [email protected] PGP 87145445 | ) / \_CS\ | _____ -O #include <stddisclaimer.h> O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445
Quoted 29 lines · Elliott Mitchell
Quoted 10 lines · Andrew Cooper
Quoted 9 lines · Elliott Mitchell
typeof()is available in Xen's build environment, which uses Xen's compiler. As these headers are public, they need strict standards conformance. Only__typeof__()is officially standardized.A compiler in standards conformance mode should report:
warning: implicit declaration of function 'typeof' is invalid in C99 [-Wimplicit-function-declaration]
Quoted 7 lines
Quoted 4 lines
(this has been observed with FreeBSD's kernel build environment)
Based-on-patch-by Julien Grall <[email protected]>, Sun Oct 4 20:33:04 2015 +0100Signed-off-by Elliott Mitchell <[email protected]>s!arm!xen/public! in the subject seeing as two thirds of the modifications are in non-ARM headers.
Gah! Crucial little detail missing when rewriting the subject line. Julien Grall's original patch/commit only did ARM, but when I checked I found the other two and I did them too.
Quoted 5 lines
Acked-by Andrew Cooper <[email protected]>This wants backporting as a build fix, so should be considered for 4.15 at this point.
Quoted 6 lines
Quoted 2 lines
I wonder why our header checks don't pick this up.?? Do we need to throw a -pedantic around?
This came up since FreeBSD's kernel build uses Clang with -std=iso9899:1999. When I found FreeBSD was simply copying Xen's headers it was clear this needed to be *here*.
FTR this was never spotted on x86 because we don't make use of any of the macros that use typeof in the kernel. Arm OTOH has a typeof in set_xen_guest_handle_raw which is used by kernel code.
Thanks for fixing those.
Thanks, Roger.
Quoted 18 lines · Andrew Cooper
Quoted 6 lines · Elliott Mitchell
typeof()is available in Xen's build environment, which uses Xen's compiler. As these headers are public, they need strict standards conformance. Only__typeof__()is officially standardized.A compiler in standards conformance mode should report:
Quoted 7 lines
warning: implicit declaration of function 'typeof' is invalid in C99 [-Wimplicit-function-declaration]
(this has been observed with FreeBSD's kernel build environment)
Based-on-patch-by Julien Grall <[email protected]>, Sun Oct 4 20:33:04 2015 +0100Signed-off-by Elliott Mitchell <[email protected]>s!arm!xen/public! in the subject seeing as two thirds of the modifications are in non-ARM headers.
Quoted 7 lines
Acked-by Andrew Cooper <[email protected]>This wants backporting as a build fix, so should be considered for 4.15 at this point.
I wonder why our header checks don't pick this up. Do we need to throw a -pedantic around?
That's a long-standing issue with the checking: For issues to be found in macros, the macros would actually need to be used.
Jan
Jan Beulich writes ("Re: [PATCH for-4.15] arm: replace typeof() with __typeof__()"):
Quoted 3 lines · Andrew Cooper
Quoted 2 lines
This wants backporting as a build fix, so should be considered for 4.15 at this point.
Ian.
Hi,
Quoted 6 lines · Ian Jackson
Jan Beulich writes ("Re: [PATCH for-4.15] arm: replace
typeof()with__typeof__()"):Quoted 3 lines · Andrew Cooper
Quoted 2 lines
This wants backporting as a build fix, so should be considered for 4.15 at this point.
Release-Acked-by Ian Jackson <[email protected]>
Thanks! I have committed the patch now.
Cheers,
Signature · 1 line
Julien Grall
Quoted 7 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper
I wonder why our header checks don't pick this up.?? Do we need to throw a -pedantic around?
That's a long-standing issue with the checking: For issues to be found in macros, the macros would actually need to be used.
This is key since only the hunk for xen/include/public/arch-arm.h was found during a build. The other two hunks were found while preparing to submit this to the Xen Project since I checked for other occurrences of typeof(). Had I not spent the time to look, the other three uses might have generated 2-3 additional patches in the future.
Also notable the ARM portion was originally found more than 5 years ago (between 4.2 and 4.6), so this had been lurking for a long time.
Signature · 4 lines
(\___(\___(\______ --=> 8-) EHM <=-- ______/)___/)___/) \BS ( | [email protected] PGP 87145445 | ) / \_CS\ | _____ -O #include <stddisclaimer.h> O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445
Quoted 6 lines · Elliott Mitchell
typeof()is available in Xen's build environment, which uses Xen's compiler. As these headers are public, they need strict standards conformance. Only__typeof__()is officially standardized.A compiler in standards conformance mode should report:
Quoted 7 lines
warning: implicit declaration of function 'typeof' is invalid in C99 [-Wimplicit-function-declaration]
(this has been observed with FreeBSD's kernel build environment)
Based-on-patch-by Julien Grall <[email protected]>, Sun Oct 4 20:33:04 2015 +0100Signed-off-by Elliott Mitchell <[email protected]>
Juergen