LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM
cover LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM
Replace the use of nested functions where a normal function will suffice.
Nested functions are not liked by upstream kernel developers in general. Their use breaks the use of clang as a compiler, and doesn't make the code any better.
This code now works for both gcc and clang.
The LLVMLinux project aims to fully build the Linux kernel using both gcc and clang (the C front end for the LLVM compiler infrastructure project).
Behan Webster (2):
arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb
drivers/video/fbdev/omap2/dss/dispc-compat.c | 9 +++++---- drivers/video/fbdev/omap2/dss/manager-sysfs.c | 16 +++++++++------- drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 14 +++++++------- 3 files changed, 21 insertions(+), 18 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss
Replace the use of nested functions where a normal function will suffice.
Nested functions are not liked by upstream kernel developers in general. Their use breaks the use of clang as a compiler, and doesn't make the code any better.
This code now works for both gcc and clang.
--- drivers/video/fbdev/omap2/dss/dispc-compat.c | 9 +++++---- drivers/video/fbdev/omap2/dss/manager-sysfs.c | 16 +++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-)
drivers/video/fbdev/omap2/dss/dispc-compat.c +5 -4
@@ -634,13 +634,14 @@ void dispc_mgr_disable_sync(enum omap_channel channel)WARN_ON (1 ); } +static inline void dispc_irq_wait_handler (void *data,u32 mask) +{ +complete ((struct completion *)data); +} +int omap_dispc_wait_for_irq_interruptible_timeout (u32 irqmask,unsigned long timeout) { -void dispc_irq_wait_handler (void *data,u32 mask) - { -complete ((struct completion *)data); - }int r;DECLARE_COMPLETION_ONSTACK (completion);
drivers/video/fbdev/omap2/dss/manager-sysfs.c +9 -7
@@ -44,6 +44,13 @@ static ssize_t manager_display_show(struct omap_overlay_manager *mgr, char *buf) dssdev->name : "<none>"); } +static int manager_display_match (struct omap_dss_device *dssdev,void *data) +{ +const char *str = data; + +return sysfs_streq (dssdev->name, str); +} +static ssize_t manager_display_store (struct omap_overlay_manager *mgr,const char *buf,size_t size) {
@@ -52,17 +59,12 @@ static ssize_t manager_display_store(struct omap_overlay_manager *mgr,struct omap_dss_device *dssdev =NULL ;struct omap_dss_device *old_dssdev; -int match (struct omap_dss_device *dssdev,void *data) - { -const char *str = data; -return sysfs_streq (dssdev->name, str); - } -if (buf[size-1 ] ='\n' ) --len;if (len >0 ) - dssdev =omap_dss_find_device ((void *)buf, match); + dssdev =omap_dss_find_device ((void *)buf, + manager_display_match);if (len >0 && dssdev =NULL )return -EINVAL ;
Signature · 1 line
1.9.1
Re: [PATCH 1/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss
Quoted 11 lines · Behan Webster
Replace the use of nested functions where a normal function will suffice.
Nested functions are not liked by upstream kernel developers in general. Their use breaks the use of clang as a compiler, and doesn't make the code any better.
This code now works for both gcc and clang.
Signed-off-by Behan Webster <[email protected]>Suggested-by Arnd Bergmann <[email protected]>Cc Arnd Bergmann <[email protected]>
another one that make sense :-) And probably also deserves checkpatch/coccinelle/sparse.
Signature · 1 line
balbi
Re: [PATCH 1/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss
Quoted 7 lines · Felipe Balbi
Quoted 6 lines · Behan Webster
Replace the use of nested functions where a normal function will suffice.
Nested functions are not liked by upstream kernel developers in general. Their use breaks the use of clang as a compiler, and doesn't make the code any better.
Quoted 7 lines
Quoted 5 lines
This code now works for both gcc and clang.
Signed-off-by Behan Webster <[email protected]>Suggested-by Arnd Bergmann <[email protected]>Cc Arnd Bergmann <[email protected]>another one that make sense :-) And probably also deserves checkpatch/coccinelle/sparse.
Indeed! That would be very appreciated.
The clang static analyzer already points this one out. :)
Behan
Signature · 2 lines
Behan Webster [email protected]
PATCH 2/2 arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb
In reply to Behan WebsterReplace the use of nested functions where a normal function will suffice.
Nested functions are not liked by upstream kernel developers in general. Their use breaks the use of clang as a compiler, and doesn't make the code any better.
This code now works for both gcc and clang.
--- drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/video/fbdev/omap2/omapfb/omapfb-main.c +7 -7
@@ -273,16 +273,16 @@ static struct omapfb_colormode omapfb_colormodes[] = { }, }; +static bool cmp_component(struct fb_bitfield *f1, struct fb_bitfield *f2) +{ + return f1->length = f2->length && + f1->offset = f2->offset && + f1->msb_right = f2->msb_right; +} + static bool cmp_var_to_colormode(struct fb_var_screeninfo *var, struct omapfb_colormode *color) { - bool cmp_component(struct fb_bitfield *f1, struct fb_bitfield *f2) - { - return f1->length = f2->length && - f1->offset = f2->offset && - f1->msb_right = f2->msb_right; - } - if (var->bits_per_pixel = 0 || var->red.length = 0 || var->blue.length = 0 ||
Signature · 1 line
1.9.1
Re: [PATCH 2/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb
Quoted 11 lines · Behan Webster
Replace the use of nested functions where a normal function will suffice.
Nested functions are not liked by upstream kernel developers in general. Their use breaks the use of clang as a compiler, and doesn't make the code any better.
This code now works for both gcc and clang.
Signed-off-by Behan Webster <[email protected]>Suggested-by Arnd Bergmann <[email protected]>Cc Arnd Bergmann <[email protected]>
Signature · 1 line
balbi
Quoted 11 lines · Behan Webster
Replace the use of nested functions where a normal function will suffice.
Nested functions are not liked by upstream kernel developers in general. Their use breaks the use of clang as a compiler, and doesn't make the code any better.
This code now works for both gcc and clang.
The LLVMLinux project aims to fully build the Linux kernel using both gcc and clang (the C front end for the LLVM compiler infrastructure project).
Quoted 9 lines
Behan Webster (2):
arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfbdrivers/video/fbdev/omap2/dss/dispc-compat.c | 9 +++++---- drivers/video/fbdev/omap2/dss/manager-sysfs.c | 16 +++++++++------- drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 14 +++++++------- 3 files changed, 21 insertions(+), 18 deletions(-)
I have to say I do like small helper funcs as nested functions, as they are restricted inside the parent function's scope. But, of course, nested funcs have their issues.
So looks fine to me, queuing for 3.18.
Tomi