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

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


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 6 Apr 2023 12:00:38 +0100
  • 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=2xNSNKUP7UWFvHKNJukQfcArgYn3YiCjUe8bsow8ens=; b=OGjC0bWBb+6lF1MCSGZalYbQXc9yKq3TeSsYdK1KFeMkFiB8F0RLz7S1PAuo8eegAfvSAdYhbF6RSuogiRdjOJopRzxi+jKNxcu84bvYzB4jV2R6MllPL0ld9m3vPckmJeqwCXba8NuCyA+leol3JeEDu2q53mcOoa1ewhywd+Gqo5A2lFkc/+Uqt5LlsEOS2aNbgzx4ws2HjPwQgaZHzPGZ8EL039jFEjpP/ezjXw9oqHLkTESpiftfo8P9ja53PMlbTAozEOekg6E5pWl8YqXB2n0m5QGGrbp3z6j09Camt7LVi1gEXNU7ReY8e/nh0oHXZZib0IxwmZ0OMIanGA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aM9cyZ+1c6w089f298g0+DD8RyVvyvnLcmRb6lNec9hy7OGsbGDTU4r1pXVKx6jLFfharGl06WBt44Q+kXm/WZYrO3onCH2MubAh+BflPbe4nUH9qIwGLmU2XEx0ViXETqg/Tmu8GUm6sTap6eBhEae+LDPXJntoHvZP5x+3noBExAmFK8By9E5oQ9LPIoySTnuT62vyTspDUvZzGi9+7R6NNSFOtI7RQ90zSIzcD0kphXDrB2k9pR57Q8zV+ozLr8xBhcmAZJMwvBU17F2tspc3fr4edYLajkaxPEScDgzvfG0V3Y6gwAeCCFL10piMa1ykXLY71qmWjTx7jsGtOw==
  • 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 11:00:56 +0000
  • Ironport-data: A9a23:qZix3KDgzAsPuhVW/w3iw5YqxClBgxIJ4kV8jS/XYbTApD50hmcFx mNKCmCPPPjZNGqnL41zPYvgo01SuZOAn9BhQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbyRFu8pvlDs15K6p4G9A4ARnDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw+PReBjl+9 NAiChMTZzCxpsyTy5ikc7w57igjBJGD0II3nFhFlGmcIdN4BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTI9exuuza7IA9ZidABNPL8fNCQSNoTtUGfv m/cpEzyAw0ANczZwj2Amp6prraXwX+mCNJMRdVU8NZMqmPL5lE1VSFLdmmRmueVsUGbA+pmf hl8Fi0G6PJaGFaQZsnwWVi0rWCJujYYWsFMCKsq5QeV0K3W7g2FQG8eQVZpa9sgrsY6AyMr0 lyhmMngDjhi9raSTBqgGqy8qDqzPW0ZKDEEbCpdFQ8duYC7/sc0kw7FSctlHOitlNrpFDrsw jeM6i8jm7EUis1N3KK+lbzavw+RSlHyZlZdzm3qsqiNt2uVuKbNi1SU1GXm
  • Ironport-hdrordr: A9a23:gzQPWq88LBiHJJZZ7a9uk+EKdb1zdoMgy1knxilNoENuH/Bwxv rFoB1E73TJYVcqKRcdcLW7VJVoLkmskaKdjbNhX4tKPzOW21dATrsSlLcKqgeIc0KRltK1vZ 0QC5SWY+eAamSS4/yKhTVQJ+xQu+VvvZrY9tv2/jNId0VHeqtg5wB2BkKyFVB3fhBPAd4cGI CH7sRKijK8cTBPB/7Lc0UtbqzmnZnmhZjmaRkJC1oO7xSPtyqh7PrfHwKD1hkTfjtTyfMJ8H TDkSb++qK/2svLuCP05iv21dB7idHhwtxMCIiljdUUECzljkKSaIFoS9S5zU4ISLXE0jcXue iJhy1lE9V46nvXcG3wiwDqwRPc3DEn7GKn4UOEgFP4yPaJDg4SOo5kv8Z0YxHZ400vsJVXy6 RQxV+UsJJREFfpgDn93d7VTBtn/3DE6kbKqdRjwkC3bLFuIYO57LZvin+9Ka1wax4SPbpXWN WHD6nnlYlrmB2hHjzkV1JUsaCRt0QIb2q7q3c5y7aoOhht7QFEJhgjtbwidzE7heYAd6U=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06/04/2023 11:54 am, Roger Pau Monné wrote:
> 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.

Yeah, anything in err.h ought to be fine.

>
>> 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.

I'd be hesitant to drop it, considering how much shell parsing there is
of these tools.

But ultimately it's up to Konrad/Ross.

~Andrew



 


Rackspace

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