Re: [PATCH] mmc-utils: Assert MMC_IOC_MULTI_CMD in compile time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 24 May 2023 at 10:42, Avri Altman <avri.altman@xxxxxxx> wrote:
>
> 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@xxxxxxx>
> ---
>  mmc_cmds.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> 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"

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.

>  #else
>         int dev_fd, img_fd;
>         int sect_done = 0, retry = 3, ret = -EINVAL;

Kind regards
Uffe



[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux