qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nikita Ivanov <nivanov@cloudlinux.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Christian Schoenebeck" <qemu_oss@crudebyte.com>,
	qemu-devel@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Greg Kurz" <groug@kaod.org>, "Jason Wang" <jasowang@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"Konstantin Kostiuk" <kkostiuk@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH] error handling: Use TFR() macro where applicable
Date: Mon, 10 Oct 2022 11:33:53 +0300	[thread overview]
Message-ID: <CAAJ4Ao8wyZAE-r-ad9DwF-CrqNqTukZTYL5PYBX4_uUTrC3R7Q@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA-jRHEGyW-oA1rSXDuYa81x2SNt+vqrvUPtgK6Wr93sJg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2340 bytes --]

Hi! Thanks for your notes. I'll try to send updated patches by the end of
the day.

On Fri, Oct 7, 2022 at 6:32 PM Peter Maydell <peter.maydell@linaro.org>
wrote:

> I think this patch is doing things in the wrong order. Instead of
> converting code to use the old macro that we don't like and then
> updating it again in patch 2 to use the new macro, we should
> first introduce the new macro, and then after that we can update
> code that's currently not using a macro at all to use the new one.
> This makes code review easier because we don't have to look at a
> change to this code which is then going to be rewritten anyway.


Sounds smooth. I'll refactor patches accordingly.


> >      if (ret < 0) {
> >          ret = -errno;
>
>
> > @@ -1472,8 +1472,8 @@ static ssize_t
> handle_aiocb_rw_vector(RawPosixAIOData *aiocb)
> >  {
> >      ssize_t len;
> >
> > -    TFR(
> > -        len = (aiocb->aio_type & QEMU_AIO_WRITE) ?
> > +    len = TEMP_FAILURE_RETRY(
> > +        (aiocb->aio_type & QEMU_AIO_WRITE) ?
> >              qemu_pwritev(aiocb->aio_fildes,
> >                             aiocb->io.iov,
> >                             aiocb->io.niov,
>
> I'm not sure why you've put the TEMP_FAILURE_RETRY on the outside here
> rather than just on the individual function calls.
>

The original code contained both branches in one while loop, so I was
afraid that
value `aiocb->aio_type & QEMU_AIO_WRITE` would change somehow during the
loop.
If you'll say that this is impossible, I'll adjust the code as you propose.

> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> > index b1c161c035..6e244f15fa 100644
> > --- a/include/qemu/osdep.h
> > +++ b/include/qemu/osdep.h
> > @@ -243,7 +243,13 @@ void QEMU_ERROR("code path is reachable")
> >  #define ESHUTDOWN 4099
> >  #endif
> >
> > -#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
> > +#define TEMP_FAILURE_RETRY(expr) \
>
> We can't call the macro this, because the glibc system headers already
> may define a macro of that name, so the compiler will complain if they're
> both defined at the same time, and depending on header ordering it might
> not be clear which version you're getting.
>

Sorry, my fault. I will rename it to "RETRY_ON_EINTR" as it was proposed
earlier in this thread.
-- 
Best Regards,
*Nikita Ivanov* | C developer

[-- Attachment #2: Type: text/html, Size: 3491 bytes --]

  reply	other threads:[~2022-10-10  8:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04  7:25 [PATCH] error handling: Use TFR() macro where applicable Nikita Ivanov
2022-08-05 11:10 ` Christian Schoenebeck
2022-08-05 11:18   ` Marc-André Lureau
2022-08-05 11:40     ` Peter Maydell
2022-08-08  7:19       ` Nikita Ivanov
2022-08-08  8:05         ` Markus Armbruster
2022-08-08  8:27           ` Nikita Ivanov
2022-08-08 12:52           ` Christian Schoenebeck
2022-08-08 13:11             ` Christian Schoenebeck
2022-08-08 14:22               ` Markus Armbruster
2022-08-08 18:00                 ` Nikita Ivanov
2022-08-08 18:03                   ` Nikita Ivanov
2022-08-17 14:06                     ` Nikita Ivanov
2022-08-17 14:16                       ` Peter Maydell
2022-08-17 14:49                         ` Nikita Ivanov
2022-08-17 15:55                           ` Peter Maydell
2022-08-18 14:07                             ` Christian Schoenebeck
2022-08-18 14:11                               ` Peter Maydell
2022-10-07 11:44                                 ` Nikita Ivanov
2022-10-07 14:50                                   ` Christian Schoenebeck
2022-10-07 15:32                                   ` Peter Maydell
2022-10-10  8:33                                     ` Nikita Ivanov [this message]
2022-10-10  9:56                                       ` 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=CAAJ4Ao8wyZAE-r-ad9DwF-CrqNqTukZTYL5PYBX4_uUTrC3R7Q@mail.gmail.com \
    --to=nivanov@cloudlinux.com \
    --cc=armbru@redhat.com \
    --cc=groug@kaod.org \
    --cc=jasowang@redhat.com \
    --cc=kkostiuk@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.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 NNTP newsgroup(s).