Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3608075ybb; Mon, 6 Apr 2020 11:55:12 -0700 (PDT) X-Google-Smtp-Source: APiQypJxiM46cHUnYIycHPy64CVRPQM3XF97NM0uRvwzHTtk1iTCQ8wcNEIiGl5fdiFY1zBLiiaO X-Received: by 2002:a9d:2c01:: with SMTP id f1mr19170513otb.67.1586199311967; Mon, 06 Apr 2020 11:55:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586199311; cv=none; d=google.com; s=arc-20160816; b=n8f11Ah+7VVDOzRrVxsB4sx/r0eP1E20HGisLf16glic+uacCnK8NLFcxBNJFygB2V BC0V7Jh7Q1QQKzw0/j57C/NUMMEPA4fwzLffb5EBU/kcqECvVBWorzYY5vXdvMqrdrdX 2hWC0W9FxrEPrJFZ/B50KGroQnsNgd2uN+5SEHeP2sy7lHzhJRSKHe7yEZgSC2dUzIB3 fGOb1gUeKgkNE79BVyl6ClYe+yb9WfhMSATdP8y0kPaG20Z3FPjJ5P8+xLd6HwxSn4Hw WKFox3vGtS8+Z4RIpSH6OfW3lM0R5TCM/XnWi8SCoEsGkBE+JGKwHtGIukbt/RvxhIKw 58mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3s/azVcAKYn4FoQVJtdOnYETn5jVBnR54PceNuclGDY=; b=sjGQ1a7FCy9hCeFjhDq95PwI4EIvyTwqYDv0iYXfSs4Gn3sIfuu6qMjeASEY623mIH U/4RogL8yAIuLY7bqUWi5/ZvIM/P8OgDTFQXvvttjEov8T8SOjfhTetQbDBpqDLIwnkS GdW51vFdBB/n+9pIEx1dBE6FXtPnDzk2WojFMXt2HRUbB3I8EQzPkQfQQgcqYsKMvmLc fJblSARPSDtEW1DEjEssi3swP83603G+rsApyZoVaHrofPK9KJ7jWm4ZlHocMZO3o3x/ L9HrjVFLk89Yb3Q8aYhFwkCsKwur3axZo7wFNKYSrk5+T7CiW8x0aUJLcp7N9Z/ZMQtc LZnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Cn3Ws38V; 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 r184si7396441oie.79.2020.04.06.11.54.58; Mon, 06 Apr 2020 11:55:11 -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=Cn3Ws38V; 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 S1725995AbgDFSyw (ORCPT + 99 others); Mon, 6 Apr 2020 14:54:52 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43956 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbgDFSyw (ORCPT ); Mon, 6 Apr 2020 14:54:52 -0400 Received: by mail-pg1-f194.google.com with SMTP id s4so420543pgk.10 for ; Mon, 06 Apr 2020 11:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3s/azVcAKYn4FoQVJtdOnYETn5jVBnR54PceNuclGDY=; b=Cn3Ws38VjU3XKA0YB+NsZVZON02LqxDqX2Joumi9OSkK1/4XEJ9aWWN+dBydJIceHR dq1K+tDGrYE8Nzg7abG1ESPx6SrMdR7dqdivll6u/+p1OEWBXY9YszFS/Rt9IlpSnHWC SF/c6JPbJcBAtAbCtgI4uWYKnuLBmj6YG09w0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3s/azVcAKYn4FoQVJtdOnYETn5jVBnR54PceNuclGDY=; b=HCGLm9fPRS0jNG7JcRv+yXrvq73Mr98UkHazm8JiwA3dBzqEDSsyOiG7icyc5MA/As agvk/6U6JBKAqZQXcQJdtQu3Z05dBJmdhpnYZmXX2vZwE3yl9+UVgWClEu4TM5o4M5Wq yTA0H9TfgayXHkWGQPcCJs9jaFE19+1fvnNZwW9WsS3g9i7vIxxfE99Z1W4/KAJai24g ev5g/JHpsSlkDjnfQKVcS1XEbUnDQk4DorjYHM9QoODtgUanMOuwxxAXWDRMLZLsntiZ 6hPdVHUn55MYMZWMmiJKimINnGvyB4fMleL536caiXrsbTVlfbI/CXKUIOQfUmYBZ8E6 7NvQ== X-Gm-Message-State: AGi0Pub9hecYXB3GR6FvM9fRcWwSVUR6gJsqE/3lh4BFL2T71K8OEoJo 10J28MQTl0nUOVTcsxCiM/zTHmJYMOw= X-Received: by 2002:a62:2f01:: with SMTP id v1mr886586pfv.136.1586199290345; Mon, 06 Apr 2020 11:54:50 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:b7e2:9910:bd78:608d]) by smtp.gmail.com with ESMTPSA id y4sm12253649pfo.39.2020.04.06.11.54.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2020 11:54:49 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Guenter Roeck , Sonny Sasaka Subject: [PATCH] Bluetooth: Simplify / fix return values from tk_request Date: Mon, 6 Apr 2020 11:54:38 -0700 Message-Id: <20200406185438.13576-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200406184523.GA49680@roeck-us.net> References: <20200406184523.GA49680@roeck-us.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Guenter Roeck 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 Reviewed-by: Sonny Sasaka --- 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 d0b695ee4..30e8626dd 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.24.1