Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3626282ybb; Mon, 6 Apr 2020 12:16:05 -0700 (PDT) X-Google-Smtp-Source: APiQypKvPHyBAUSliXO8AwgmCf9KjXAK2dqfiHRMTJseP/v9AYFeIlje8sMsglJDaN0DEN+vUI0K X-Received: by 2002:a9d:64cd:: with SMTP id n13mr18835400otl.274.1586200565809; Mon, 06 Apr 2020 12:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586200565; cv=none; d=google.com; s=arc-20160816; b=ZrchS9Np3YRpk+yBdRZW800B+0Ac7efN5S+DbJyD8X+82emnY1EzMIZ2Z8C5CFjdYX KvBmVgsuHoDfLAay1DLoUvKhT6T6krEvR112cBFGFaERadENorhMajeJJycbOKDB/5pX +mmYs2OcqiPv9BRZqWVSVEnnsjIBIS8uaSXGC48Lafcphac3ruuPuh36AIk6JKcMd7pl pfLL7IIf0AMU6h52BrF3RVspFeBwgHQOqzfC0LvTgoKSuV3Ypt5psIEuLYrvC0Dru9Sf naVdK1pLkFvS2jtCpNNjvwG3Ln9MgmsCJVE2Zg5fFp496yrWbTw3ZMboMaWm9DVNXAD1 gckA== 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:dkim-signature; bh=miv5n/k+feV617mYPhfbVUPV8D5MSyOCPj4Ac3CWtMw=; b=hjwuhfTVjiAbT8VmgdF+/ncDQ5TetfYDHOQR/4HSMmYQ3SivyYnThqF08NrZWuDGS6 aYyafFDP8fMKudpd/kVXu7Gz9aYZNRiE3H4Jqo9QKjHxjLYAiekJ6aKNFz7Xw3m5KorR lps/ncBOicn1PQ1hBeWBD4WgLlD36vIW9CTp40XqgSWZwFSP/QtfFaYE9TFLzFU3LklY 5UD85nhcHi8YwIspePXOPKVrkODCvJ2UI596hVO8uAzngVNEAs21dh/ZpZ413M7Esnri m8/f1qwmYOK6T2Pdtow3UUEgRdIawRNTwodM/2c/0Mr3saiLpsCf/+4LoCjjmQbjktOU aZiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MYMwPh61; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si209591otf.248.2020.04.06.12.15.37; Mon, 06 Apr 2020 12:16:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MYMwPh61; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726303AbgDFTPd (ORCPT + 99 others); Mon, 6 Apr 2020 15:15:33 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:46165 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbgDFTPd (ORCPT ); Mon, 6 Apr 2020 15:15:33 -0400 Received: by mail-oi1-f196.google.com with SMTP id q204so14063570oia.13 for ; Mon, 06 Apr 2020 12:15:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=miv5n/k+feV617mYPhfbVUPV8D5MSyOCPj4Ac3CWtMw=; b=MYMwPh61GsI6XsGu3waWGuBT+BFAV4nlTM+8bOVNOvORSLC9/gEEvCPUVQxfcBQJA8 XDodjyCNKYnd13iQN3dmjxvpJuq2OMKLUKHGYphGSTT7Zwzz7GecUfFA7WsIDkc16nvg BdHfFTckVYMzUtMxG+9RBCpQlVZQidM84ypVI= 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=miv5n/k+feV617mYPhfbVUPV8D5MSyOCPj4Ac3CWtMw=; b=LPG8PTRtGbfYIVhtki/2tvznqNuz2xnS82MW573CfYYYHMfUoCIRU7UFTabeD9zY8G QDtISYxrwYBebOLLhmmwjzcpCrS89oSjch4rzpQO80OfaKEf9uSsJgRRC36JZxf96+y4 ey9riDW+sc5ealJbJOuZ9hh4daxwg0viZfw7FQyQvLXaBCmKC4iZPCAmmp7MGmsFvSr2 EYEj2VtvG29dp4qHMyuyG3lRtzcqwHXfUbBMQFSed7gBrppUteY6mgjGYnY/9yfzB4rg 5kIznzSs7h20pwK/KT82JjkTpUBry3CflVMLKdHFsUSebtdZwhD1vCpR9j+rEFNn5C88 vGAQ== X-Gm-Message-State: AGi0PuZL12e/4uGsuJR88KLY8VcvZFUNR368j3pFJu32rQI5CcO3lKTC bfkQcknTCzU8Y4GvwjJbRcxzwfuO1krdgG7X3wEuZQ== X-Received: by 2002:aca:dd55:: with SMTP id u82mr618185oig.27.1586200532136; Mon, 06 Apr 2020 12:15:32 -0700 (PDT) MIME-Version: 1.0 References: <20200403150236.74232-1-linux@roeck-us.net> In-Reply-To: <20200403150236.74232-1-linux@roeck-us.net> From: Sonny Sasaka Date: Mon, 6 Apr 2020 12:15:19 -0700 Message-ID: Subject: Re: [PATCH] Bluetooth: Simplify / fix return values from tk_request To: Guenter Roeck Cc: Marcel Holtmann , Johan Hedberg , "David S . Miller" , Jakub Kicinski , BlueZ , netdev , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Reviewed-by: Sonny Sasaka On Fri, Apr 3, 2020 at 8:02 AM Guenter Roeck wrote: > > Some static checker run by 0day reports a variableScope warning. > > net/bluetooth/smp.c:870:6: warning: > The scope of the variable 'err' can be reduced. [variableScope] > > There is no need for two separate variables holding return values. > Stick with the existing variable. While at it, don't pre-initialize > 'ret' because it is set in each code path. > > tk_request() is supposed to return a negative error code on errors, > not a bluetooth return code. The calling code converts the return > value to SMP_UNSPECIFIED if needed. > > Fixes: 92516cd97fd4 ("Bluetooth: Always request for user confirmation for Just Works") > Cc: Sonny Sasaka > Signed-off-by: Guenter Roeck > --- > net/bluetooth/smp.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c > index d0b695ee49f6..30e8626dd553 100644 > --- a/net/bluetooth/smp.c > +++ b/net/bluetooth/smp.c > @@ -854,8 +854,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, > struct l2cap_chan *chan = conn->smp; > struct smp_chan *smp = chan->data; > u32 passkey = 0; > - int ret = 0; > - int err; > + int ret; > > /* Initialize key for JUST WORKS */ > memset(smp->tk, 0, sizeof(smp->tk)); > @@ -887,12 +886,12 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, > /* If Just Works, Continue with Zero TK and ask user-space for > * confirmation */ > if (smp->method == JUST_WORKS) { > - err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, > + ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, > hcon->type, > hcon->dst_type, > passkey, 1); > - if (err) > - return SMP_UNSPECIFIED; > + if (ret) > + return ret; > set_bit(SMP_FLAG_WAIT_USER, &smp->flags); > return 0; > } > -- > 2.17.1 >