[bug report] cmd: mbr: Allow 4 MBR partitions without need for extended
Nam Cao
namcao at linutronix.de
Mon Jan 29 16:27:01 CET 2024
On Mon, 29 Jan 2024 18:18:03 +0300 Dan Carpenter wrote:
> Hello Alexander Gendin,
>
> The patch 04291ee0aba6: "cmd: mbr: Allow 4 MBR partitions without
> need for extended" from Oct 9, 2023, leads to the following Smatch
> static checker warning:
>
> test/cmd/mbr.c:243 mbr_test_run()
> warn: sizeof(NUMBER)?
>
> test/cmd/mbr.c
> 233 ulong mbr_wa, ebr_wa, ra, ebr_blk, mbr_parts_max;
> 234 struct udevice *dev;
> 235 ofnode root, node;
> 236
> 237 /* Enable the mmc6 node for this test */
> 238 root = oftree_root(oftree_default());
> 239 node = ofnode_find_subnode(root, "mmc6");
> 240 ut_assert(ofnode_valid(node));
> 241 ut_assertok(lists_bind_fdt(gd->dm_root, node, &dev, NULL, false));
> 242
> --> 243 mbr_parts_max = sizeof('\0') + 2 +
> ^^^
> You probably wanted this to a readable way to explain that we are
> leaving space for the NUL char, however this size is 4 not 1. (I guess
> this is from type promotion?)
Quick google search told me:
"Perhaps surprisingly, character constants in C are of type int, so
sizeof('a') is sizeof(int) (though this is another area where C++
differs)" [1].
Quite interesting, TIL.
Best regards,
Nam
[1] https://c-faq.com/charstring/sizeofchar.html
More information about the U-Boot
mailing list