[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 01/12] libxc/save: Shrink code volume where possible


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Ian Jackson <ian.jackson@xxxxxxxxxx>
  • Date: Tue, 14 Jan 2020 16:48:25 +0000
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=ian.jackson@xxxxxxxxxx; spf=Pass smtp.mailfrom=Ian.Jackson@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 14 Jan 2020 16:48:37 +0000
  • Ironport-sdr: j06LJzbD0qngWktmfxgTwqAJZRtxf0fS9lHAabpypPuGDXq+JnDtbSOXwphmKITQYaQI86XjlX kwm3GBOBbXVZEsTyF3H1weO/7z51AiPZwvImgYNIg2xJI6w9kOmAvtoyJEnQGUsv+DRG39NfWF hO+tppZW4C8nm/Duh7cSvOb6Q2mEXdoL0sVosQ61ZNmC1y7+6vygBvfUUS/X9boQiSrXuFdJif jzXg8bn2C0EHLWGt+L8amuMa6wGkL5UAwP4urghI/DDynaHWeabO5wqabKfXrPanx2uskk2Kxr dys=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Andrew Cooper writes ("[PATCH 01/12] libxc/save: Shrink code volume where 
possible"):
> A property of how the error handling (0 on success, nonzero otherwise)
> allows these calls to be chained together with the ternary operatior.

I'm quite surprised to find a suggestion like this coming from you in
particular.  I think if we are going to adopt this thing in general,
it ought to be in a CODING_STYLE somewhere.

I'm distinctly unsure about the merits of the pattern.  It does make
the code much shorter and less repetitive.  OTOH ?: is a
not-very-frequently used GNU extension and my representative sample of
programmers had to think about what this idiom meant and it wasn't
universally liked.  On the third hand, if this idiom becomes dominant
you only have to think about it once.

Maybe it would be better to have
    #define MUST(call) ({ rc = (call); if (rc) goto error; })
and write
    MUST( write_one_vcpu_basic(ctx, i) );

Or just to permit
   rc = write_one_vcpu_basic(ctx, i);    if (rc) goto error;
(ie on a single line).

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.