Skip to contentSkip to conversation

block: partitions: efi: Typecast sizeof(gpt_header)

PATCH In review Fabio Estevam 3 participants 3 messages Feb 20, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: partitions: efi: Typecast sizeof(gpt_header)

From: Fabio Estevam <[email protected]>

Since commit ef25bb0fa6e2 (block/partitions/efi.c: ensure that the GPT header is at least the size of the structure.) , when building for a 32-bit architecture, such as ARM, the following build warning is seen:

block/partitions/efi.c:324:3: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int' [-Wformat]

Typecast sizeof(gpt_header) to (unsigned long) to avoid such warning on 32-bit systems.

Cc Peter Jones <[email protected]>
Cc Matt Fleming <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Andrew Morton <[email protected]>
---
 block/partitions/efi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/partitions/efi.c +1 -1
index a7475e7..62e05cf 100644
@@ -323,7 +323,7 @@ static int is_gpt_valid(struct parsed_partitions *state, u64 lba,
 	if (le32_to_cpu((*gpt)->header_size) < sizeof(gpt_header)) {
 		pr_debug("GUID Partition Table Header size is too small: %u < %lu\n",
 			le32_to_cpu((*gpt)->header_size),
-			sizeof(gpt_header));
+			(unsigned long)sizeof(gpt_header));
 		goto fail;
 	}
 
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 7 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Since commit ef25bb0fa6e2 (block/partitions/efi.c: ensure that the GPT header is at least the size of the structure.) , when building for a 32-bit architecture, such as ARM, the following build warning is seen:

block/partitions/efi.c:324:3: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int' [-Wformat]

Hi Fabio,

I sent and updated version of ef25bb0fa6e2 this morning to fix this issue. Thanks for the patch, though. Andrew, if you'd like you can just use this instead of replacing my patch with the new one.

Quoted 30 lines

Typecast sizeof(gpt_header) to (unsigned long) to avoid such warning on 32-bit systems.

Cc Peter Jones <[email protected]>
Cc Matt Fleming <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Andrew Morton <[email protected]>
---
 block/partitions/efi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/partitions/efi.c +1 -1
index a7475e7..62e05cf 100644
@@ -323,7 +323,7 @@ static int is_gpt_valid(struct parsed_partitions *state, u64 lba,
 	if (le32_to_cpu((*gpt)->header_size) < sizeof(gpt_header)) {
 		pr_debug("GUID Partition Table Header size is too small: %u < %lu\n",
 			le32_to_cpu((*gpt)->header_size),
-			sizeof(gpt_header));
+			(unsigned long)sizeof(gpt_header));
 		goto fail;
 	}
 
Signature · 1 line
1.7.9.5
Signature · 1 line
        Peter
#2 lore raw
Quoted 7 lines · On Wed, 20 Feb 2013 11:27:48 -0500 Peter Jones <[email protected]> wrote:
Quoted 6 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Since commit ef25bb0fa6e2 (block/partitions/efi.c: ensure that the GPT header is at least the size of the structure.) , when building for a 32-bit architecture, such as ARM, the following build warning is seen:

Quoted 7 lines
Quoted 1 line

block/partitions/efi.c:324:3: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int' [-Wformat]

Hi Fabio,

I sent and updated version of ef25bb0fa6e2 this morning to fix this issue. Thanks for the patch, though. Andrew, if you'd like you can just use this instead of replacing my patch with the new one.

You're both wrong ;) Print a size_t with %z:

block/partitions/efi.c renamed from block/partitions/efi.c~ensure-that-the-gpt-header-is-at-least-the-size-of-the-structure-fix +1 -1
@@ -321,7 +321,7 @@ static int is_gpt_valid(struct parsed_pa
 
 	/* Check the GUID Partition Table header size is too small */
 	if (le32_to_cpu((*gpt)->header_size) < sizeof(gpt_header)) {
-		pr_debug("GUID Partition Table Header size is too small: %u < %lu\n",
+		pr_debug("GUID Partition Table Header size is too small: %u < %zu\n",
 			le32_to_cpu((*gpt)->header_size),
 			sizeof(gpt_header));
 		goto fail;

_