xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] xl: Fix CHK_ERRNO
Date: Tue, 10 Dec 2013 15:16:39 +0000	[thread overview]
Message-ID: <52A73057.8050802@citrix.com> (raw)
In-Reply-To: <21159.12194.684886.874446@mariner.uk.xensource.com>

On 10/12/13 15:13, Ian Jackson wrote:
> Andrew Cooper writes ("Re: [PATCH] xl: Fix CHK_ERRNO"):
>> On 09/12/13 14:55, Ian Campbell wrote:
>>> [Andrew Cooper:]
>>>> Split the macro into two; CHK_ERRNO() for calls which return -1
>>>> and set errno on error, and CHK_POSERRNO() for calls which return
>>>> a positive errno.
> This is a bit confusing.  Why do you write "a _positive_ errno"
> (emph. mine) ?  errno values are always positive.  In the libxl LOG*
> macros we call a style where an errno value is passed explicitly
> "ERRNOVAL".
>
> You propose:
>
>     #define CHK_POSERRNO( call ) ({                                         \
>             int chk_errno = (call);                                         \
>             if (chk_errno > 0) {                                            \
>                 fprintf(stderr,"xl: fatal error: %s:%d: %s: %s\n",          \
>                         __FILE__,__LINE__, strerror(chk_errno), #call);     \
>                 exit(-ERROR_FAIL);                                          \
>             }                                                               \
>         })
>
> This is what I would call CHK_ERRNOVAL.  (But I think it should
> abort() if the returned value is negative, not treat it as success!)
>
>>> Would be better to call POSERRNO LIBXLERR or something, rather than
>>> accidentally imply that it was related to "errno" somehow, I think.
> I think there should be a CHK_LIBXL or something too, but that's not
> needed right now because all the CHK_* call sites are either
> (return -1, set errno) or (return errno value).
>
> I think the former macro would better be called CHK_SYSCALL, because
> it's the system call return convention.  CHK_ERRNO would do.
>
> Ian.

In v2 of the patch, CHK_POSERRNO was renamed to CHK_LIBXLERR, but I can
certainly extend it to abort() if negative.

I can also rename CHK_ERRNO to CHK_SYSCALL which does make it somewhat
more descriptive.

~Andrew

  reply	other threads:[~2013-12-10 15:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-09 14:48 [PATCH] xl: Fix CHK_ERRNO Andrew Cooper
2013-12-09 14:55 ` Ian Campbell
2013-12-09 14:56   ` Andrew Cooper
2013-12-10 15:13     ` Ian Jackson
2013-12-10 15:16       ` Andrew Cooper [this message]
2013-12-10 15:21         ` Ian Jackson
2013-12-10 15:25           ` Ian Campbell

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=52A73057.8050802@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=xen-devel@lists.xen.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).