grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 28/37] btrfs: fix a bad null check


From: Vladimir 'phcoder' Serbinenko
Subject: Re: [PATCH v1 28/37] btrfs: fix a bad null check
Date: Tue, 8 Oct 2024 08:09:03 +0300

LGTM 
Reviewed-by: Vladimir Serbinenko phcoder@gmail.com


Le lun. 7 oct. 2024, 21:23, Leo Sandoval <lsandova@redhat.com> a écrit :
From: Peter Jones <pjones@redhat.com>

current gcc complains:

  grub-core/fs/btrfs.c: In function ‘grub_cmd_btrfs_info’:
  grub-core/fs/btrfs.c:2745:7: error: the comparison will always evaluate as ‘true’ for the address of ‘label’ will never be NULL [-Werror=address]
   2745 |   if (data->sblock.label)
        |       ^~~~
  grub-core/fs/btrfs.c:92:8: note: ‘label’ declared here
     92 |   char label[0x100];
        |        ^~~~~
  cc1: all warnings being treated as errors

Obviously this check should be on the first data byte instead of the
symbol itself.

Signed-off-by: Peter Jones <pjones@redhat.com>
---
 grub-core/fs/btrfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index f14fe9c1b..8e2b1e9f7 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -2625,7 +2625,7 @@ grub_cmd_btrfs_info (grub_command_t cmd __attribute__ ((unused)), int argc,
       return grub_error (GRUB_ERR_BAD_ARGUMENT, "failed to open fs");
     }

-  if (data->sblock.label)
+  if (data->sblock.label[0])
     grub_printf("Label: '%s' ", data->sblock.label);
   else
     grub_printf("Label: none ");
--
2.46.2


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]