public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Joel Sherrill <joel.sherrill@oarcorp.com>
To: "noloader@gmail.com" <noloader@gmail.com>,
	"newlib@sourceware.org" <newlib@sourceware.org>
Subject: Re: Use of initialized variable in strtod.c
Date: Wed, 15 Mar 2017 20:03:00 -0000	[thread overview]
Message-ID: <b99c41d9-d4c6-e69a-927f-ebee60867fd0@oarcorp.com> (raw)
In-Reply-To: <ee71b32c-1f8f-986c-b04e-ea1c0d97e1bd@oarcorp.com>



On 3/15/2017 2:54 PM, Joel Sherrill wrote:
>
>
> On 3/15/2017 2:31 PM, Jeffrey Walton wrote:
>>> Does Coverity have a way in which in the code it can be marked as OK?  (I'd
>>> expect some '#pragma CoverityIgnore(bits)' or the like ought to be
>>> available.)
>>
>> Yes. You have to provide a modeling file. Also see the Coverity Scan
>> FAQ entry "what is a model" at https://scan.coverity.com/faq.
>
> A model is for odd cases like where you have your
> own memory allocators or synchronization primitives.
>
> I think this is a case for what they call annotations.
> I have never written one of these but I think we would
> have to add a comment something like this ahead of the
> call:
>
> /* coverity[uninit_use_in_call] */

Adding this does result in silencing Coverity on this issue.
It doesn't change the fact that the uninitialized bits
variable is used on the RHS of ULtod() though. :(

> I will try adding that notation but we clearly need
> some guidelines as a project.
>
>> Other projects use them, like Python. See, for example,
>> https://docs.python.org/devguide/coverity.html.
>>
>>> I agree with trying to get rid of the message, but it is worth
>>> bloat to do it?  (It will add instructions to either initialize bits to 0 or
>>> add the else.)
>>
>> If I am parsing things correctly, it seems like the bloat is going the
>> other way: if the code is not needed, then remove it. It will avoid
>> findings like these, and speed up the compile.
>>
>>> I would rather mark something in the code as a false
>>> positive than add code because the tool is not smart enough to know--so we
>>> might differ in philosophy there.
>>
>> Perhaps a better strategy would be to initialize all variables, and
>> then allow the optimizer to remove the unneeded writes. It will ensure
>> a program is in a good state, and avoid findings like these.
>
> I'm a middle of the road guy. I add initialization in cases
> where there are paths where it is used and doesn't otherwise
> get set. I wouldn't automatically initialize everything.
>
> In this case, "bits" is actually used on the RHS multiple
> times in ULtod() so it bothers me that it has an undefined
> value. That means the output of ULtod() is undefined in
> this case.
>
>> Another strategy is to do nothing. In this case, the same findings
>> will waste multiple developer's time, and generate additional mailing
>> list messages.
>
> Agreed.
>
>> I like dark and silent cockpits, so I don't want tools generating
>> findings, and I don't want mailing list messages. I would squash it
>> once and for all and avoid all future problems. But that's just me,
>> and I understand the Newlib project may have a different outlook on
>> things.
>
> +1
>
> There are still 60 others issues. We should do our best to squash
> them permanently. IMO marking them with Coverity specific annotation
> just means that another static analyzer may find the same issue
> in the future. The annotation won't help.
>
>> Jeff
>>
> --joel
>

  reply	other threads:[~2017-03-15 20:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-15 18:16 Joel Sherrill
2017-03-15 18:34 ` Craig Howland
2017-03-15 18:38   ` Joel Sherrill
2017-03-15 18:56     ` Craig Howland
2017-03-15 19:31       ` Jeffrey Walton
2017-03-15 19:54         ` Joel Sherrill
2017-03-15 20:03           ` Joel Sherrill [this message]
2017-03-15 22:37             ` Joel Sherrill
2017-03-15 22:47               ` Craig Howland
2017-03-16  8:32       ` Corinna Vinschen

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=b99c41d9-d4c6-e69a-927f-ebee60867fd0@oarcorp.com \
    --to=joel.sherrill@oarcorp.com \
    --cc=newlib@sourceware.org \
    --cc=noloader@gmail.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).