Skip to contentSkip to conversation

erofs: suppress false positive last_block warning

PATCH In review Gao Xiang 2 participants 2 messages May 28, 2020 EROFS file system

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs: suppress false positive last_block warning

As Andrew mentioned, some rare specific gcc versions could report last_block uninitialized warning. Actually last_block doesn't need to be uninitialized first from its implementation due to bio == NULL condition. After a bio is allocated, last_block will be assigned then.

The detailed analysis is in this thread [1]. So let's silence those confusing gccs simply.

[1] https://lore.kernel.org/r/20200421072839.GA13867@hsiangkao-HP-ZHAN-66-Pro-G1

Cc Andrew Morton <[email protected]>
---
 fs/erofs/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/erofs/data.c +2 -2
index fc3a8d8064f8..2812645b361e 100644
@@ -265,7 +265,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
  */
 static int erofs_raw_access_readpage(struct file *file, struct page *page)
 {
-	erofs_off_t last_block;
+	erofs_off_t uninitialized_var(last_block);
 	struct bio *bio;
 
 	trace_erofs_readpage(page, true);
@@ -285,7 +285,7 @@ static int erofs_raw_access_readpages(struct file *filp,
 				      struct list_head *pages,
 				      unsigned int nr_pages)
 {
-	erofs_off_t last_block;
+	erofs_off_t uninitialized_var(last_block);
 	struct bio *bio = NULL;
 	gfp_t gfp = readahead_gfp_mask(mapping);
 	struct page *page = list_last_entry(pages, struct page, lru);
Signature · 1 line
2.18.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Gao Xiang

As Andrew mentioned, some rare specific gcc versions could report last_block uninitialized warning. Actually last_block doesn't need to be uninitialized first from its implementation due to bio == NULL condition. After a bio is allocated, last_block will be assigned then.

Quoted 7 lines

The detailed analysis is in this thread [1]. So let's silence those confusing gccs simply.

[1] https://lore.kernel.org/r/20200421072839.GA13867@hsiangkao-HP-ZHAN-66-Pro-G1

Cc Andrew Morton <[email protected]>

Thanks,