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] [day] [month] [year] [list]
Date: Mon, 03 Jul 2023 16:01:53 +0800
From: Xi Ruoyao <xry111@...111.site>
To: You Kangren <youkangren@...o.com>, Johannes Berg
 <johannes@...solutions.net>,  "David S. Miller" <davem@...emloft.net>, Eric
 Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo
 Abeni <pabeni@...hat.com>, "open list:MAC80211"
 <linux-wireless@...r.kernel.org>, "open list:NETWORKING [GENERAL]"
 <netdev@...r.kernel.org>, open list <linux-kernel@...r.kernel.org>
Cc: opensource.kernel@...o.com
Subject: Re: [PATCH v4] wifi:mac80211: Replace the
 ternary conditional operator with conditional-statements

On Mon, 2023-07-03 at 11:02 +0800, You Kangren wrote:
> Replacing ternary conditional operators with conditional statements 
> ensures proper expression of meaning while making it easier for 
> the compiler to generate code.

No you underestimated the compiler here.  Both GCC and Clang translates
the ternary operator and the if statement into the same IR during very
early passes.

Maybe there is some reason to avoid ternary operators, but "making it
easier for compiler" is just invalid.  And "my text book/my teacher says
ternary operators are bad" will be invalid too, the kernel coding
convention is not what the text book or teacher say.

> Signed-off-by: You Kangren <youkangren@...o.com>
> ---
>  net/mac80211/tdls.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/mac80211/tdls.c b/net/mac80211/tdls.c
> index a4af3b7675ef..41176491965d 100644
> --- a/net/mac80211/tdls.c
> +++ b/net/mac80211/tdls.c
> @@ -946,7 +946,8 @@ ieee80211_tdls_build_mgmt_packet_data(struct
> ieee80211_sub_if_data *sdata,
>         int ret;
>         struct ieee80211_link_data *link;
>  
> -       link_id = link_id >= 0 ? link_id : 0;
> +       if (link_id < 0)
> +               link_id = 0;
>         rcu_read_lock();
>         link = rcu_dereference(sdata->link[link_id]);
>         if (WARN_ON(!link))

-- 
Xi Ruoyao <xry111@...111.site>
School of Aerospace Science and Technology, Xidian University

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ