qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Markus Armbruster <armbru@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>
Cc: "Damien Hedde" <damien.hedde@greensocs.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	qemu-devel@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH v2] util/qemu-option: Document the get_opt_value() function
Date: Tue, 7 Jul 2020 07:48:11 +0200	[thread overview]
Message-ID: <ba9d8dc5-e654-99a7-1481-c5174e366540@redhat.com> (raw)
In-Reply-To: <87r1tnanuq.fsf@dusky.pond.sub.org>

On 07/07/2020 07.35, Markus Armbruster wrote:
> Richard Henderson <richard.henderson@linaro.org> writes:
> 
>> On 6/29/20 12:08 AM, Philippe Mathieu-Daudé wrote:
>>> Coverity noticed commit 950c4e6c94 introduced a dereference before
>>> null check in get_opt_value (CID1391003):
>>>
>>>   In get_opt_value: All paths that lead to this null pointer
>>>   comparison already dereference the pointer earlier (CWE-476)
>>>
>>> We fixed this in commit 6e3ad3f0e31, but relaxed the check in commit
>>> 0c2f6e7ee99 because "No callers of get_opt_value() pass in a NULL
>>> for the 'value' parameter".
>>>
>>> Since this function is publicly exposed, it risks new users to do
>>> the same error again. Avoid that documenting the 'value' argument
>>> must not be NULL.
>>
>> I think we should also add some use of __attribute__((nonnull(...))) to enforce
>> this within the compiler.
>>
>> I recently did this without a qemu/compiler.h QEMU_FOO wrapper within
>> target/arm.  But the nonnull option has optional arguments, so it might be
>> difficult to wrap in macros.
> 
> Do we support building with a compuler that lacks this attribute?

It seems to be available in GCC 4.0 already:

https://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html

... so the answer to your question is certainly "no". All supported
compilers should have this attribute.

 Thomas




  reply	other threads:[~2020-07-07  5:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-29  7:08 [PATCH v2] util/qemu-option: Document the get_opt_value() function Philippe Mathieu-Daudé
2020-06-29  9:03 ` Daniel P. Berrangé
2020-07-04 16:46 ` Philippe Mathieu-Daudé
2020-07-06 16:58 ` Laurent Vivier
2020-07-07  1:14 ` Richard Henderson
2020-07-07  2:14   ` Philippe Mathieu-Daudé
2020-07-07  8:38     ` Daniel P. Berrangé
2020-07-07  5:35   ` Markus Armbruster
2020-07-07  5:48     ` Thomas Huth [this message]
2020-07-07 12:04       ` Markus Armbruster
2020-07-07  5:48 ` Markus Armbruster
2020-07-07  6:11   ` Philippe Mathieu-Daudé
2020-07-07 12:03     ` Markus Armbruster

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=ba9d8dc5-e654-99a7-1481-c5174e366540@redhat.com \
    --to=thuth@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=damien.hedde@greensocs.com \
    --cc=kwolf@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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 NNTP newsgroup(s).