From 6d593efc3cd00e4debd0ffc5806246390dc66242 Mon Sep 17 00:00:00 2001 From: Avri Altman Date: Fri, 9 Jun 2023 11:34:25 +0300 Subject: [PATCH] mmc-utils: Assert MMC_IOC_MULTI_CMD in compile time Notify of mult-ioctl violation during preprocessing instead of bailing out in runtime. This prevents bogus copies of mmc-utils binaries wondering about out there. Signed-off-by: Avri Altman Link: https://lore.kernel.org/r/20230609083425.765-1-avri.altman@wdc.com Signed-off-by: Ulf Hansson --- mmc_cmds.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/mmc_cmds.c b/mmc_cmds.c index df66986..26bdc38 100644 --- a/mmc_cmds.c +++ b/mmc_cmds.c @@ -34,6 +34,10 @@ #include "mmc_cmds.h" #include "3rdparty/hmac_sha/hmac_sha2.h" +#ifndef MMC_IOC_MULTI_CMD +#error "mmc-utils needs MMC_IOC_MULTI_CMD support (added in kernel v4.4)" +#endif + #ifndef offsetof #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif @@ -2112,11 +2116,6 @@ static int do_rpmb_op(int fd, struct rpmb_frame *frame_out, 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); -#else int err; u_int16_t rpmb_type; struct mmc_ioc_multi_cmd *mioc; @@ -2196,7 +2195,6 @@ static int do_rpmb_op(int fd, out: free(mioc); return err; -#endif /* !MMC_IOC_MULTI_CMD */ } int do_rpmb_write_key(int nargs, char **argv) @@ -2804,11 +2802,6 @@ 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); -#else int dev_fd, img_fd; int sect_done = 0, retry = 3, ret = -EINVAL; unsigned int sect_size; @@ -3034,7 +3027,6 @@ out: close(img_fd); close(dev_fd); return ret; -#endif } int do_general_cmd_read(int nargs, char **argv)