Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp25809911rwd; Mon, 3 Jul 2023 01:03:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlF+JHO/EO47NBcKYpDdsy4bDk7nk7qMcrIdWxJ1c8/VRO2m5+UAAxcOb/3mkRk/6+fYrt8K X-Received: by 2002:a05:6a00:a25:b0:67a:553d:3bc3 with SMTP id p37-20020a056a000a2500b0067a553d3bc3mr13829261pfh.6.1688371412054; Mon, 03 Jul 2023 01:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688371412; cv=none; d=google.com; s=arc-20160816; b=z3LfFK9mOEpcx4cWkxxXPc9fASoE9LpwvJJ4dcRd6UZqmZzbheL/WLzzLkZKf1wpzB nXyRd0qndEoWc3d0l3MKQQcE6EIjkTnmNyKY5Fo5qVzmnWZYafexxMU2NQbRBi94RXP+ L23bzAyeSr3Jzy2Tpk8u0+npTmLuPXYr73VfXjThlwNy/1gxDLdjt9nKvuu4xTgG7cNN KaLaehQfgDAG4vxAXC0D2RZoUXYpl9ImeYBWllgn3OhNM9l9K6+CXRqL/PBQZy7NIPd6 0cJK8w5do5vNwjxnowNg8+NUgRLRSoUV8OhKkwynxderu/lNWKRPWIbU4bDB569JhVwJ s3/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=HVjAYscL6HIjmQVXAt6NCRCD420dRO8909yniiMykgc=; fh=KeSvIyAIjNCgCsaNw6hl/ttGGKaXCaZzBnwJNQzDYoc=; b=AmrQtSs+YFXcVl+aNByuNnigFxwJ5lOLb/B0JWkyUlP0zBkfW+ebDRNMBnkOXfAWlE TmiBxUe0Gz+tKaMwv0VJW0AHHmycOWVqdWjyKbAoBUrQDoLPPZUSBC9UMQJiPYlTbLhC IgWJBPrvWbNqzA2tiaofNMzB7Ga/UHf01ArqAwIsI8vjinl2LmB6Z3pzD+DGWk7t+vS/ zypjQdRmILUJ6vyeRruhHA+knv+AAca2cZMs/GQc5nnPcd+bUTGihgzWtFMTxOWkkuVs bCV4Nv83RgpOAOC7Mw1SJgH85BU3Tj1K052hikF60AOi5tnM1vWbYmo6IYE7L3Ws7Ri+ D+8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=iY49mJOi; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp22-20020a056a00349600b00643c4345942si16598092pfb.134.2023.07.03.01.03.24; Mon, 03 Jul 2023 01:03:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=iY49mJOi; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230298AbjGCIDF (ORCPT + 59 others); Mon, 3 Jul 2023 04:03:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231211AbjGCICv (ORCPT ); Mon, 3 Jul 2023 04:02:51 -0400 Received: from xry111.site (xry111.site [89.208.246.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 493BEE76; Mon, 3 Jul 2023 01:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1688371330; bh=mxT+hp0pGIWfYK4XM4T63enx90hO11e+CShcYgfo8H0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=iY49mJOi8grshnjTw7grQ3MauTVbYoj0RJm4FCUljQPdjDMRI8vQ6Y8pO6+2OS43+ P+fAm31J9NbYzsF/SYpRVP4ZRVFU8XLN7qQFvi4UD4SYiBFMOuvruDEw8syyH7vK+1 e2aIDQg/d2mT1Y1lDoBIik0J7t7IDAeqQ6I3a1eM= Received: from [IPv6:240e:358:110a:4b00:dc73:854d:832e:4] (unknown [IPv6:240e:358:110a:4b00:dc73:854d:832e:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384)) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id CD90E660BB; Mon, 3 Jul 2023 04:02:02 -0400 (EDT) Message-ID: <1b331090f91215d6c061a24c4cc61680995412f8.camel@xry111.site> Subject: Re: [PATCH v4] =?gb2312?Q?wifi=A3=BAmac80211=3A?= Replace the ternary conditional operator with conditional-statements From: Xi Ruoyao To: You Kangren , Johannes Berg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "open list:MAC80211" , "open list:NETWORKING [GENERAL]" , open list Cc: opensource.kernel@vivo.com Date: Mon, 03 Jul 2023 16:01:53 +0800 In-Reply-To: <20230703030200.1067-1-youkangren@vivo.com> References: <20230703030200.1067-1-youkangren@vivo.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Mon, 2023-07-03 at 11:02 +0800, You Kangren wrote: > Replacing ternary conditional operators with conditional statements=20 > ensures proper expression of meaning while making it easier for=20 > 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 > --- > =C2=A0net/mac80211/tdls.c | 3 ++- > =C2=A01 file changed, 2 insertions(+), 1 deletion(-) >=20 > 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, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0int ret; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct ieee80211_link_dat= a *link; > =C2=A0 > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0link_id =3D link_id >=3D 0 ? l= ink_id : 0; > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (link_id < 0) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0link_id =3D 0; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0rcu_read_lock(); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0link =3D rcu_dereference(= sdata->link[link_id]); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (WARN_ON(!link)) --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University