Re: [PATCH 2/3] media: drxj: get rid of uneeded casts

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

 



On Tue, Aug 7, 2018 at 5:26 AM Mauro Carvalho Chehab
<mchehab+samsung@xxxxxxxxxx> wrote:
>
> Instead of doing casts, use %zd to print sizes, in order to make
> smatch happier:
>         drivers/media/dvb-frontends/drx39xyj/drxj.c:11814 drx_ctrl_u_code() warn: argument 4 to %u specifier is cast from pointer
>         drivers/media/dvb-frontends/drx39xyj/drxj.c:11845 drx_ctrl_u_code() warn: argument 3 to %u specifier is cast from pointer
>         drivers/media/dvb-frontends/drx39xyj/drxj.c:11869 drx_ctrl_u_code() warn: argument 3 to %u specifier is cast from pointer
>         drivers/media/dvb-frontends/drx39xyj/drxj.c:11878 drx_ctrl_u_code() warn: argument 3 to %u specifier is cast from pointer
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@xxxxxxxxxx>
> ---
>  drivers/media/dvb-frontends/drx39xyj/drxj.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
> index 2948d12d7c14..9628d4067fe1 100644
> --- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
> +++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
> @@ -11810,8 +11810,8 @@ static int drx_ctrl_u_code(struct drx_demod_instance *demod,
>                 block_hdr.CRC = be16_to_cpu(*(__be16 *)(mc_data));
>                 mc_data += sizeof(u16);
>
> -               pr_debug("%u: addr %u, size %u, flags 0x%04x, CRC 0x%04x\n",
> -                       (unsigned)(mc_data - mc_data_init), block_hdr.addr,
> +               pr_debug("%zd: addr %u, size %u, flags 0x%04x, CRC 0x%04x\n",
> +                       (mc_data - mc_data_init), block_hdr.addr,
>                          block_hdr.size, block_hdr.flags, block_hdr.CRC);
>
>                 /* Check block header on:
> @@ -11841,8 +11841,8 @@ static int drx_ctrl_u_code(struct drx_demod_instance *demod,
>                                                         mc_block_nr_bytes,
>                                                         mc_data, 0x0000)) {
>                                 rc = -EIO;
> -                               pr_err("error writing firmware at pos %u\n",
> -                                      (unsigned)(mc_data - mc_data_init));
> +                               pr_err("error writing firmware at pos %zd\n",
> +                                      mc_data - mc_data_init);
>                                 goto release;
>                         }
>                         break;
> @@ -11865,8 +11865,8 @@ static int drx_ctrl_u_code(struct drx_demod_instance *demod,
>                                                     (u16)bytes_to_comp,
>                                                     (u8 *)mc_data_buffer,
>                                                     0x0000)) {
> -                                       pr_err("error reading firmware at pos %u\n",
> -                                              (unsigned)(mc_data - mc_data_init));
> +                                       pr_err("error reading firmware at pos %zd\n",
> +                                              mc_data - mc_data_init);
>                                         return -EIO;
>                                 }
>
> @@ -11874,8 +11874,8 @@ static int drx_ctrl_u_code(struct drx_demod_instance *demod,
>                                                 bytes_to_comp);
>
>                                 if (result) {
> -                                       pr_err("error verifying firmware at pos %u\n",
> -                                              (unsigned)(mc_data - mc_data_init));
> +                                       pr_err("error verifying firmware at pos %zd\n",
> +                                              mc_data - mc_data_init);
>                                         return -EIO;
>                                 }
>
> --
> 2.17.1
>

>From Documentation/printk-formats.txt, it looks like %zd is for
ssize_t, which is what I would expect for pointer subtracting (well
maybe intptr_t, but ssize_t should be word-size-independent).

Reviewed-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>

-- 
Thanks,
~Nick Desaulniers



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux