* [PATCH] btrfs-progs: receive: fix unused variable warning without LZO
@ 2026-09-29 7:14 liuh0329
2026-09-29 10:37 ` Qu Wenruo
0 siblings, 1 reply; 7+ messages in thread
From: liuh0329 @ 2026-09-29 7:14 UTC (permalink / raw)
To: linux-btrfs; +Cc: liuh0329
When btrfs-progs is built without LZO support, sector_shift is still
declared in decompress_and_write(), while all its uses are guarded by
COMPRESSION_LZO. This results in an unused variable warning.
Guard the declaration with COMPRESSION_LZO as well.
Fixes: 345731fff32d ("btrfs-progs: receive: optional build for lzo, zstd")
Signed-off-by: liuh0329 <liuhuan01@kylinos.cn>
---
cmds/receive.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/cmds/receive.c b/cmds/receive.c
index 49103ea3..14a9ba03 100644
--- a/cmds/receive.c
+++ b/cmds/receive.c
@@ -1186,7 +1186,9 @@ static int decompress_and_write(struct btrfs_receive *rctx,
{
int ret = 0;
char *unencoded_data;
+#if COMPRESSION_LZO
int sector_shift = 0;
+#endif
u64 written = 0;
unencoded_data = calloc(unencoded_len, 1);
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] btrfs-progs: receive: fix unused variable warning without LZO 2026-09-29 7:14 [PATCH] btrfs-progs: receive: fix unused variable warning without LZO liuh0329 @ 2026-09-29 10:37 ` Qu Wenruo 2026-09-30 2:21 ` [PATCH v2] " liuh0329 0 siblings, 1 reply; 7+ messages in thread From: Qu Wenruo @ 2026-09-29 10:37 UTC (permalink / raw) To: liuh0329, linux-btrfs 在 2026/9/29 16:44, liuh0329 写道: > When btrfs-progs is built without LZO support, sector_shift is still > declared in decompress_and_write(), while all its uses are guarded by > COMPRESSION_LZO. This results in an unused variable warning. > > Guard the declaration with COMPRESSION_LZO as well. Just move the declaration to the only usage. That makes more sense than introducing new #if block. > > Fixes: 345731fff32d ("btrfs-progs: receive: optional build for lzo, zstd") > Signed-off-by: liuh0329 <liuhuan01@kylinos.cn> > --- > cmds/receive.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/cmds/receive.c b/cmds/receive.c > index 49103ea3..14a9ba03 100644 > --- a/cmds/receive.c > +++ b/cmds/receive.c > @@ -1186,7 +1186,9 @@ static int decompress_and_write(struct btrfs_receive *rctx, > { > int ret = 0; > char *unencoded_data; > +#if COMPRESSION_LZO > int sector_shift = 0; > +#endif > u64 written = 0; > > unencoded_data = calloc(unencoded_len, 1); ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] btrfs-progs: receive: fix unused variable warning without LZO 2026-09-29 10:37 ` Qu Wenruo @ 2026-09-30 2:21 ` liuh0329 2026-09-30 4:59 ` Qu Wenruo 0 siblings, 1 reply; 7+ messages in thread From: liuh0329 @ 2026-09-30 2:21 UTC (permalink / raw) To: quwenruo.btrfs; +Cc: linux-btrfs, liuhuan01 When btrfs-progs is built without LZO support, sector_shift is still declared in decompress_and_write(), while all its uses are guarded by COMPRESSION_LZO. This results in an unused variable warning. Move the sector_shift declaration to the LZO-specific code path so it is only declared when LZO support is enabled. Fixes: 345731fff32d ("btrfs-progs: receive: optional build for lzo, zstd") Signed-off-by: liuh0329 <liuhuan01@kylinos.cn> --- Changes in v2: - Move sector_shift declaration to its only usage, as suggested by Qu Wenruo. - Add a local scope for sector_shift. cmds/receive.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cmds/receive.c b/cmds/receive.c index 49103ea3..02c864a6 100644 --- a/cmds/receive.c +++ b/cmds/receive.c @@ -1186,7 +1186,6 @@ static int decompress_and_write(struct btrfs_receive *rctx, { int ret = 0; char *unencoded_data; - int sector_shift = 0; u64 written = 0; unencoded_data = calloc(unencoded_len, 1); @@ -1220,13 +1219,16 @@ static int decompress_and_write(struct btrfs_receive *rctx, case BTRFS_ENCODED_IO_COMPRESSION_LZO_32K: case BTRFS_ENCODED_IO_COMPRESSION_LZO_64K: #if COMPRESSION_LZO - sector_shift = - compression - BTRFS_ENCODED_IO_COMPRESSION_LZO_4K + 12; - ret = decompress_lzo(encoded_data, encoded_len, unencoded_data, - unencoded_len, 1U << sector_shift); - if (ret) - goto out; - break; + { + int sector_shift = + compression - BTRFS_ENCODED_IO_COMPRESSION_LZO_4K + 12; + + ret = decompress_lzo(encoded_data, encoded_len, unencoded_data, + unencoded_len, 1U << sector_shift); + if (ret) + goto out; + break; + } #else error("LZO compression for stream not compiled in"); ret = -EOPNOTSUPP; -- 2.54.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] btrfs-progs: receive: fix unused variable warning without LZO 2026-09-30 2:21 ` [PATCH v2] " liuh0329 @ 2026-09-30 4:59 ` Qu Wenruo 2026-09-30 6:17 ` liuh 2026-09-30 6:43 ` [PATCH v3] " liuh0329 0 siblings, 2 replies; 7+ messages in thread From: Qu Wenruo @ 2026-09-30 4:59 UTC (permalink / raw) To: liuh0329, quwenruo.btrfs; +Cc: linux-btrfs 在 2026/9/30 11:51, liuh0329 写道: > When btrfs-progs is built without LZO support, sector_shift is still > declared in decompress_and_write(), while all its uses are guarded by > COMPRESSION_LZO. This results in an unused variable warning. > > Move the sector_shift declaration to the LZO-specific code path so it is > only declared when LZO support is enabled. > > Fixes: 345731fff32d ("btrfs-progs: receive: optional build for lzo, zstd") > Signed-off-by: liuh0329 <liuhuan01@kylinos.cn> > > --- > Changes in v2: > - Move sector_shift declaration to its only usage, as suggested by Qu Wenruo. > - Add a local scope for sector_shift. > > cmds/receive.c | 18 ++++++++++-------- > 1 file changed, 10 insertions(+), 8 deletions(-) > > diff --git a/cmds/receive.c b/cmds/receive.c > index 49103ea3..02c864a6 100644 > --- a/cmds/receive.c > +++ b/cmds/receive.c > @@ -1186,7 +1186,6 @@ static int decompress_and_write(struct btrfs_receive *rctx, > { > int ret = 0; > char *unencoded_data; > - int sector_shift = 0; > u64 written = 0; > > unencoded_data = calloc(unencoded_len, 1); > @@ -1220,13 +1219,16 @@ static int decompress_and_write(struct btrfs_receive *rctx, > case BTRFS_ENCODED_IO_COMPRESSION_LZO_32K: > case BTRFS_ENCODED_IO_COMPRESSION_LZO_64K: > #if COMPRESSION_LZO > - sector_shift = > - compression - BTRFS_ENCODED_IO_COMPRESSION_LZO_4K + 12; > - ret = decompress_lzo(encoded_data, encoded_len, unencoded_data, > - unencoded_len, 1U << sector_shift); > - if (ret) > - goto out; > - break; > + { Why? Why not just simply do the following? diff --git a/cmds/receive.c b/cmds/receive.c index 49103ea3eeea..f592a044801d 100644 --- a/cmds/receive.c +++ b/cmds/receive.c @@ -1186,7 +1186,6 @@ static int decompress_and_write(struct btrfs_receive *rctx, { int ret = 0; char *unencoded_data; - int sector_shift = 0; u64 written = 0; unencoded_data = calloc(unencoded_len, 1); @@ -1220,7 +1219,7 @@ static int decompress_and_write(struct btrfs_receive *rctx, case BTRFS_ENCODED_IO_COMPRESSION_LZO_32K: case BTRFS_ENCODED_IO_COMPRESSION_LZO_64K: #if COMPRESSION_LZO - sector_shift = + int sector_shift = compression - BTRFS_ENCODED_IO_COMPRESSION_LZO_4K + 12; ret = decompress_lzo(encoded_data, encoded_len, unencoded_data, unencoded_len, 1U << sector_shift); > + int sector_shift = > + compression - BTRFS_ENCODED_IO_COMPRESSION_LZO_4K + 12; > + > + ret = decompress_lzo(encoded_data, encoded_len, unencoded_data, > + unencoded_len, 1U << sector_shift); > + if (ret) > + goto out; > + break; > + } > #else > error("LZO compression for stream not compiled in"); > ret = -EOPNOTSUPP; ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] btrfs-progs: receive: fix unused variable warning without LZO 2026-09-30 4:59 ` Qu Wenruo @ 2026-09-30 6:17 ` liuh 2026-09-30 6:43 ` [PATCH v3] " liuh0329 1 sibling, 0 replies; 7+ messages in thread From: liuh @ 2026-09-30 6:17 UTC (permalink / raw) To: Qu Wenruo, linux-btrfs 在 2026/9/30 12:59, Qu Wenruo 写道: > > > 在 2026/9/30 11:51, liuh0329 写道: >> When btrfs-progs is built without LZO support, sector_shift is still >> declared in decompress_and_write(), while all its uses are guarded by >> COMPRESSION_LZO. This results in an unused variable warning. >> >> Move the sector_shift declaration to the LZO-specific code path so it is >> only declared when LZO support is enabled. >> >> Fixes: 345731fff32d ("btrfs-progs: receive: optional build for lzo, >> zstd") >> Signed-off-by: liuh0329 <liuhuan01@kylinos.cn> >> >> --- >> Changes in v2: >> - Move sector_shift declaration to its only usage, as suggested by Qu >> Wenruo. >> - Add a local scope for sector_shift. >> >> cmds/receive.c | 18 ++++++++++-------- >> 1 file changed, 10 insertions(+), 8 deletions(-) >> >> diff --git a/cmds/receive.c b/cmds/receive.c >> index 49103ea3..02c864a6 100644 >> --- a/cmds/receive.c >> +++ b/cmds/receive.c >> @@ -1186,7 +1186,6 @@ static int decompress_and_write(struct >> btrfs_receive *rctx, >> { >> int ret = 0; >> char *unencoded_data; >> - int sector_shift = 0; >> u64 written = 0; >> unencoded_data = calloc(unencoded_len, 1); >> @@ -1220,13 +1219,16 @@ static int decompress_and_write(struct >> btrfs_receive *rctx, >> case BTRFS_ENCODED_IO_COMPRESSION_LZO_32K: >> case BTRFS_ENCODED_IO_COMPRESSION_LZO_64K: >> #if COMPRESSION_LZO >> - sector_shift = >> - compression - BTRFS_ENCODED_IO_COMPRESSION_LZO_4K + 12; >> - ret = decompress_lzo(encoded_data, encoded_len, unencoded_data, >> - unencoded_len, 1U << sector_shift); >> - if (ret) >> - goto out; >> - break; >> + { > > Why? Why not just simply do the following? Thanks, that is simpler. I'll drop the extra scope and move the declaration directly to its only usage in v3. > diff --git a/cmds/receive.c b/cmds/receive.c > index 49103ea3eeea..f592a044801d 100644 > --- a/cmds/receive.c > +++ b/cmds/receive.c > @@ -1186,7 +1186,6 @@ static int decompress_and_write(struct > btrfs_receive *rctx, > { > int ret = 0; > char *unencoded_data; > - int sector_shift = 0; > u64 written = 0; > > unencoded_data = calloc(unencoded_len, 1); > @@ -1220,7 +1219,7 @@ static int decompress_and_write(struct > btrfs_receive *rctx, > case BTRFS_ENCODED_IO_COMPRESSION_LZO_32K: > case BTRFS_ENCODED_IO_COMPRESSION_LZO_64K: > #if COMPRESSION_LZO > - sector_shift = > + int sector_shift = > compression - > BTRFS_ENCODED_IO_COMPRESSION_LZO_4K + 12; > ret = decompress_lzo(encoded_data, encoded_len, > unencoded_data, > unencoded_len, 1U << sector_shift); > > >> + int sector_shift = >> + compression - BTRFS_ENCODED_IO_COMPRESSION_LZO_4K + 12; >> + >> + ret = decompress_lzo(encoded_data, encoded_len, >> unencoded_data, >> + unencoded_len, 1U << sector_shift); >> + if (ret) >> + goto out; >> + break; >> + } >> #else >> error("LZO compression for stream not compiled in"); >> ret = -EOPNOTSUPP; > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3] btrfs-progs: receive: fix unused variable warning without LZO 2026-09-30 4:59 ` Qu Wenruo 2026-09-30 6:17 ` liuh @ 2026-09-30 6:43 ` liuh0329 2026-09-30 7:39 ` Qu Wenruo 1 sibling, 1 reply; 7+ messages in thread From: liuh0329 @ 2026-09-30 6:43 UTC (permalink / raw) To: wqu; +Cc: linux-btrfs, liuhuan01, quwenruo.btrfs When btrfs-progs is built without LZO support, sector_shift is still declared in decompress_and_write(), while all its uses are guarded by COMPRESSION_LZO. This results in an unused variable warning. Move the sector_shift declaration to the LZO-specific code path so it is only declared when LZO support is enabled. Fixes: 345731fff32d ("btrfs-progs: receive: optional build for lzo, zstd") Signed-off-by: liuh0329 <liuhuan01@kylinos.cn> --- Changes in v3: - Drop the extra scope and move sector_shift declaration directly to its only usage as suggested by Qu Wenruo. Changes in v2: - Move sector_shift declaration to its only usage, as suggested by Qu Wenruo. - Add a local scope for sector_shift. cmds/receive.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmds/receive.c b/cmds/receive.c index 49103ea3..f592a044 100644 --- a/cmds/receive.c +++ b/cmds/receive.c @@ -1186,7 +1186,6 @@ static int decompress_and_write(struct btrfs_receive *rctx, { int ret = 0; char *unencoded_data; - int sector_shift = 0; u64 written = 0; unencoded_data = calloc(unencoded_len, 1); @@ -1220,7 +1219,7 @@ static int decompress_and_write(struct btrfs_receive *rctx, case BTRFS_ENCODED_IO_COMPRESSION_LZO_32K: case BTRFS_ENCODED_IO_COMPRESSION_LZO_64K: #if COMPRESSION_LZO - sector_shift = + int sector_shift = compression - BTRFS_ENCODED_IO_COMPRESSION_LZO_4K + 12; ret = decompress_lzo(encoded_data, encoded_len, unencoded_data, unencoded_len, 1U << sector_shift); -- 2.54.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3] btrfs-progs: receive: fix unused variable warning without LZO 2026-09-30 6:43 ` [PATCH v3] " liuh0329 @ 2026-09-30 7:39 ` Qu Wenruo 0 siblings, 0 replies; 7+ messages in thread From: Qu Wenruo @ 2026-09-30 7:39 UTC (permalink / raw) To: liuh0329; +Cc: linux-btrfs, quwenruo.btrfs 在 2026/9/30 16:13, liuh0329 写道: > When btrfs-progs is built without LZO support, sector_shift is still > declared in decompress_and_write(), while all its uses are guarded by > COMPRESSION_LZO. This results in an unused variable warning. > > Move the sector_shift declaration to the LZO-specific code path so it is > only declared when LZO support is enabled. > > Fixes: 345731fff32d ("btrfs-progs: receive: optional build for lzo, zstd") > Signed-off-by: liuh0329 <liuhuan01@kylinos.cn> Reviewed-by: Qu Wenruo <wqu@suse.com> > --- > Changes in v3: > - Drop the extra scope and move sector_shift declaration directly to its > only usage as suggested by Qu Wenruo. Next time please use more common sense, less brain dead "vibe" coding. > > Changes in v2: > - Move sector_shift declaration to its only usage, as suggested by Qu Wenruo. > - Add a local scope for sector_shift. > > cmds/receive.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/cmds/receive.c b/cmds/receive.c > index 49103ea3..f592a044 100644 > --- a/cmds/receive.c > +++ b/cmds/receive.c > @@ -1186,7 +1186,6 @@ static int decompress_and_write(struct btrfs_receive *rctx, > { > int ret = 0; > char *unencoded_data; > - int sector_shift = 0; > u64 written = 0; > > unencoded_data = calloc(unencoded_len, 1); > @@ -1220,7 +1219,7 @@ static int decompress_and_write(struct btrfs_receive *rctx, > case BTRFS_ENCODED_IO_COMPRESSION_LZO_32K: > case BTRFS_ENCODED_IO_COMPRESSION_LZO_64K: > #if COMPRESSION_LZO > - sector_shift = > + int sector_shift = > compression - BTRFS_ENCODED_IO_COMPRESSION_LZO_4K + 12; > ret = decompress_lzo(encoded_data, encoded_len, unencoded_data, > unencoded_len, 1U << sector_shift); ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-09-30 7:39 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-09-29 7:14 [PATCH] btrfs-progs: receive: fix unused variable warning without LZO liuh0329 2026-09-29 10:37 ` Qu Wenruo 2026-09-30 2:21 ` [PATCH v2] " liuh0329 2026-09-30 4:59 ` Qu Wenruo 2026-09-30 6:17 ` liuh 2026-09-30 6:43 ` [PATCH v3] " liuh0329 2026-09-30 7:39 ` Qu Wenruo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox