From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 EA8A23C6A22 for ; Mon, 2 Mar 2026 20:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772484187; cv=none; b=OxS7mh2DFK0EFg/2F1hJTC2hDmjFhC9D7ye++f2buYnlJ6+OpCRW3X8g273yqLxpW/zMPT2enf/61OX+DQt1/M6ELT1VSd1xQdFrlRLskeaCL6xZJ28DaORsfw1zD9w1MZ0eQFCL9p6YRSfdMsWFz7YtI0jfqEPgTsY9VG2p7Ts= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772484187; c=relaxed/simple; bh=8jcRbTjIYYoEeo6c1jQlp3VJwq3xRQpJ9kuc5+hcUTQ=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=fmLi423HFQrWtJqlhHk2Y5miZSKxKK60//x+8GVnwZUjwxtUhR9Bc+e5sFIGK/FLZze9XOzx8DEKPpTSPE03NdtYDutjanmsTmyofzX0Xj+wG9WJQxa/zVz7yO8CHqwz0kmYd4kVJyTyma0CvGGWd70Ho3Gl9+UijeGS2yhLVWc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=UCZ68iJ+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="UCZ68iJ+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A328C2BC87; Mon, 2 Mar 2026 20:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1772484186; bh=8jcRbTjIYYoEeo6c1jQlp3VJwq3xRQpJ9kuc5+hcUTQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UCZ68iJ+2TwxqdabJNKHBbq8jGZ/2EJdLAUuAH3h7VBEgYxI/n7kXeNv3eVD1Zz3P yvI8PZGs8KBq2Wakr6Q1C8l0bLhK848YNlHcAPZAInPOQjTPJqDdbNYT+xzk4K9krV aVLTx76+vTC1aHSADmIXR3n1vTndOO3XdMl4V6Nw= Date: Mon, 2 Mar 2026 12:43:05 -0800 From: Andrew Morton To: Alexey Suchkov Cc: dywoq.contact@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox , Joshua Hahn Subject: Re: [PATCH] [PATCH v2] mm: initialize 'seq' in gup_fast to remove -Wmaybe-uninitialized warning Message-Id: <20260302124305.6bb7f34228bfe07094de51ca@linux-foundation.org> In-Reply-To: <20260302193405.37961-1-dywoq.contact@gmail.com> References: <20260302191237.34375-1-dywoq.contact@gmail.com> <20260302193405.37961-1-dywoq.contact@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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=UTF-8 Content-Transfer-Encoding: 8bit On Mon, 2 Mar 2026 22:34:05 +0300 Alexey Suchkov wrote: > The local variable 'seq' in gup_fast (mm/gup.c) was declared > without initialization, which can trigger: > > mm/gup.c:3165:20: warning: ‘seq’ may be used uninitialized [-Wmaybe-uninitialized] > > Initialize 'seq' to 0. This does not change behavior, since > read_seqcount_retry() always writes to it before use. > > ... > > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -3131,7 +3131,7 @@ static unsigned long gup_fast(unsigned long start, unsigned long end, > { > unsigned long flags; > int nr_pinned = 0; > - unsigned seq; > + unsigned int seq = 0; > > if (!IS_ENABLED(CONFIG_HAVE_GUP_FAST) || > !gup_fast_permitted(start, end)) stupid gcc. I liked uninitalized_var(), particularly for its self-documenting nature. Never agreed with Linus's hate on it. Thanks, I tweaked the changelog a bit: : The local variable 'seq' in gup_fast (mm/gup.c) was declared : without initialization, which with gcc-15.2.1 can trigger: : : mm/gup.c:3165:20: warning: `seq' may be used uninitialized [-Wmaybe-uninitialized] : : Work around this by initializing 'seq' to 0. This does not change : behavior, since read_seqcount_retry() always writes to it before use.