[bug report] cmd: mbr: Allow 4 MBR partitions without need for extended
Dan Carpenter
dan.carpenter at linaro.org
Mon Jan 29 16:18:03 CET 2024
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?)
244 strlen(mbr_parts_header) +
245 strlen(mbr_parts_p1) +
246 strlen(mbr_parts_p2) +
247 strlen(mbr_parts_p3) +
248 max(strlen(mbr_parts_p4), strlen(mbr_parts_p5)) +
249 strlen(mbr_parts_tail);
250 ut_assertf(sizeof(mbr_parts_buf) >= mbr_parts_max, "Buffer avail: %ld; buffer req: %ld\n",
251 sizeof(mbr_parts_buf), mbr_parts_max);
252
regards,
dan carpenter
More information about the U-Boot
mailing list