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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFB57E95A89 for ; Sun, 8 Oct 2023 00:53:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344310AbjJHAxc (ORCPT ); Sat, 7 Oct 2023 20:53:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234498AbjJHAxI (ORCPT ); Sat, 7 Oct 2023 20:53:08 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F1F01BD3; Sat, 7 Oct 2023 17:50:01 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3D27C4166B; Sun, 8 Oct 2023 00:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696726198; bh=/4v5qOeRYAErE8E50MhTjzue/NXuAeNeE0WVpsua4Ng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oWZ/TntPOV63sOlAg9fSsa83K6DUyVMNIKIMElHyTIHEazd6VDTUT0QSyuMvg2ewd 2MYhZewemZI/mPkyQX6jiyj22u+ZPjx7lyDFDvn1vripGhGSZrfR2iVYJ3LdipAxg4 z+z25vxAr4uLBXArypVXIBF0qpm2o66dookNEXeM7g8MPSvXB1BWgVrOS7VkEE9P8P EHLT1OgeBlC4oqAZ7Kwxvm+fBtHY9qwlERrFNLfuiRZTWMNa/9NmRBBoDdq+b+VoIu 1uoZvFq3DHAEljGcQpt6uEMRQg1NtOW3k6toWTFjyHwcwnXwscxgOyv/sP3pnjFiwX /8KXlIkKSYX4A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Josef Bacik , Jens Axboe , David Sterba , Sasha Levin , clm@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 04/10] btrfs: initialize start_slot in btrfs_log_prealloc_extents Date: Sat, 7 Oct 2023 20:49:43 -0400 Message-Id: <20231008004950.3768189-4-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231008004950.3768189-1-sashal@kernel.org> References: <20231008004950.3768189-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.134 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Josef Bacik [ Upstream commit b4c639f699349880b7918b861e1bd360442ec450 ] Jens reported a compiler warning when using CONFIG_CC_OPTIMIZE_FOR_SIZE=y that looks like this fs/btrfs/tree-log.c: In function ‘btrfs_log_prealloc_extents’: fs/btrfs/tree-log.c:4828:23: warning: ‘start_slot’ may be used uninitialized [-Wmaybe-uninitialized] 4828 | ret = copy_items(trans, inode, dst_path, path, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | start_slot, ins_nr, 1, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~ fs/btrfs/tree-log.c:4725:13: note: ‘start_slot’ was declared here 4725 | int start_slot; | ^~~~~~~~~~ The compiler is incorrect, as we only use this code when ins_len > 0, and when ins_len > 0 we have start_slot properly initialized. However we generally find the -Wmaybe-uninitialized warnings valuable, so initialize start_slot to get rid of the warning. Reported-by: Jens Axboe Tested-by: Jens Axboe Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/tree-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 7c0c6fc0c536b..dcf0dd2093f58 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -4446,7 +4446,7 @@ static int btrfs_log_prealloc_extents(struct btrfs_trans_handle *trans, struct extent_buffer *leaf; int slot; int ins_nr = 0; - int start_slot; + int start_slot = 0; int ret; if (!(inode->flags & BTRFS_INODE_PREALLOC)) -- 2.40.1