[PATCH 3/5] staging: lustre: lustre: Remove unnecessary cast on void pointer

SIMRAN SINGHAL singhalsimran0 at gmail.com
Thu Mar 2 22:05:04 UTC 2017


On Fri, Mar 3, 2017 at 3:29 AM, Joe Perches <joe at perches.com> wrote:
> On Fri, 2017-03-03 at 03:25 +0530, SIMRAN SINGHAL wrote:
>> On Fri, Mar 3, 2017 at 3:13 AM, Joe Perches <joe at perches.com> wrote:
>> > On Fri, 2017-03-03 at 02:49 +0530, simran singhal wrote:
>> > > The following Coccinelle script was used to detect this:
>> > > @r@
>> > > expression x;
>> > > void* e;
>> > > type T;
>> > > identifier f;
>> > > @@
>> > > (
>> > >   *((T *)e)
>> > > >
>> > >
>> > >   ((T *)x)[...]
>> > > >
>> > >
>> > >   ((T*)x)->f
>> > > >
>> > >
>> > > - (T*)
>> > >   e
>> > > )
>> >
>> > NAK.
>> >
>> > Nice, but you still have to verify correctness
>> > before submitting these patches.
>> >
>> > > diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
>> >
>> > []
>> > > @@ -1034,7 +1034,7 @@ static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp,
>> > >               rc = sptlrpc_parse_flavor(val, &flvr);
>> > >               if (rc) {
>> > >                       CERROR("invalid sptlrpc flavor %s to MGS\n",
>> > > -                            (char *)val);
>> > > +                            val);
>> >
>> > Try compiling this.
>> >
>>
>> I compiled it before sending.
>
> Did you look at the warnings?
>
>   CC [M]  drivers/staging/lustre/lustre/mgc/mgc_request.o
> drivers/staging/lustre/lustre/mgc/mgc_request.c: In function ‘mgc_set_info_async’:
> drivers/staging/lustre/lustre/mgc/mgc_request.c:1036:115: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘void *’ [-Wformat=]
>     CERROR("invalid sptlrpc flavor %s to MGS\n",
>

I again compiled it and this is what I got :-

  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/bounds.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  LD      arch/x86/boot/compressed/vmlinux
  ZOFFSET arch/x86/boot/zoffset.h
  AS      arch/x86/boot/header.o
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  OBJCOPY arch/x86/boot/vmlinux.bin
  BUILD   arch/x86/boot/bzImage
Setup is 17500 bytes (padded to 17920 bytes).
System is 7128 kB
CRC 37713343
Kernel: arch/x86/boot/bzImage is ready  (#4)
  Building modules, stage 2.
  MODPOST 4541 modules

I am not getting any warning.


More information about the devel mailing list