From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757640AbcJXXss (ORCPT ); Mon, 24 Oct 2016 19:48:48 -0400 Received: from mga06.intel.com ([134.134.136.31]:26367 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753009AbcJXXsq (ORCPT ); Mon, 24 Oct 2016 19:48:46 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,543,1473145200"; d="scan'208";a="777116023" Date: Tue, 25 Oct 2016 02:48:41 +0300 From: "Kirill A. Shutemov" To: Arnd Bergmann Cc: Hugh Dickins , Andrew Morton , Al Viro , Michal Hocko , Andreas Gruenbacher , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] shmem: avoid maybe-uninitialized warning Message-ID: <20161024234841.dk673yxv7fhw5rx3@black.fi.intel.com> References: <20161024205725.786455-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20161024205725.786455-1-arnd@arndb.de> User-Agent: NeoMutt/20160916 (1.7.0) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 24, 2016 at 10:57:09PM +0200, Arnd Bergmann wrote: > After enabling -Wmaybe-uninitialized warnings, we get a false-postive > warning for shmem: > > mm/shmem.c: In function ‘shmem_getpage_gfp’: > include/linux/spinlock.h:332:21: error: ‘info’ may be used uninitialized in this function [-Werror=maybe-uninitialized] > > This can be easily avoided, since the correct 'info' pointer is known > at the time we first enter the function, so we can simply move the > initialization up. Moving it before the first label avoids the > warning and lets us remove two later initializations. > > Note that the function is so hard to read that it not only confuses > the compiler, but also most readers and without this patch it could\ > easily break if one of the 'goto's changed. > > Link: https://www.spinics.net/lists/kernel/msg2368133.html > Acked-by: Michal Hocko > Signed-off-by: Arnd Bergmann Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov