All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] devmapper: Fix build error on 32bit host
@ 2023-03-01  9:23 Michael Chang
  2023-03-01 13:16 ` Daniel Kiper
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Chang @ 2023-03-01  9:23 UTC (permalink / raw)
  To: The development of GNU GRUB

The gcc build has failed for 32bit host (for eg, i386-emu and arm-emu)
due to mismatch between format specifier and data type.

../grub-core/osdep/devmapper/getroot.c: In function
'grub_util_pull_devmapper':

../grub-core/osdep/devmapper/getroot.c:265:75: error: format '%lu'
expects argument of type 'long unsigned int', but argument 2 has type
'int' [-Werror=format=]

../grub-core/osdep/devmapper/getroot.c:276:80: error: format '%lu'
expects argument of type 'long unsigned int', but argument 2 has type
'int' [-Werror=format=]

This patch fixes the problem by casting the type of calculated offset to
grub_size_t and use platform PRIuGRUB_SIZE as format specifier.

Signed-off-by: Michael Chang <mchang@suse.com>
---
 grub-core/osdep/devmapper/getroot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c
index cc3f7daff..a9e8784f2 100644
--- a/grub-core/osdep/devmapper/getroot.c
+++ b/grub-core/osdep/devmapper/getroot.c
@@ -262,7 +262,7 @@ grub_util_pull_devmapper (const char *os_dev)
                                  params);
               cipher = grub_strndup (c, seek_head - c);
               if (cipher == NULL)
-                grub_util_error (_("could not strndup cipher of length `%lu'"), seek_head - c);
+                grub_util_error (_("could not strndup cipher of length `%" PRIuGRUB_SIZE "'"), (grub_size_t)(seek_head - c));
               remaining -= seek_head - c + 1;
               c = seek_head + 1;
 
@@ -273,7 +273,7 @@ grub_util_pull_devmapper (const char *os_dev)
                                  params);
               cipher_mode = grub_strndup (c, seek_head - c);
               if (cipher_mode == NULL)
-                grub_util_error (_("could not strndup cipher_mode of length `%lu'"), seek_head - c);
+                grub_util_error (_("could not strndup cipher_mode of length `%" PRIuGRUB_SIZE "'"), (grub_size_t)(seek_head - c));
 
               remaining -= seek_head - c + 1;
               c = seek_head + 1;
-- 
2.39.2



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

* Re: [PATCH] devmapper: Fix build error on 32bit host
  2023-03-01  9:23 [PATCH] devmapper: Fix build error on 32bit host Michael Chang
@ 2023-03-01 13:16 ` Daniel Kiper
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2023-03-01 13:16 UTC (permalink / raw)
  To: Michael Chang; +Cc: grub-devel

On Wed, Mar 01, 2023 at 05:23:08PM +0800, Michael Chang via Grub-devel wrote:
> The gcc build has failed for 32bit host (for eg, i386-emu and arm-emu)
> due to mismatch between format specifier and data type.
>
> ../grub-core/osdep/devmapper/getroot.c: In function
> 'grub_util_pull_devmapper':
>
> ../grub-core/osdep/devmapper/getroot.c:265:75: error: format '%lu'
> expects argument of type 'long unsigned int', but argument 2 has type
> 'int' [-Werror=format=]
>
> ../grub-core/osdep/devmapper/getroot.c:276:80: error: format '%lu'
> expects argument of type 'long unsigned int', but argument 2 has type
> 'int' [-Werror=format=]
>
> This patch fixes the problem by casting the type of calculated offset to
> grub_size_t and use platform PRIuGRUB_SIZE as format specifier.
>
> Signed-off-by: Michael Chang <mchang@suse.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


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

end of thread, other threads:[~2023-03-01 13:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-01  9:23 [PATCH] devmapper: Fix build error on 32bit host Michael Chang
2023-03-01 13:16 ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.