This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [committed] Use structure to bubble up information about unterminated strings from c_strlen
- From: Christophe Lyon <christophe dot lyon at linaro dot org>
- To: Jeff Law <law at redhat dot com>
- Cc: gcc Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 1 Oct 2018 23:46:02 +0200
- Subject: Re: [committed] Use structure to bubble up information about unterminated strings from c_strlen
- References: <5bac7adf-fad3-bd4a-985c-7f9d30bcebbd@redhat.com>
On Sat, 29 Sep 2018 at 18:06, Jeff Law <law@redhat.com> wrote:
>
>
> This patch changes the NONSTR argument to c_strlen to instead be a
> little data structure c_strlen can populate with nuggets of information
> about the string.
>
> There's clearly a need for the decl related to the non-string argument.
> I see an immediate need for the length of a non-terminated string
> (c_strlen returns NULL for non-terminated strings). I also see a need
> for the offset within the non-terminated strong as well.
>
> We only populate the structure when c_strlen encounters a non-terminated
> string. One could argue we should always fill in the members. Right
> now I think filling it in for unterminated cases makes the most sense,
> but I could be convinced otherwise.
>
> I won't be surprised if subsequent warnings from Martin need additional
> information about the string. The idea here is we can add more elements
> to the structure without continually adding arguments to c_strlen.
>
> Bootstrapped in isolation as well as with Martin's patches for strnlen
> and sprintf checking. Installing on the trunk.
>
Hi Jeff,
+ /* If TYPE is asking for a maximum, then use any
+ length (including the length of an unterminated
+ string) for VAL. */
+ if (type == 2)
+ val = data.len;
It seems this part is dead-code, since the case type==2 is handled in
the "then" part of the "if" (this code is in the "else" part).
Since you added a comment, I suspect you explicitly tested it, though?
Christophe
> Jeff