Attention is currently required from: Angel Pons, Arthur Heymans.
Maximilian Brune has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/68160 )
Change subject: util/cbfstool: Add a new mechanism to provide a memory mapped ......................................................................
Patch Set 1:
(1 comment)
File util/cbfstool/cbfstool.c:
https://review.coreboot.org/c/coreboot/+/68160/comment/27a0bb90_ef092f81 PS1, Line 335: static int decode_mmap_arg(char *optarg) : { : if (optarg == NULL) : return 1; : : unsigned long flash_base; : unsigned long mmap_base; : unsigned long region_size; : char *suffix = NULL; : char *substring = strtok(optarg, ":"); : if (substring) : flash_base = strtol(substring, &suffix, 0); : if (!substring || (suffix && *suffix)) { : ERROR("Invalid flash base address '%s'.\n", : optarg); : return 1; : } : substring = strtok(NULL, ":"); : if (substring) : mmap_base = strtol(substring, &suffix, 0); : if (!substring || (suffix && *suffix)) { : ERROR("Invalid mmap base address '%s'.\n", : optarg); : return 1; : } : substring = strtok(NULL, ":"); : if (substring) : region_size = strtol(substring, &suffix, 0); : if (!substring || (suffix && *suffix)) { : ERROR("Invalid flash region size '%s'.\n", : optarg); : return 1; : } : : if (strtok(NULL, ":") != NULL) { : ERROR("Invalid argument, too many substrings '%s'.\n", : optarg); : : return 1; : } : : add_mmap_window(flash_base, mmap_base, region_size); : return 0;
It doesn't look *too* bad, but please try introducing a helper function that gets called three times […]
In this case it doesn't seem like a helper function would actually reduce any code here. But I would recommend to remove the "if (substring)" and just place the "flash_base = ..." after the error checking