Skip to contentSkip to conversation

Fix an uninitialized variable.

PATCH In review Peter Jones 2 participants 2 messages Jan 27, 2020 – Jan 29, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix an uninitialized variable.

gcc says:

grub-core/fs/squash4.c: In function ‘direct_read’:
grub-core/fs/squash4.c:868:10: error: ‘err’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
868 | if (err)
| ^
cc1: all warnings being treated as errors

This patch initializes it to 0.

---
 grub-core/fs/squash4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/fs/squash4.c +1 -1
index 95d5c1e1ff4..0583aeab8e8 100644
@@ -746,7 +746,7 @@ direct_read (struct grub_squash_data *data,
 	     struct grub_squash_cache_inode *ino,
 	     grub_off_t off, char *buf, grub_size_t len)
 {
-  grub_err_t err;
+  grub_err_t err = 0;
   grub_off_t cumulated_uncompressed_size = 0;
   grub_uint64_t a = 0;
   grub_size_t i;
Signature · 1 line
2.24.1
#1 lore raw
Quoted 9 lines · Peter Jones

gcc says:

grub-core/fs/squash4.c: In function ‘direct_read’:
grub-core/fs/squash4.c:868:10: error: ‘err’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
868 | if (err)
| ^
cc1: all warnings being treated as errors

Quoted 3 lines

This patch initializes it to 0.

Pushed but with small change...

Quoted 9 lines
---
 grub-core/fs/squash4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/fs/squash4.c +0 -0
index 95d5c1e1ff4..0583aeab8e8 100644

grub-core/fs/squash4.c direct_read (struct grub_squash_data *data, · line 749

Quoted 5 lines
grub-core/fs/squash4.c +1 -1
@@ -746,7 +746,7 @@ direct_read (struct grub_squash_data *data,
 	     struct grub_squash_cache_inode *ino,
 	     grub_off_t off, char *buf, grub_size_t len)
 {
-  grub_err_t err;
+  grub_err_t err = 0;

s/0/GRUB_ERR_NONE/

Thanks,

Daniel