2010-06-11 06:36:02

by Javier Martinez Canillas

[permalink] [raw]
Subject: [PATCH] staging/wlags49_hs: Fix build error when CONFIG_SYSFS is not set

With current linux-next I got a build error with wlags49_h2 driver when CONFIG_SYSFS is not set.

This patch solves the issue.

Signed-off-by: Javier Martinez Canillas <[email protected]>
---
drivers/staging/wlags49_h2/wl_sysfs.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wlags49_h2/wl_sysfs.h b/drivers/staging/wlags49_h2/wl_sysfs.h
index 6d96d03..7d5895d 100644
--- a/drivers/staging/wlags49_h2/wl_sysfs.h
+++ b/drivers/staging/wlags49_h2/wl_sysfs.h
@@ -2,6 +2,6 @@
extern void register_wlags_sysfs(struct net_device *);
extern void unregister_wlags_sysfs(struct net_device *);
#else
-static void register_wlags_sysfs(struct net_device *) { return; };
-static void unregister_wlags_sysfs(struct net_device *) { return; };
+#define register_wlags_sysfs(net_device) { }
+#define unregister_wlags_sysfs(net_device) { }
#endif
--
1.7.0.4





2010-06-11 06:41:46

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] staging/wlags49_hs: Fix build error when CONFIG_SYSFS is not set

On Fri, 2010-06-11 at 02:35 -0400, Javier Martinez Canillas wrote:
> With current linux-next I got a build error with wlags49_h2 driver when CONFIG_SYSFS is not set.
> diff --git a/drivers/staging/wlags49_h2/wl_sysfs.h b/drivers/staging/wlags49_h2/wl_sysfs.h
> index 6d96d03..7d5895d 100644
> --- a/drivers/staging/wlags49_h2/wl_sysfs.h
> +++ b/drivers/staging/wlags49_h2/wl_sysfs.h
> @@ -2,6 +2,6 @@
> extern void register_wlags_sysfs(struct net_device *);
> extern void unregister_wlags_sysfs(struct net_device *);
> #else
> -static void register_wlags_sysfs(struct net_device *) { return; };
> -static void unregister_wlags_sysfs(struct net_device *) { return; };
> +#define register_wlags_sysfs(net_device) { }
> +#define unregister_wlags_sysfs(net_device) { }
> #endif

Yes, that works, but a better fix would be to remove the
semicolons after the function close braces.
---
diff --git a/drivers/staging/wlags49_h2/wl_sysfs.h
b/drivers/staging/wlags49_h2/wl_sysfs.h
index 6d96d03..7d5895d 100644
--- a/drivers/staging/wlags49_h2/wl_sysfs.h
+++ b/drivers/staging/wlags49_h2/wl_sysfs.h
@@ -2,6 +2,6 @@
extern void register_wlags_sysfs(struct net_device *);
extern void unregister_wlags_sysfs(struct net_device *);
#else
-static void register_wlags_sysfs(struct net_device *) { return; };
-static void unregister_wlags_sysfs(struct net_device *) { return; };
+static void register_wlags_sysfs(struct net_device *) { return; }
+static void unregister_wlags_sysfs(struct net_device *) { return; }
#endif

2010-06-11 12:46:18

by Javier Martinez Canillas

[permalink] [raw]
Subject: Re: [PATCH] staging/wlags49_hs: Fix build error when CONFIG_SYSFS is not set

>>  extern void register_wlags_sysfs(struct net_device *);
>>  extern void unregister_wlags_sysfs(struct net_device *);
>>  #else
>> -static void register_wlags_sysfs(struct net_device *) { return; };
>> -static void unregister_wlags_sysfs(struct net_device *) { return; };
>> +#define register_wlags_sysfs(net_device) { }
>> +#define unregister_wlags_sysfs(net_device) { }
>>  #endif
>
> Yes, that works, but a better fix would be to remove the
> semicolons after the function close braces.
> ---

Why would it be better? With a macro you avoid the overhead of a
function call that does nothing.
I personally think a macro fit better in this case.

Best regards,

-----------------------------------------
Javier Martínez Canillas
+595 981 88 66 58

2010-06-11 16:52:44

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] staging/wlags49_hs: Fix build error when CONFIG_SYSFS is not set

On Fri, 2010-06-11 at 08:46 -0400, Javier Martinez Canillas wrote:
> >> extern void register_wlags_sysfs(struct net_device *);
> >> extern void unregister_wlags_sysfs(struct net_device *);
> >> #else
> >> -static void register_wlags_sysfs(struct net_device *) { return; };
> >> -static void unregister_wlags_sysfs(struct net_device *) { return; };
> >> +#define register_wlags_sysfs(net_device) { }
> >> +#define unregister_wlags_sysfs(net_device) { }
> >> #endif
> > Yes, that works, but a better fix would be to remove the
> > semicolons after the function close braces.
> > ---
> Why would it be better? With a macro you avoid the overhead of a
> function call that does nothing.

Check the generated code.
$ make drivers/staging/wlags49_h2/wl_sysfs.lst

> I personally think a macro fit better in this case.

Check the general kernel use of macros vs functions.
Functions verify proper arguments, macros do not.

2010-06-11 22:13:13

by Javier Martinez Canillas

[permalink] [raw]
Subject: Re: [PATCH] staging/wlags49_hs: Fix build error when CONFIG_SYSFS is not set

On Fri, Jun 11, 2010 at 12:52 PM, Joe Perches <[email protected]> wrote:
> On Fri, 2010-06-11 at 08:46 -0400, Javier Martinez Canillas wrote:
>
> Check the general kernel use of macros vs functions.
> Functions verify proper arguments, macros do not.
>
>
>

I see. thank you very much for clarify this. I'm will generate a
correct patch and resend.

Best regards,

-----------------------------------------
Javier Martínez Canillas
+595 981 88 66 58