Message ID | 20231228030854.11689-1-zeming@nfschina.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-12400-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1782261dyb; Wed, 27 Dec 2023 19:09:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGt2N9NuSPJPKzQOTPnolZ9BjHdbzwuIB5Pg/YZobvdv7vMbv3oiPyq/3676EI+OGgfwCNF X-Received: by 2002:a17:906:c342:b0:a26:84d8:9411 with SMTP id ci2-20020a170906c34200b00a2684d89411mr4523225ejb.128.1703732970016; Wed, 27 Dec 2023 19:09:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703732970; cv=none; d=google.com; s=arc-20160816; b=DlyryPRN6xgV7bqJiqoXjd7itym46qcYWSdDAPKSo3abWdMTcsGMTrTlWFj92lhtz7 aJzPhTcek0wvOfPWHEc3t/mkVRAXRyZtutE8mO2j4iNxy5pKb2sz+4QUU+trMBqp/oNe a2gYT9l6XlYZ5/mzzUYR7Pn5SKGQXzV82BByEMfc69vZphoY1I8PT5iJURfkCGCcLLz4 JpACMWMBVm6zxRwQdjuLgPqdTDkxKiAFK8GwXE0ZCtXNcgGw2DXUE5C86o6HwMt1ldlo P5BXF10xw6dk1wsPiXINtWoD9iZEyX18h8XyyFRVj9grfBJFZxvT5HxxBSkFCaQBOV4O rc0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=sa6NFNl6Lmf5X3XnINSKpAEYW8vUgH6fbly5Ko16Wuc=; fh=95s5pPBfooz2jZ19PGrn6cKeEbsfx2+H2Ck7dLws95w=; b=YAH6rE7Fms0h8EsR75ojqfvfsg7JPHida+caL+9i8rJD7GWjH1RYFZoVSRH9he4a6J ISW6VJtIxVqqDuX0nqFzxRZ4qi8meSigpkCZ2/FU8THKApIs7l0Iqr6HZSe+N+A5gSeV dTbuOFTfzAdrd9Yqp6AxRPGpf+kRKXtTFRx1DwKfY76k2Jw4IhDYzeIP/gCbte73irwP t1Snz7oDOt50dy0KiRdBbIWNVJKucgSYGpzIWGin2BL896CQy54+F6DP2oAipzu/w3Lx 5T7BiaesmXc9b11FIMu5LqbBVjTobHUhF68xGymhF8MFtz516NTD1IP8IgdDNHeGryYd lF3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12400-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12400-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g17-20020a170906199100b00a269fa0dcb3si6186941ejd.399.2023.12.27.19.09.29 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 19:09:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12400-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12400-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12400-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9DFBA1F22122 for <ouuuleilei@gmail.com>; Thu, 28 Dec 2023 03:09:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7DDA23B7; Thu, 28 Dec 2023 03:09:12 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail.nfschina.com (unknown [42.101.60.195]) by smtp.subspace.kernel.org (Postfix) with SMTP id 09B8B10F2; Thu, 28 Dec 2023 03:09:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nfschina.com Received: from localhost.localdomain (unknown [219.141.250.2]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id 568476019ED87; Thu, 28 Dec 2023 11:08:55 +0800 (CST) X-MD-Sfrom: zeming@nfschina.com X-MD-SrcIP: 219.141.250.2 From: Li zeming <zeming@nfschina.com> To: serge@hallyn.com Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Li zeming <zeming@nfschina.com> Subject: [PATCH] =?utf-8?q?kernel=3A_capability=3A_Remove_unnecessary_?= =?utf-8?q?=E2=80=980=E2=80=99_values_from_ret?= Date: Thu, 28 Dec 2023 11:08:54 +0800 Message-Id: <20231228030854.11689-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786493502800099120 X-GMAIL-MSGID: 1786493502800099120 |
Series |
kernel: capability: Remove unnecessary ‘0’ values from ret
|
|
Commit Message
Li zeming
Dec. 28, 2023, 3:08 a.m. UTC
The ret variable is assigned when it does not need to be defined, as it
has already been assigned before use.
Signed-off-by: Li zeming <zeming@nfschina.com>
---
kernel/capability.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, Dec 28, 2023 at 11:08:54AM +0800, Li zeming wrote: > The ret variable is assigned when it does not need to be defined, as it > has already been assigned before use. > > Signed-off-by: Li zeming <zeming@nfschina.com> This is true, so the patch would fine now. But it has not always been the case, and a future patch could add code at the start which makes it no longer true. While I'd hope we would easily catch that, I'm just not sure it's worth it. In fact I'm curious - does the compiler recognize this situation and optimize the = 0 away? > --- > kernel/capability.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/capability.c b/kernel/capability.c > index dac4df77e376e..ed8a983e21da4 100644 > --- a/kernel/capability.c > +++ b/kernel/capability.c > @@ -140,7 +140,7 @@ static inline int cap_get_target_pid(pid_t pid, kernel_cap_t *pEp, > */ > SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr) > { > - int ret = 0; > + int ret; > pid_t pid; > unsigned tocopy; > kernel_cap_t pE, pI, pP; > -- > 2.18.2
diff --git a/kernel/capability.c b/kernel/capability.c index dac4df77e376e..ed8a983e21da4 100644 --- a/kernel/capability.c +++ b/kernel/capability.c @@ -140,7 +140,7 @@ static inline int cap_get_target_pid(pid_t pid, kernel_cap_t *pEp, */ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr) { - int ret = 0; + int ret; pid_t pid; unsigned tocopy; kernel_cap_t pE, pI, pP;