Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp723059img; Fri, 22 Mar 2019 07:17:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpUVwkF3WiujqNnQGrZ1ztKlB6Phl2oM92DJs59jhvE4pfVPDCshZt9+OR+hvPKtpjPUXE X-Received: by 2002:a65:628f:: with SMTP id f15mr9308308pgv.410.1553264239821; Fri, 22 Mar 2019 07:17:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553264239; cv=none; d=google.com; s=arc-20160816; b=xEM+r0yGy+cCFduB4MRiO2gAHxXjiA9+HoXxTQY3FuIgeIvQlkjfK91XgYlNMUKoSJ dWJbw2tMZVA4FW+3aWIUp1b/tWhBxr3Q7WSFbvPcCauDxdAGp5Bf3ousY8fa6wz0OiSQ QIcRqsOhMPhGOZ+hITqh6zmdwuIxWCp6IIShtKmjzo8qc4ZjXTWQ6M3kD1vlYp6AP2Za t+wfjaZbSZSb5uiY9p7kfjurdj1qEzsFmM4cU4Jd5JwQZYNeJVeJ9VMJcFseX8LBSpPV eRC8H0sbKd8gvuuSl0JQHVKeOy0anf7qtaABKBx3TZao6jAPv5pohjCr2KnaUb3gD0iX 0Wcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=kPZ0I7dSeGGKOKCao/BNvdtgasGpQu8Zb0CtoFpKTLg=; b=0JVy6TkH793Bm/tjy2J0sbeSsY12tFRWBvilYOHnxg3lcYwxqssaw1OJS1SDFx988z 52bMdCj05K9hFZ31N1D6P+fUuTCjFgPO5Lb1msg5QdzAitIV3YehJ4aRUDUkVEDsiidv GoiZN8Q4AcOYOhYXTOw+XN4tdM4euh8nKxi/Ra25ur/kjGEuaTkyixZcR5lh3hJR88vK V6K96h0vKee3tCyOq1V1h8LapIbJXstHVXvDIbSBd8twiCPmpqzGKMey3pANiU9pBU45 dy5JCJun8BXssJG5UivvIMvmtZZf+w7MdhDm7HVLnbN0KmTIVL6wX1Slk+6r9ajUp5Ze bbow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9si6650628pgs.450.2019.03.22.07.17.04; Fri, 22 Mar 2019 07:17:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728107AbfCVOQZ (ORCPT + 99 others); Fri, 22 Mar 2019 10:16:25 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:34884 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727719AbfCVOQZ (ORCPT ); Fri, 22 Mar 2019 10:16:25 -0400 Received: by mail-qk1-f196.google.com with SMTP id z13so1298673qki.2; Fri, 22 Mar 2019 07:16:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kPZ0I7dSeGGKOKCao/BNvdtgasGpQu8Zb0CtoFpKTLg=; b=o7chK2UcOT1UN0zUM0QEWOm/heNkNt+PdP3qhgHCfsdc6kZ77DbW8YweVr0swWiLLp fBiXpm/2oZvpuVM0C0ng8baY3eU9Wju85IzXmdDuoCEuVS0WalhxlId6rRFALZ2YJKJD 3IX7eO0XAiUw042G/GiaRWt1CgHhNDZZ3fiqQb0N9KXemhgWw0j0aL0EEmC5Rgeki4N2 ELRoQhjTPlEbLnj3Dg2lHOWZk9EBpz5lDCTCiyvzWs/UxpEwG9Nm/KqS3Qkl+MTSBR1v 0VcNom9DMo7Jdhj1o4ESU6YnxmJN1RO+BoaowE6LI6dnahC2ttngNAL/3pELq/RLvD1v /AEg== X-Gm-Message-State: APjAAAXFtRgBPSj27iWnRgOvK5VY27BkILAC/Bw1T4SYkgHpDzMLIJHQ X7w53dMyqNyd+X/nlgG6P8LaGoL5XXPGfJeBI1w= X-Received: by 2002:a05:620a:133b:: with SMTP id p27mr7680631qkj.173.1553264184275; Fri, 22 Mar 2019 07:16:24 -0700 (PDT) MIME-Version: 1.0 References: <20190307235735.31487-1-natechancellor@gmail.com> In-Reply-To: <20190307235735.31487-1-natechancellor@gmail.com> From: Arnd Bergmann Date: Fri, 22 Mar 2019 15:16:06 +0100 Message-ID: Subject: Re: [PATCH] cfg80211: Change an 'else if' into an 'else' in cfg80211_calculate_bitrate_he To: Nathan Chancellor Cc: Johannes Berg , linux-wireless , "David S. Miller" , Networking , Linux Kernel Mailing List , clang-built-linux@googlegroups.com, Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 8, 2019 at 12:57 AM Nathan Chancellor wrote: > > When building with -Wsometimes-uninitialized, Clang warns: > > net/wireless/util.c:1223:11: warning: variable 'result' is used > uninitialized whenever 'if' condition is false > [-Wsometimes-uninitialized] > > Clang can't evaluate at this point that WARN(1, ...) always returns true > because __ret_warn_on is defined as !!(condition), which isn't > immediately evaluated as 1. Change this branch to else so that it's > clear to Clang that we intend to bail out here. > > Link: https://github.com/ClangBuiltLinux/linux/issues/382 > Suggested-by: Nick Desaulniers > Signed-off-by: Nathan Chancellor > --- > net/wireless/util.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/net/wireless/util.c b/net/wireless/util.c > index e4b8db5e81ec..75899b62bdc9 100644 > --- a/net/wireless/util.c > +++ b/net/wireless/util.c > @@ -1220,9 +1220,11 @@ static u32 cfg80211_calculate_bitrate_he(struct rate_info *rate) > else if (rate->bw == RATE_INFO_BW_HE_RU && > rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_26) > result = rates_26[rate->he_gi]; > - else if (WARN(1, "invalid HE MCS: bw:%d, ru:%d\n", > - rate->bw, rate->he_ru_alloc)) > + else { > + WARN(1, "invalid HE MCS: bw:%d, ru:%d\n", > + rate->bw, rate->he_ru_alloc); > return 0; > + } Reviewed-by: Arnd Bergmann I independently came up with the same fix before I saw yours, the only difference was that I avoided the extra curly braces using + else + return !WARN(1, "invalid HE MCS: bw:%d, ru:%d\n", + rate->bw, rate->he_ru_alloc); to avoid the mix of bare if() and if() {} Arnd