[Drbd-dev] [Patch] drbd: check MODULE for THIS_MODULE

Andrew Morton akpm at linux-foundation.org
Tue Apr 10 01:14:27 CEST 2012


On Tue,  3 Apr 2012 14:13:36 +0800
Cong Wang <xiyou.wangcong at gmail.com> wrote:

> THIS_MODULE is NULL only when drbd is compiled as built-in,
> so the #ifdef CONFIG_MODULES should be #ifdef MODULE instead.
> 
> This fixes the warning:
> 
> drivers/block/drbd/drbd_main.c: In function ___drbd_buildtag___:
> drivers/block/drbd/drbd_main.c:4187:24: warning: the comparison will always evaluate as ___true___ for the address of _____this_module___ will never be NULL [-Waddress]
> 
> Cc: Lars Ellenberg <drbd-dev at lists.linbit.com>
> Signed-off-by: WANG Cong <xiyou.wangcong at gmail.com>
> 
> ---
> diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
> index 211fc44..96c432f 100644
> --- a/drivers/block/drbd/drbd_main.c
> +++ b/drivers/block/drbd/drbd_main.c
> @@ -4183,12 +4183,11 @@ const char *drbd_buildtag(void)
>  	static char buildtag[38] = "\0uilt-in";
>  
>  	if (buildtag[0] == 0) {
> -#ifdef CONFIG_MODULES
> -		if (THIS_MODULE != NULL)
> -			sprintf(buildtag, "srcversion: %-24s", THIS_MODULE->srcversion);
> -		else
> +#ifdef MODULE
> +		sprintf(buildtag, "srcversion: %-24s", THIS_MODULE->srcversion);
> +#else
> +		buildtag[0] = 'b';
>  #endif
> -			buildtag[0] = 'b';
>  	}
>  
>  	return buildtag;

If the MODULE_SRCVERSION_ALL help in init/Kconfig is to be believed,
this should depend on CONFIG_MODULE_SRCVERSION_ALL?

But drbd is the only driver in all of Linux which plays with
srcversion.  Can we just delete this code?



More information about the drbd-dev mailing list