BPF Archive on lore.kernel.org
 help / color / Atom feed
From: Quentin Monnet <quentin.monnet@netronome.com>
To: David Laight <David.Laight@ACULAB.COM>,
	"ast@kernel.org" <ast@kernel.org>,
	"daniel@iogearbox.net" <daniel@iogearbox.net>,
	"kafai@fb.com" <kafai@fb.com>,
	"songliubraving@fb.com" <songliubraving@fb.com>,
	"yhs@fb.com" <yhs@fb.com>,
	"jakub.kicinski@netronome.com" <jakub.kicinski@netronome.com>,
	"df@google.com" <df@google.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] bpf: bpftool: convert ‘const char *’ type into 'char *' in assignment
Date: Thu, 28 Mar 2019 15:58:13 +0000
Message-ID: <4c015f97-b5f0-68a0-2a6b-9333fe1bcb62@netronome.com> (raw)
In-Reply-To: <ebf3f6b747cb4400b8357e361b1f522a@AcuMS.aculab.com>

2019-03-28 15:08 UTC+0000 ~ David Laight <David.Laight@ACULAB.COM>
> From: Quentin Monnet
>> Sent: 28 March 2019 14:31
>> 2019-03-28 10:16 UTC-0400 ~ Bo YU <tsu.yubo@gmail.com>
>>> 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
> 

Which is what this binutils commit I cited does :)

Quentin

  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-28 14:16 Bo YU
2019-03-28 14:30 ` Quentin Monnet
2019-03-28 14:38   ` Bo YU
2019-03-28 15:08   ` David Laight
2019-03-28 15:58     ` Quentin Monnet [this message]
2019-03-28 14:36 ` Mukesh Ojha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4c015f97-b5f0-68a0-2a6b-9333fe1bcb62@netronome.com \
    --to=quentin.monnet@netronome.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=df@google.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=kafai@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

BPF Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/bpf/0 bpf/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 bpf bpf/ https://lore.kernel.org/bpf \
		bpf@vger.kernel.org
	public-inbox-index bpf

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.bpf


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git