qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] decodetree: Do not remove output_file from /dev
Date: Fri, 26 May 2023 14:49:48 -0700	[thread overview]
Message-ID: <036fdefe-7094-770b-5a83-02c8d44f688e@linaro.org> (raw)
In-Reply-To: <CAFEAcA_PWUB-+qRLMzqtwPsegSzs73N5sFryj4GGcBU9b0OWrw@mail.gmail.com>

On 5/26/23 12:52, Peter Maydell wrote:
> On Fri, 26 May 2023 at 18:40, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> Nor report any PermissionError on remove.
>>
>> Previously we were testing with "> /dev/null", but that's not easy
>> to do with meson test(), so we want to use '-o /dev/null' instead.
>> That works fine for all of the existing tests, where all errors are
>> diagnosed before opening the output file.  However, PMM's named field
>> patch set diagnoses cycle errors during output.  This is fair, but
>> we need to be more careful with the remove.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   scripts/decodetree.py | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/scripts/decodetree.py b/scripts/decodetree.py
>> index e4ef0a03cc..a9a0cd0fa3 100644
>> --- a/scripts/decodetree.py
>> +++ b/scripts/decodetree.py
>> @@ -71,7 +71,12 @@ def error_with_file(file, lineno, *args):
>>
>>       if output_file and output_fd:
>>           output_fd.close()
>> -        os.remove(output_file)
>> +        # Do not try to remove e.g. -o /dev/null
>> +        if not output_file.startswith("/dev"):
>> +            try:
>> +                os.remove(output_file)
>> +            except PermissionError:
>> +                pass
> 
> Maybe rather than hardcoding /dev, only try to delete the file
> if it's a normal file, i.e.:
>         if os.path.isfile(output_file):
>             os.remove(output_file)

Good idea.


r~



      reply	other threads:[~2023-05-26 21:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26 17:40 [PATCH] decodetree: Do not remove output_file from /dev Richard Henderson
2023-05-26 19:52 ` Peter Maydell
2023-05-26 21:49   ` Richard Henderson [this message]

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=036fdefe-7094-770b-5a83-02c8d44f688e@linaro.org \
    --to=richard.henderson@linaro.org \
    --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).