From: Simon Horman <simon.horman@corigine.com>
To: You Kangren <youkangren@vivo.com>
Cc: Kalle Valo <kvalo@kernel.org>, Dongliang Mu <dzm91@hust.edu.cn>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
"open list:RAYLINK/WEBGEAR 802.11 WIRELESS LAN DRIVER"
<linux-wireless@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>,
opensource.kernel@vivo.com
Subject: Re: [PATCH] wifi: ray_cs: Replace the ternary conditional operator with min()
Date: Mon, 26 Jun 2023 14:28:51 +0200 [thread overview]
Message-ID: <ZJmEg5Jw4e9KZVfA@corigine.com> (raw)
In-Reply-To: <20230626093504.1325-1-youkangren@vivo.com>
On Mon, Jun 26, 2023 at 05:35:02PM +0800, You Kangren wrote:
> Replace the ternary conditional operator with min() to make the code clean
>
> Signed-off-by: You Kangren <youkangren@vivo.com>
> ---
> drivers/net/wireless/legacy/ray_cs.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/legacy/ray_cs.c b/drivers/net/wireless/legacy/ray_cs.c
> index 8ace797ce951..96f34d90f601 100644
> --- a/drivers/net/wireless/legacy/ray_cs.c
> +++ b/drivers/net/wireless/legacy/ray_cs.c
> @@ -2086,8 +2086,7 @@ static void ray_rx(struct net_device *dev, ray_dev_t *local,
> rx_data(dev, prcs, pkt_addr, rx_len);
>
> copy_from_rx_buff(local, (UCHAR *) &local->last_bcn, pkt_addr,
> - rx_len < sizeof(struct beacon_rx) ?
> - rx_len : sizeof(struct beacon_rx));
> + min(rx_len, sizeof(struct beacon_rx));
Hi You Kangren,
I like where you are going with this patch.
But unfortunately using min() here causes an x86_64 allmodconfig W=1 build
to fail with both gcc-12 and clang-16.
Perhaps min_t() would be more appropriate?
GCC 12.3.0 says:
In file included from ./include/linux/kernel.h:27,
from ./arch/x86/include/asm/percpu.h:27,
from ./arch/x86/include/asm/nospec-branch.h:14,
from ./arch/x86/include/asm/paravirt_types.h:27,
from ./arch/x86/include/asm/ptrace.h:97,
from ./arch/x86/include/asm/math_emu.h:5,
from ./arch/x86/include/asm/processor.h:13,
from ./arch/x86/include/asm/timex.h:5,
from ./include/linux/timex.h:67,
from ./include/linux/time32.h:13,
from ./include/linux/time.h:60,
from ./include/linux/stat.h:19,
from ./include/linux/module.h:13,
from drivers/net/wireless/legacy/ray_cs.c:20:
drivers/net/wireless/legacy/ray_cs.c: In function 'ray_rx':
./include/linux/minmax.h:20:35: warning: comparison of distinct pointer types lacks a cast
20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
| ^~
./include/linux/minmax.h:26:18: note: in expansion of macro '__typecheck'
26 | (__typecheck(x, y) && __no_side_effects(x, y))
| ^~~~~~~~~~~
./include/linux/minmax.h:36:31: note: in expansion of macro '__safe_cmp'
36 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~
./include/linux/minmax.h:67:25: note: in expansion of macro '__careful_cmp'
67 | #define min(x, y) __careful_cmp(x, y, <)
| ^~~~~~~~~~~~~
drivers/net/wireless/legacy/ray_cs.c:2089:35: note: in expansion of macro 'min'
2089 | min(rx_len, sizeof(struct beacon_rx));
| ^~~
drivers/net/wireless/legacy/ray_cs.c:2089:72: error: expected ')' before ';' token
2089 | min(rx_len, sizeof(struct beacon_rx));
| ^
drivers/net/wireless/legacy/ray_cs.c:2088:34: note: to match this '('
2088 | copy_from_rx_buff(local, (UCHAR *) &local->last_bcn, pkt_addr,
| ^
drivers/net/wireless/legacy/ray_cs.c:2098:23: error: expected ';' before '}' token
2098 | break;
| ^
| ;
2099 | }
| ~
next prev parent reply other threads:[~2023-06-26 12:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-26 9:35 [PATCH] wifi: ray_cs: Replace the ternary conditional operator with min() You Kangren
2023-06-26 12:28 ` Simon Horman [this message]
2023-06-26 18:48 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZJmEg5Jw4e9KZVfA@corigine.com \
--to=simon.horman@corigine.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=dzm91@hust.edu.cn \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=opensource.kernel@vivo.com \
--cc=youkangren@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox