qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "QEMU Developers" <qemu-devel@nongnu.org>,
	"Fam Zheng" <famz@redhat.com>,
	"patches@linaro.org" <patches@linaro.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [Qemu-devel] [PATCH 1/2] scripts/run-coverity-scan: Script to run Coverity Scan build
Date: Tue, 13 Nov 2018 13:51:33 -0600	[thread overview]
Message-ID: <dcbe49b4-4e16-b21c-ef5b-93cd55ae54c7@redhat.com> (raw)
In-Reply-To: <CAFEAcA-Fw2niH-XevrqTacouNcM=+xbT3qAqyyuQi+8oK_Xkig@mail.gmail.com>

On 11/13/18 1:21 PM, Peter Maydell wrote:

>>
>> set -e...
>>
>>> +check_upload_permissions() {
>>
>>
>> ...and shell functions do NOT intuitively do what you would think. It's
>> almost always better to use explicit error checking than to rely on set -e
>> as a crutch, because then you don't get surprises.
> 
> I think we had this conversation with last year's version
> of this script too :-)  As you say, the use of functions
> makes it maybe better to use explicit error checking -- but
> is there a standard syntax for that that doesn't make
> basic
>   foo
>   bar
>   baz
> "do these things in order" code look weird and require special care?
> At least with set -e you do get error checking, whereas scripts without
> it tend to just plough on regardless (look at configure, which doesn't
> use set -e but doesn't have explicit checking either).

I've seen both:

foo &&
bar &&
baz

and

foo || fail
bar || fail
baz || fail

for some variation of a 'fail' function.  But yeah, once you start 
having to worry about checking everything yourself (or realizing which 
lines don't need checking), you find out how much of a crutch 'set -e' 
tries to be, and then wonder how it ever worked (for the number of cases 
where 'set -e' does not actually catch failure, and cannot be re-enabled 
in smaller scopes).

>>> +TOOLBIN="$(cd "$COVERITY_TOOL_BASE" && echo
>>> $(pwd)/coverity_tool/cov-analysis-*/bin)"
>>
>>
>> If $CDPATH is set and $COVERITY_TOOL_BASE does not contain /, this could
>> result in garbage being prepended to TOOLBIN as output from the 'cd'. Also,
>> $PWD is nicer than $(pwd); but are you sure the glob in cov-analysis-* won't
>> select too many files?
> 
> The glob is not great, but it is necessary to make the script
> robust over new versions of the tools, which put the version
> number in the cov-analysis-whatever directory name. If
> we do ever get more than one file then the "test -x" below
> will fail, and we'll be able to investigate and fix up the script.

Yeah, I think you're okay on that front.

> 
> CDPATH sounds like a horrific misfeature designed for breaking
> scripts, so I'm not very interested in trying to work around it.
> We don't seem to worry about this in configure either.
> (I suppose we could just unset it at the start of the script.)

Autoconf 'configure' scripts do just that (unset CDPATH up front).  If 
someone ever complains that it actually broke for them, we'll make the 
fix; until then, I can live with the risk.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

  reply	other threads:[~2018-11-13 19:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-13 18:46 [Qemu-devel] [PATCH 0/2] Automation for running Coverity Scan builds Peter Maydell
2018-11-13 18:46 ` [Qemu-devel] [PATCH 1/2] scripts/run-coverity-scan: Script to run Coverity Scan build Peter Maydell
2018-11-13 19:06   ` Eric Blake
2018-11-13 19:21     ` Peter Maydell
2018-11-13 19:51       ` Eric Blake [this message]
2018-11-13 18:46 ` [Qemu-devel] [PATCH 2/2] scripts/coverity-scan: Add Docker support Peter Maydell
2018-11-13 19:37   ` Philippe Mathieu-Daudé
2018-11-14 11:25     ` Alex Bennée
2018-11-14 11:46       ` Philippe Mathieu-Daudé
2018-11-14 12:02     ` Paolo Bonzini
2018-11-14 14:31       ` Peter Maydell

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=dcbe49b4-4e16-b21c-ef5b-93cd55ae54c7@redhat.com \
    --to=eblake@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=famz@redhat.com \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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).