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

Re: [PATCH] livepatch-tools: remove usage of error.h


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 6 Apr 2023 12:54:09 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EyMfEoLHM3v5KuwRZuXhJRCyB5szuGQEJtrTdAsqC3U=; b=KQaTi60ZmaEH28TooI+J0pzkXFgw7i/SxrqQ0ACRxpVWlf8YPyYDmc/f6+NLtB5EWZVptzAZvStb21jGlLXIaCDHVpbKEmc6smK79Wdu2NabxGSLIPuuFW80ORduR7DDt1XNdz9IB72pereHlE3p1G0xTWZ4BODhf8or4UG7LgKNxMoNWnaVA/MvSsl0u5Elp1G5iiQbOgZLvvp/0ihAcwoSczB4sRqy9ZtLGUeCusZEQITjb4V+/8vplKDJcbww5WNm/pO4JHI2b1I2GpC2LKJIK5KdQVpOCLe6ZomG8/O5FgUKm14w9Zkca8PnrWhcHZsAp2BOoIqFSm0+bavGxw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nMzOjBpvtoyIEGeguEMooEmr//5NpK3Fr4JcucJ6gUDN3xVfVVntM2UkpXPqW/hWtKvws88vpYWEI5Cau/LbsqAHBzSxoS4HKrNPIxAXG6N5qRs1nVWHl8KsYrilkef+4jq921ZwEWf8Equlc4XqMJanVPEqA/e4JaYOxvz9H1u9viE31sTcaUp8aUiwAubHoiBsP0doNQI0n9kmJUIh74Zo5OOv/yRZParxVMu5xv0s4S1+AM+DdvWMSAaBUgXE0n8vbAlRYtARhf3waGlOTpbDeZRqg3wLl/lBV5tlklRXQUan+HfFQ0PJ0LkPIOdplXFPYuBCDIFB+EBsZgavBw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • Delivery-date: Thu, 06 Apr 2023 10:54:52 +0000
  • Ironport-data: A9a23:/tfCuapO27wDsfOlmQ95dtii73BeBmIBZBIvgKrLsJaIsI4StFCzt garIBnTM/uMY2D0c9hxadjjoRsCvcPRyodrSQE4/ik8HilBopuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpA1c/Ek/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKm06WNwUmAWP6gR5weCzydNVfrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXAG0DXBS7hLmX+oiqE8JhtOM4LZC1YIxK7xmMzRmBZRonabbqZvyToPV+jHI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3jeiraYSFEjCJbZw9ckKwv GXJ8n6/GhgHHNee1SCE4jSngeqncSbTAdpOSeLlp6Mx6LGV7kwMUQUqdHu+m+CgyRW/acldC hJP/zV7+MDe82TuFLERRSaQsHOC+xIRRddUO+k78x2WjLrZ5R6DAWoJRSIHb8Yp3Oc1Qjow3 1PPgNLtBhRoqrSeTX/b/bCRxQ5eIgAQJG4GICUCHQ0M5oC6pJlp10yfCNF+DKSyk9v5Xynqx CyHpzQ/gLNVitMX06K8/hbMhDfESoX1czPZLz7/BgqNhj6Vrqb8D2B0wTA3Ncp9Ebs=
  • Ironport-hdrordr: A9a23:xJ9JzapBcIjOKmXmsKZA85oaV5oCeYIsimQD101hICG9JPbo7/ xG+85rsSMc6QxhPU3J+7i7UpVoJEmwyXcb2+Us1NuZMzUO21HYTr2Kj7GD/9S6IVyGygc178 4JGJSWbuefMbEQt7eY3ODXKbcdKHbsytHSuQ9zpU0dKj2DystbnmFENjo=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Apr 06, 2023 at 10:36:37AM +0100, Andrew Cooper wrote:
> On 06/04/2023 10:18 am, Roger Pau Monne wrote:
> > It's a GNU libc specific header which prevents building on musl for
> > example.  Instead open code an equivalent replacement for the usage
> > of ERROR() and DIFF_FATAL() macros.
> >
> > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> > ---
> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> > Cc: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
> > ---
> >  common.h             | 10 ++++++----
> >  create-diff-object.c |  1 -
> >  lookup.c             |  7 +++++--
> >  prelink.c            |  1 -
> >  4 files changed, 11 insertions(+), 8 deletions(-)
> >
> > diff --git a/common.h b/common.h
> > index 9a9da79..ec2ea33 100644
> > --- a/common.h
> > +++ b/common.h
> > @@ -1,18 +1,20 @@
> >  #ifndef _COMMON_H_
> >  #define _COMMON_H_
> >  
> > -#include <error.h>
> > -
> >  extern char *childobj;
> >  
> >  #define ERROR(format, ...) \
> > -   error(1, 0, "ERROR: %s: %s: %d: " format, childobj, __FUNCTION__, 
> > __LINE__, ##__VA_ARGS__)
> > +({ \
> > +   fflush(stdout); \
> > +   fprintf(stderr, "ERROR: %s: %s: %d: " format "\n", childobj, 
> > __FUNCTION__, __LINE__, ##__VA_ARGS__); \
> > +   exit(1); \
> > +})
> >  
> >  #define DIFF_FATAL(format, ...) \
> >  ({ \
> >     fflush(stdout); \
> >     fprintf(stderr, "ERROR: %s: " format "\n", childobj, ##__VA_ARGS__); \
> > -   error(2, 0, "unreconcilable difference"); \
> > +   exit(2); \
> >  })
> 
> Looking at the usage, can't we just use err() instead?

Hm, err() will unconditionaly use errno, which doesn't seem wanted
here, as in both cases errnum is passed as 0, effectively preventing
printing it.

I could use errx(), as that doesn't append an error message, I think
that's available on musl.

Let me know if you agree with that substitution.

> Also, I suspect you don't intend to delete the error message in
> DIFF_FATAL() ?

I didn't think it was that helpful, but I could keep it.

Thanks, Roger.



 


Rackspace

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