Message ID | 20230524084224.558-1-avri.altman@wdc.com |
---|---|
State | New |
Headers | show |
Series | mmc-utils: Assert MMC_IOC_MULTI_CMD in compile time | expand |
> > { > > #ifndef MMC_IOC_MULTI_CMD > > - fprintf(stderr, "mmc-utils has been compiled without > MMC_IOC_MULTI_CMD" > > - " support, needed by FFU.\n"); > > - exit(1); > > +#error "mmc-utils needs MMC_IOC_MULTI_CMD support" > > May I suggest that we have one place in the file to deal with this. > Perhaps put it in the top of the file, immediately after #include" > section. > > Moreover, the MMC_IOC_MULTI_CMD support was added in v4.4, so adding > that information as part of the error message would be good too I think. Done. Thanks, Avri > > > #else > > int dev_fd, img_fd; > > int sect_done = 0, retry = 3, ret = -EINVAL; > > Kind regards > Uffe
diff --git a/mmc_cmds.c b/mmc_cmds.c index df66986..a4819ab 100644 --- a/mmc_cmds.c +++ b/mmc_cmds.c @@ -2113,9 +2113,7 @@ static int do_rpmb_op(int fd, unsigned int out_cnt) { #ifndef MMC_IOC_MULTI_CMD - fprintf(stderr, "mmc-utils has been compiled without MMC_IOC_MULTI_CMD" - " support, needed by RPMB operation.\n"); - exit(1); +#error "mmc-utils needs MMC_IOC_MULTI_CMD support" #else int err; u_int16_t rpmb_type; @@ -2805,9 +2803,7 @@ out: int do_ffu(int nargs, char **argv) { #ifndef MMC_IOC_MULTI_CMD - fprintf(stderr, "mmc-utils has been compiled without MMC_IOC_MULTI_CMD" - " support, needed by FFU.\n"); - exit(1); +#error "mmc-utils needs MMC_IOC_MULTI_CMD support" #else int dev_fd, img_fd; int sect_done = 0, retry = 3, ret = -EINVAL;
Notify of mult-ioctl violation during preprocessing instead of bailing out in runtime. Would not even allow bogus copies of mmc-utils binaries wondering about out there. Signed-off-by: Avri Altman <avri.altman@wdc.com> --- mmc_cmds.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)