From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6488CC433E0 for ; Thu, 4 Jun 2020 03:33:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 25715206DC for ; Thu, 4 Jun 2020 03:33:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="An50kzaF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25715206DC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CB8948000A; Wed, 3 Jun 2020 23:33:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8F3A80007; Wed, 3 Jun 2020 23:33:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA6CF8000A; Wed, 3 Jun 2020 23:33:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0054.hostedemail.com [216.40.44.54]) by kanga.kvack.org (Postfix) with ESMTP id A2DCE80007 for ; Wed, 3 Jun 2020 23:33:20 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6FCE840EE for ; Thu, 4 Jun 2020 03:33:20 +0000 (UTC) X-FDA: 76890108960.13.toad22_5750fa2cdb31c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 527A918140B60 for ; Thu, 4 Jun 2020 03:33:20 +0000 (UTC) X-HE-Tag: toad22_5750fa2cdb31c X-Filterd-Recvd-Size: 5869 Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Jun 2020 03:33:19 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id c194so3856201oig.5 for ; Wed, 03 Jun 2020 20:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8Faii11PvSo51bdsAemmq3+A0d7oNRL4/GLZ67cBSMg=; b=An50kzaFvA39pC4h/8bP4oIWOqTSG046GlYB5+emgXeZszQTtbXKqSjDjHWmw8n8um VXpLlrq83m2ZAS8J26v56FTDUjfbdw4fWaYAjEK9Ox20DjsyL1kabqtQvJ0qaNA6AN6x WQHzqT/rIk17+lobg6a1Qz4niujZV9KifIFoGU6CnMcUxFKQqfbbxVvC4XVpIL5SSTtt 6xGwnGkCkYTcRnL3OaIoBi5ReA1N/8hWVCv9k4QJ2ieUjD5HXDXWHDv6XZ9+0M+W+p2j GHjogeet/zLPYDJFnvbD/NGsLeEzoRiqyu6IiidyEX/Bv9x5fa84lURyrkrcSmOp3voL uKqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8Faii11PvSo51bdsAemmq3+A0d7oNRL4/GLZ67cBSMg=; b=cxOkisCJCT33Jcy+dL+bLhJua5sJvkFfmmaa7rJWRbmu3sB8uZlQ0LFW0FBZtkXWuj x90imFLIMTez5yHfH00cfAVsgXhAjtFpqCCEqWVBYShVtsudwAwGSv/2i7DVWh/1n4+h IJKuV1ZDHPcCQDLm5YA2d1jU0vJy4MG5uQdKH9yDwODJ4jAgsEnngmG5CAREFWYtkPTE NteTvhdlGvYDU+yh4NAC2EPWWMl47wmt8+x3cEzXVW2OMYf+id9grN/xeKW/LhclNnCK gq5Coj/dr+ktczRuL+Xr6e/+BVmbQHzV39NVNK98DrbYeGcnrhTcEnIuiIUDz4yfGBXZ LrQA== X-Gm-Message-State: AOAM532pH3vovWud4CYTyV8/oDO0SMohdICNDEwir4v1xeWt2xGkjqHD 2YxFt3kvdO9X5oWSX0eyExo= X-Google-Smtp-Source: ABdhPJwnzfVVb4uCTFG1lxg30QZrwlILRC7pC1WmnFYGEgON5rzpjMpDI7aYXPTUb98IobrtcgZC+g== X-Received: by 2002:aca:b707:: with SMTP id h7mr1938490oif.174.1591241599191; Wed, 03 Jun 2020 20:33:19 -0700 (PDT) Received: from ubuntu-n2-xlarge-x86 ([2604:1380:4111:8b00::3]) by smtp.gmail.com with ESMTPSA id n60sm327816otn.75.2020.06.03.20.33.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 20:33:17 -0700 (PDT) Date: Wed, 3 Jun 2020 20:33:15 -0700 From: Nathan Chancellor To: Kees Cook Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Miguel Ojeda , Alexander Potapenko , Joe Perches , Andy Whitcroft , x86@kernel.org, drbd-dev@lists.linbit.com, linux-block@vger.kernel.org, b43-dev@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-ide@vger.kernel.org, linux-clk@vger.kernel.org, linux-spi@vger.kernel.org, linux-mm@kvack.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH 09/10] treewide: Remove uninitialized_var() usage Message-ID: <20200604033315.GA1131596@ubuntu-n2-xlarge-x86> References: <20200603233203.1695403-1-keescook@chromium.org> <20200603233203.1695403-10-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200603233203.1695403-10-keescook@chromium.org> X-Rspamd-Queue-Id: 527A918140B60 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Jun 03, 2020 at 04:32:02PM -0700, Kees Cook wrote: > Using uninitialized_var() is dangerous as it papers over real bugs[1] > (or can in the future), and suppresses unrelated compiler warnings > (e.g. "unused variable"). If the compiler thinks it is uninitialized, > either simply initialize the variable or make compiler changes. > > I preparation for removing[2] the[3] macro[4], remove all remaining > needless uses with the following script: > > git grep '\buninitialized_var\b' | cut -d: -f1 | sort -u | \ > xargs perl -pi -e \ > 's/\buninitialized_var\(([^\)]+)\)/\1/g; > s:\s*/\* (GCC be quiet|to make compiler happy) \*/$::g;' > > drivers/video/fbdev/riva/riva_hw.c was manually tweaked to avoid > pathological white-space. > > No outstanding warnings were found building allmodconfig with GCC 9.3.0 > for x86_64, i386, arm64, arm, powerpc, powerpc64le, s390x, mips, sparc64, > alpha, and m68k. > > [1] https://lore.kernel.org/lkml/20200603174714.192027-1-glider@google.com/ > [2] https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/ > [3] https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/ > [4] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/ > > Signed-off-by: Kees Cook > diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c > index a0f6813f4560..a71fa7204882 100644 > --- a/arch/powerpc/kvm/book3s_pr.c > +++ b/arch/powerpc/kvm/book3s_pr.c > @@ -1829,7 +1829,7 @@ static int kvmppc_vcpu_run_pr(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) > { > int ret; > #ifdef CONFIG_ALTIVEC > - unsigned long uninitialized_var(vrsave); > + unsigned long vrsave; > #endif This variable is actually unused: ../arch/powerpc/kvm/book3s_pr.c:1832:16: warning: unused variable 'vrsave' [-Wunused-variable] unsigned long vrsave; ^ 1 warning generated. It has been unused since commit 99dae3bad28d ("KVM: PPC: Load/save FP/VMX/VSX state directly to/from vcpu struct"). $ git grep vrsave 99dae3bad28d8fdd32b7bfdd5e2ec7bb2d4d019d arch/powerpc/kvm/book3s_pr.c 99dae3bad28d8fdd32b7bfdd5e2ec7bb2d4d019d:arch/powerpc/kvm/book3s_pr.c: unsigned long uninitialized_var(vrsave); I would nuke the whole '#ifdef' block. Cheers, Nathan