Message ID | 20231017060824.10434-1-zeming@nfschina.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3926797vqb; Mon, 16 Oct 2023 23:08:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFb06L/B/hPbZfvrzluv0GwFFLNIMoGJDMSXdCXSHW2hkuK66FGaGE1D2G/M3Sz9TL7ftCc X-Received: by 2002:a05:6870:96a3:b0:1e9:8a7e:5893 with SMTP id o35-20020a05687096a300b001e98a7e5893mr1687781oaq.5.1697522933402; Mon, 16 Oct 2023 23:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697522933; cv=none; d=google.com; s=arc-20160816; b=ejo/Vo8JH+rdXIrOybWWbarxM8UcAhDarDovU5UVA+H9kemfI4Ao0+P/dn+seMM5Go u+Jxr6TMQz048PVbd41PEx/izy+R6PT8oZUHCQePS7xmH3AclAYvIhcHi8bO7HOmVbU/ knlecaLf6ZxMENV21S1k7ZupmFJgKYBfzZgxFZdJSTB3IF/mxeJxbyaAAt6gqzMYSjrb J2UkJwirNepSXu+wXhlp6LjG0tFcvqf8q3wjAPdhuudYybeTr4WZvwFlQCyBFZp9kUa1 P+5vAoHEVcxJLmvNrH3NI8FktTj7/ukX5dkC4MzpG4cARL326iOuDYK1P484dejHdWA+ gZzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=XcDfGqBPbATUxYY5w9Jp1R5ZLGWesMN/TD0qVldg9Fo=; fh=GSIBOmdhrT9ROZ/+r/0ZNMx4Up5jYpxe09fcPpk5r1w=; b=JZOdi98jilEQIY0Ar7svL2W924BRVUumlmJ6NKhybIKR1UDm1fVnrckB1AtKaU8Aje XmeXt5M/YJQfzXWul/eDVlb0Fj7SmlbDsJ1n7WOypieLcpuZ+k7ijfMxNk9LhZNI28Zs Nz1E8GpbzQ+pLwAF4Dd5kJWtPsQtd1G63xlCZoE2q7yhKhyik4lEqpgdAFT2gm+/A44M 6oUeoy7NsmgVvG3AA6DuenDNJnHRz0P28pkq3+7xaiX5zgWX4kVYH+bsm6N+V5ZB+kLS a/zXC0BU9n3iJoCB3sR9Vhl0nHdj04VeT667YFPhZxPf5Gy5EoVw3eekY/nhOrpWWtWu LqFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bu23-20020a632957000000b005ae05010bc4si1060286pgb.235.2023.10.16.23.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:08:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id B095B8032A32; Mon, 16 Oct 2023 23:08:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234467AbjJQGIm (ORCPT <rfc822;hjfbswb@gmail.com> + 19 others); Tue, 17 Oct 2023 02:08:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230343AbjJQGIl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 17 Oct 2023 02:08:41 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id CFCC5AB for <linux-kernel@vger.kernel.org>; Mon, 16 Oct 2023 23:08:39 -0700 (PDT) Received: from localhost.localdomain (unknown [219.141.250.2]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id C5CC46027B14C; Tue, 17 Oct 2023 14:08:25 +0800 (CST) X-MD-Sfrom: zeming@nfschina.com X-MD-SrcIP: 219.141.250.2 From: Li zeming <zeming@nfschina.com> To: gor@linux.ibm.com, mark.rutland@arm.com, hca@linux.ibm.com Cc: linux-kernel@vger.kernel.org, Li zeming <zeming@nfschina.com> Subject: [PATCH] =?utf-8?q?stackleak=3A_Remove_unnecessary_=E2=80=980?= =?utf-8?q?=E2=80=99_values_from_ret?= Date: Tue, 17 Oct 2023 14:08:24 +0800 Message-Id: <20231017060824.10434-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 16 Oct 2023 23:08:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779981807555961261 X-GMAIL-MSGID: 1779981807555961261 |
Series |
stackleak: Remove unnecessary ‘0’ values from ret
|
|
Commit Message
Li zeming
Oct. 17, 2023, 6:08 a.m. UTC
ret is assigned first, so it does not need to initialize the assignment.
Signed-off-by: Li zeming <zeming@nfschina.com>
---
kernel/stackleak.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, Oct 17, 2023 at 02:08:24PM +0800, Li zeming wrote: > ret is assigned first, so it does not need to initialize the assignment. > > Signed-off-by: Li zeming <zeming@nfschina.com> Does this actually need to change? It's not harmful, and deleting the assignment doesn't save any lines of code. That said, I don't have strong feelings either way, and Kees is the de-facto-yet-undocumented maintainer for this code, so I will leave it to him to decide whether to apply. Mark. > --- > kernel/stackleak.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/stackleak.c b/kernel/stackleak.c > index 34c9d81eea940..3faf863593846 100644 > --- a/kernel/stackleak.c > +++ b/kernel/stackleak.c > @@ -24,7 +24,7 @@ static DEFINE_STATIC_KEY_FALSE(stack_erasing_bypass); > static int stack_erasing_sysctl(struct ctl_table *table, int write, > void __user *buffer, size_t *lenp, loff_t *ppos) > { > - int ret = 0; > + int ret; > int state = !static_branch_unlikely(&stack_erasing_bypass); > int prev_state = state; > > -- > 2.18.2 >
On Tue, Oct 17, 2023 at 11:14:43AM +0100, Mark Rutland wrote: > On Tue, Oct 17, 2023 at 02:08:24PM +0800, Li zeming wrote: > > ret is assigned first, so it does not need to initialize the assignment. > > > > Signed-off-by: Li zeming <zeming@nfschina.com> > > Does this actually need to change? It's not harmful, and deleting the > assignment doesn't save any lines of code. I prefer explicit initialization. Any unused initialization will be optimized away by the compiler during Dead Store Elimination, so all removing the initialization does is make the code more fragile in the future. > That said, I don't have strong feelings either way, and Kees is the > de-facto-yet-undocumented maintainer for this code, so I will leave it to him > to decide whether to apply. Oh, hm, good point. I will add a MAINTAINER entry for it. Thanks! -Kees
On Wed, Oct 18, 2023 at 05:39:21PM -0700, Kees Cook wrote: > On Tue, Oct 17, 2023 at 11:14:43AM +0100, Mark Rutland wrote: > > On Tue, Oct 17, 2023 at 02:08:24PM +0800, Li zeming wrote: > > > ret is assigned first, so it does not need to initialize the assignment. > > > > > > Signed-off-by: Li zeming <zeming@nfschina.com> > > > > Does this actually need to change? It's not harmful, and deleting the > > assignment doesn't save any lines of code. > > I prefer explicit initialization. Any unused initialization will be > optimized away by the compiler during Dead Store Elimination, so all > removing the initialization does is make the code more fragile in the > future. > Also, be careful with those submissions, and do not take the claim in the commit message at face value. Several of them introduce uninitialize variable errors. I had two submissions for the watchdog subsystem, and both of them were wrong. Guenter
diff --git a/kernel/stackleak.c b/kernel/stackleak.c index 34c9d81eea940..3faf863593846 100644 --- a/kernel/stackleak.c +++ b/kernel/stackleak.c @@ -24,7 +24,7 @@ static DEFINE_STATIC_KEY_FALSE(stack_erasing_bypass); static int stack_erasing_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - int ret = 0; + int ret; int state = !static_branch_unlikely(&stack_erasing_bypass); int prev_state = state;