mmc-utils: Assert MMC_IOC_MULTI_CMD in compile time
PATCH v2 1/1 mmc-utils: Assert MMC_IOC_MULTI_CMD in compile time
v1 -> v2: Address Ulf's suggestions
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 <[email protected]>
--- mmc_cmds.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
mmc_cmds.c +4 -12
@@ -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)
Signature · 1 line
2.40.0
Ulf Hansson
AppliedQuoted 2 lines · Avri Altman
v1 -> v2: Address Ulf's suggestions
Next time, please put this as patch version information, below the "---".
Quoted 6 lines
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 <[email protected]>
Applied to git.kernel.org/pub/scm/utils/mmc/mmc-utils.git master, thanks!
Kind regards
Uffe
Quoted 62 lines
--- mmc_cmds.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)mmc_cmds.c +4
-13@@ -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) --2.40.0