Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1618360

Re: [PATCH] ath9k: Add cast to u8 to FREQ2FBIN macro

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH] ath9k: Add cast to u8 to FREQ2FBIN macro
Date 2017-04-06 23:40 +0200
Message-ID <ttnih-6lW-3@gated-at.bofh.it> (permalink)
References <ttn8B-6iF-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, 2017-04-06 at 14:21 -0700, Matthias Kaehlcke wrote:
> The macro results are assigned to u8 variables/fields. Adding the cast
> fixes plenty of clang warnings about "implicit conversion from 'int' to
> 'u8'".
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>  drivers/net/wireless/ath/ath9k/eeprom.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/eeprom.h b/drivers/net/wireless/ath/ath9k/eeprom.h
> index 30bf722e33ed..31390af6c33e 100644
> --- a/drivers/net/wireless/ath/ath9k/eeprom.h
> +++ b/drivers/net/wireless/ath/ath9k/eeprom.h
> @@ -106,7 +106,7 @@
>  #define AR9285_RDEXT_DEFAULT    0x1F
>  
>  #define ATH9K_POW_SM(_r, _s)	(((_r) & 0x3f) << (_s))
> -#define FREQ2FBIN(x, y)		((y) ? ((x) - 2300) : (((x) - 4800) / 5))
> +#define FREQ2FBIN(x, y)		(u8)((y) ? ((x) - 2300) : (((x) - 4800) / 5))

Maybe better to use:

static inline u8 FREQ2FBIN(int x, int y)
{
	if (y)
		return x - 2300;
	return (x - 4800) / 5;
}

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] ath9k: Add cast to u8 to FREQ2FBIN macro Matthias Kaehlcke <mka@chromium.org> - 2017-04-06 23:30 +0200
  Re: [PATCH] ath9k: Add cast to u8 to FREQ2FBIN macro Joe Perches <joe@perches.com> - 2017-04-06 23:40 +0200
    Re: [PATCH] ath9k: Add cast to u8 to FREQ2FBIN macro Matthias Kaehlcke <mka@chromium.org> - 2017-04-07 02:00 +0200
      Re: [PATCH] ath9k: Add cast to u8 to FREQ2FBIN macro Joe Perches <joe@perches.com> - 2017-04-07 04:40 +0200

csiph-web