lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191104165148.GA2293059@kroah.com>
Date:   Mon, 4 Nov 2019 17:51:48 +0100
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Jules Irenge <jbi.octave@...il.com>
Cc:     outreachy-kernel@...glegroups.com, devel@...verdev.osuosl.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: rts5208: rewrite macro with GNU extension
 __auto_type

On Mon, Nov 04, 2019 at 04:44:00PM +0000, Jules Irenge wrote:
> Rewrite macro function with GNU extension __auto_type
> to remove issue detected by checkpatch tool.
> CHECK: MACRO argument reuse - possible side-effects?
> 
> Signed-off-by: Jules Irenge <jbi.octave@...il.com>
> ---
>  drivers/staging/rts5208/rtsx_chip.h | 92 +++++++++++++++++------------
>  1 file changed, 55 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/staging/rts5208/rtsx_chip.h b/drivers/staging/rts5208/rtsx_chip.h
> index bac65784d4a1..4b986d5c68da 100644
> --- a/drivers/staging/rts5208/rtsx_chip.h
> +++ b/drivers/staging/rts5208/rtsx_chip.h
> @@ -386,23 +386,31 @@ struct zone_entry {
>  
>  /* SD card */
>  #define CHK_SD(sd_card)			(((sd_card)->sd_type & 0xFF) == TYPE_SD)
> -#define CHK_SD_HS(sd_card)		(CHK_SD(sd_card) && \
> -					 ((sd_card)->sd_type & SD_HS))
> -#define CHK_SD_SDR50(sd_card)		(CHK_SD(sd_card) && \
> -					 ((sd_card)->sd_type & SD_SDR50))
> -#define CHK_SD_DDR50(sd_card)		(CHK_SD(sd_card) && \
> -					 ((sd_card)->sd_type & SD_DDR50))
> -#define CHK_SD_SDR104(sd_card)		(CHK_SD(sd_card) && \
> -					 ((sd_card)->sd_type & SD_SDR104))
> -#define CHK_SD_HCXC(sd_card)		(CHK_SD(sd_card) && \
> -					 ((sd_card)->sd_type & SD_HCXC))
> -#define CHK_SD_HC(sd_card)		(CHK_SD_HCXC(sd_card) && \
> -					 ((sd_card)->capacity <= 0x4000000))
> -#define CHK_SD_XC(sd_card)		(CHK_SD_HCXC(sd_card) && \
> -					 ((sd_card)->capacity > 0x4000000))
> -#define CHK_SD30_SPEED(sd_card)		(CHK_SD_SDR50(sd_card) || \
> -					 CHK_SD_DDR50(sd_card) || \
> -					 CHK_SD_SDR104(sd_card))
> +#define CHK_SD_HS(sd_card)\
> +	({__auto_type _sd = sd_card; CHK_SD(_sd) && \
> +					 (_sd->sd_type & SD_HS); })
> +#define CHK_SD_SDR50(sd_card)\
> +	({__auto_type _sd = sd_card; CHK_SD(_sd) && \
> +					 (_sd->sd_type & SD_SDR50); })
> +#define CHK_SD_DDR50(sd_card)\
> +	({__auto_type _sd = sd_card; CHK_SD(_sd) && \
> +					 (_sd->sd_type & SD_DDR50); })
> +#define CHK_SD_SDR104(sd_card)\
> +	({__auto_type _sd = sd_card; CHK_SD(_sd) && \
> +					 (_sd->sd_type & SD_SDR104); })
> +#define CHK_SD_HCXC(sd_card)\
> +	({__auto_type _sd = sd_card; CHK_SD(_sd) && \
> +					 (_sd->sd_type & SD_HCXC); })
> +#define CHK_SD_HC(sd_card)\
> +	({__auto_type _sd = sd_card; CHK_SD_HCXC(_sd) && \
> +					(_sd->capacity <= 0x4000000); })
> +#define CHK_SD_XC(sd_card)\
> +	({__auto_type _sd = sd_card; CHK_SD_HCXC(_sd) && \
> +					 (_sd->capacity > 0x4000000); })
> +#define CHK_SD30_SPEED(sd_card)\
> +	({__auto_type _sd = sd_card; CHK_SD_SDR50(_sd) || \
> +					CHK_SD_DDR50(_sd) || \
> +					CHK_SD_SDR104(_sd); })
>  
>  #define SET_SD(sd_card)			((sd_card)->sd_type = TYPE_SD)
>  #define SET_SD_HS(sd_card)		((sd_card)->sd_type |= SD_HS)
> @@ -420,18 +428,24 @@ struct zone_entry {
>  /* MMC card */
>  #define CHK_MMC(sd_card)		(((sd_card)->sd_type & 0xFF) == \
>  					 TYPE_MMC)
> -#define CHK_MMC_26M(sd_card)		(CHK_MMC(sd_card) && \
> -					 ((sd_card)->sd_type & MMC_26M))
> -#define CHK_MMC_52M(sd_card)		(CHK_MMC(sd_card) && \
> -					 ((sd_card)->sd_type & MMC_52M))
> -#define CHK_MMC_4BIT(sd_card)		(CHK_MMC(sd_card) && \
> -					 ((sd_card)->sd_type & MMC_4BIT))
> -#define CHK_MMC_8BIT(sd_card)		(CHK_MMC(sd_card) && \
> -					 ((sd_card)->sd_type & MMC_8BIT))
> -#define CHK_MMC_SECTOR_MODE(sd_card)	(CHK_MMC(sd_card) && \
> -					 ((sd_card)->sd_type & MMC_SECTOR_MODE))
> -#define CHK_MMC_DDR52(sd_card)		(CHK_MMC(sd_card) && \
> -					 ((sd_card)->sd_type & MMC_DDR52))
> +#define CHK_MMC_26M(sd_card)\
> +	({__auto_type _sd = sd_card; CHK_MMC(_sd) && \
> +					 (_sd->sd_type & MMC_26M); })

Ick, no.  These are obviously pointers, which can not be "evaluated
twice" so this whole thing is just fine.

checkpatch is just a "hint" that you might want to look at the code.
This stuff is just fine, look at how it is being used for proof of that.

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ