linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs: suppress false positive last_block warning
@ 2020-05-28  8:48 Gao Xiang
  2020-05-28  9:25 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Gao Xiang @ 2020-05-28  8:48 UTC (permalink / raw)
  To: linux-erofs, Chao Yu; +Cc: Andrew Morton, linux-kernel

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 <akpm@linux-foundation.org>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
 fs/erofs/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index fc3a8d8064f8..2812645b361e 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -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);
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] erofs: suppress false positive last_block warning
  2020-05-28  8:48 [PATCH] erofs: suppress false positive last_block warning Gao Xiang
@ 2020-05-28  9:25 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2020-05-28  9:25 UTC (permalink / raw)
  To: Gao Xiang, linux-erofs, Chao Yu; +Cc: Andrew Morton, linux-kernel

On 2020/5/28 16:48, Gao Xiang wrote:
> 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 <akpm@linux-foundation.org>
> Signed-off-by: Gao Xiang <hsiangkao@redhat.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-28  9:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28  8:48 [PATCH] erofs: suppress false positive last_block warning Gao Xiang
2020-05-28  9:25 ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).