Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1073445rdd; Wed, 10 Jan 2024 07:57:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFMgodwFMYrEYLHEv+4bDTJwKFufc35R05gKcWHr6ANbnuTpphp99hHjkkXJW3C69HqwpY X-Received: by 2002:a25:ac9b:0:b0:dbf:2e9f:42b2 with SMTP id x27-20020a25ac9b000000b00dbf2e9f42b2mr604398ybi.116.1704902238347; Wed, 10 Jan 2024 07:57:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704902238; cv=none; d=google.com; s=arc-20160816; b=V/Oc6FH8jAwlNIEmZGT2igEcddR8MyyOPtP0GIcJAczsVFMdvyP3hxKhE0FIenm6CM ofFTPg7sCs3XHrrNtYH9sXS9LcvyIcs25wjDvfHUIhfSEvs7m5I2cA9uPToQUbNdLTgj NOHynJUaTu3vqfe0Mr2rvTDquvwPUAtDDm5Y+FE8AbEIQJH8NMgMIvKrCXS9bsRMw/k0 T4SG+bv1ihCzoWpA8Gr+l/4uHNgJWD1COgGaI7MMRE4UJif1Jd5P1TCduoJNxIMOa8g8 yl5nUJckaMj3T3uCesHpAosH+Qzo37kXQag7lpHoTb/DIkq9mrevmhmXlsU0a6wmhHoH KWhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=1gz90YRxD1liMwr8Oz945BZweVWst6Z8nXCBqLAlwmI=; fh=OONIVR/06K3HgRNFFM8g+eipt+dWnXnXjYnFYwlzZ0Y=; b=vLqj5tqxPffnUIzLCycep/n1VhyAh27PoRzAtAhlHiZnnt/DXd99Dxy+beahBUmZOM y/NN5XoS2Trdpx08R1nNvbpV2U7UlvzI92v9AOmAV+h8ZyOiws6jkWOfWbhYwlmZOhIN BEx8e4RjLHzp3Ez5Hz2lPyhueGFp491Rzq7pO2NAR8pkl1UAwWTUarCreZHVWsC0xxc6 7hnWahK6KPrVDqdd3ArLtG501Z/CkYPCuWW3/5SGJpmQC0Yz4sjVn/VinKPDv0qMp26W 6eNMEaAw0InNbaVwTmJuWiponQmB2aaJn0bg0HC0xVMou65/FclNP8xZeg9qr3x3chDc C1sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-22465-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22465-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id n17-20020ac85a11000000b00429b454aa5asi1385927qta.170.2024.01.10.07.57.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 07:57:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22465-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-22465-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22465-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D67451C266AE for ; Wed, 10 Jan 2024 15:57:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A43B4C62E; Wed, 10 Jan 2024 15:56:32 +0000 (UTC) Received: from mail.hallyn.com (mail.hallyn.com [178.63.66.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 749FA4C3C4; Wed, 10 Jan 2024 15:56:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hallyn.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mail.hallyn.com Received: by mail.hallyn.com (Postfix, from userid 1001) id CF337776; Wed, 10 Jan 2024 09:47:46 -0600 (CST) Date: Wed, 10 Jan 2024 09:47:46 -0600 From: "Serge E. Hallyn" To: Li zeming Cc: serge@hallyn.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernel: =?utf-8?Q?capability?= =?utf-8?B?OiBSZW1vdmUgdW5uZWNlc3Nhcnkg4oCYMOKAmQ==?= values from ret Message-ID: <20240110154746.GA92832@mail.hallyn.com> References: <20231228030854.11689-1-zeming@nfschina.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231228030854.11689-1-zeming@nfschina.com> 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 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