RE: [PATCH] bpf: bpftool: convert ‘const char *’ type into 'char *' in assignment

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

 



From: Quentin Monnet
> Sent: 28 March 2019 14:31
> 2019-03-28 10:16 UTC-0400 ~ Bo YU <tsu.yubo@xxxxxxxxx>
> > When compiling with check flag: make -C tools/bpf/bpftool/
> > gcc will warning:
> >
> > jit_disasm.c:119:29: warning: assignment discards ‘const’ qualifier from
> > pointer target type [-Wdiscarded-qualifiers]
> >   info.disassembler_options = disassembler_options;
> >
> > So convert 'const char *' type into 'char *' to fix the warning.
> >
...
> > --- a/tools/bpf/bpftool/jit_disasm.c
> > +++ b/tools/bpf/bpftool/jit_disasm.c
> > @@ -116,7 +116,7 @@ void disasm_print_insn(unsigned char *image, ssize_t
> > len, int opcodes,
> >     info.arch = bfd_get_arch(bfdf);
> >     info.mach = bfd_get_mach(bfdf);
> >     if (disassembler_options)
> > -        info.disassembler_options = disassembler_options;
> > +        info.disassembler_options = (char *)disassembler_options;
> >     info.buffer = image;
> >     info.buffer_length = len;

At some point someone may decide to build with -Wcast-const
at which point you've just generated a different error.

The (probably) correct fix is to make info.disassempler_options 'const char *'.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux