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 CB4C5E95A92 for ; Sun, 8 Oct 2023 00:49:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbjJHAtS (ORCPT ); Sat, 7 Oct 2023 20:49:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234015AbjJHAtP (ORCPT ); Sat, 7 Oct 2023 20:49:15 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B4DEED; Sat, 7 Oct 2023 17:49:09 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17C39C433CA; Sun, 8 Oct 2023 00:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696726148; bh=5qy+PofKbmFXF2n0Lmt1Civ3GMCVx0pfm8LZUZWnDF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iBdlYkNaUPwrOlkk3KE0sLMoZU9rUjrSltidLLZgKStTvfK/Ai/HLuYxoAGnfubEm jV2x4IKIhVXB7fsOhzwGVt9jvsyup2GPVgm/T9/Stf7qGnXHUD1kQJgp9gQFNMEt8u OUGjDUSJvy5SnBElsxVKeCufbvO+gJT3Te8gS8nCOJnMlDOuY4Moh4SSibqBsTx9jX cUnDQbnQ+8+bRhmksdPpKeVHasu8YxR/CyGy7JW9wyxttr3hf3bWUA/vBbZFf5v4KN mC8vra/1s+30g3bqZsHnu278wOrtBzjO9TdMC1mxqok75Usz9cPqWnt9NNuQWFwZKy m+VHiG0Row0xQ== 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 6.5 08/18] btrfs: initialize start_slot in btrfs_log_prealloc_extents Date: Sat, 7 Oct 2023 20:48:42 -0400 Message-Id: <20231008004853.3767621-8-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231008004853.3767621-1-sashal@kernel.org> References: <20231008004853.3767621-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 6.5.6 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 365a1cc0a3c35..a00e7a0bc713d 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -4722,7 +4722,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