livepatch-tools: remove usage of error.h
PATCH v2 1/1 livepatch-tools: remove usage of error.h
It's a GNU libc specific header which prevents building on musl for example. Instead use errx() in ERROR() and DIFF_FATAL() macros.
---
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Ross Lagerwall <[email protected]>
---
Changes since v1:
- Use errx().
--- common.h | 9 ++++++--- create-diff-object.c | 1 - lookup.c | 7 +++++-- prelink.c | 1 - 4 files changed, 11 insertions(+), 7 deletions(-)
common.h +6 -3
@@ -1,18 +1,21 @@#ifndef _COMMON_H_#define _COMMON_H_ -#include <error.h> +#include <err.h> extern char *childobj;#define ERROR (format, ...) \ - error(1, 0, "ERROR: %s: %s: %d: " format, childobj, __FUNCTION__, __LINE__, ##__VA_ARGS__) +({ \ + fflush(stdout); \ + errx(1, "ERROR: %s: %s: %d: " format "\n", childobj, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +})#define DIFF_FATAL (format, ...) \ ({ \ fflush(stdout); \ fprintf(stderr, "ERROR: %s: " format "\n", childobj, ##__VA_ARGS__); \ - error(2, 0, "unreconcilable difference"); \ + errx(2, "unreconcilable difference"); \ })#define log_debug (format, ...) log(DEBUG, format, ##__VA_ARGS__)
create-diff-object.c +0 -1
@@ -45,7 +45,6 @@#include <string.h> #include <libgen.h> #include <argp.h> -#include <error.h> #include <unistd.h> #include <time.h> #include <gelf.h>
lookup.c +5 -2
@@ -28,14 +28,17 @@#include <stdlib.h> #include <stdio.h> #include <string.h> -#include <error.h> +#include <err.h> #include <gelf.h> #include <unistd.h> #include "lookup.h" #define ERROR (format, ...) \ - error(1, 0, "%s: %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__) +({ \ + fflush(stdout); \ + errx(1, "%s: %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +})struct symbol {unsigned long value;
prelink.c +0 -1
@@ -27,7 +27,6 @@#include <string.h> #include <libgen.h> #include <argp.h> -#include <error.h> #include <unistd.h> #include <gelf.h>
Signature · 1 line
2.40.0
Quoted 4 lines · Roger Pau Monne
It's a GNU libc specific header which prevents building on musl for example. Instead use
errx()inERROR()andDIFF_FATAL()macros.Signed-off-by Roger Pau Monné <[email protected]>
Quoted 38 lines
From: Roger Pau Monne <[email protected]>
Sent: Thursday, April 6, 2023 12:41 PM
To: [email protected] <[email protected]>
Cc: Roger Pau Monne <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Ross Lagerwall <[email protected]>
Subject: [PATCH v2] livepatch-tools: remove usage oferror.h
It's a GNU libc specific header which prevents building on musl for
example. Instead useerrx()inERROR()andDIFF_FATAL()macros.Signed-off-by Roger Pau Monné <[email protected]>---
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Ross Lagerwall <[email protected]>
---
Changes since v1:
- Useerrx().
---
common.h | 9 ++++++---create-diff-object.c| 1 -
lookup.c | 7 +++++-- prelink.c | 1 -4 files changed, 11 insertions(+), 7 deletions(-)common.h +0
-0@@ -1,18 +1,21 @@ #ifndef _COMMON_H_ #define _COMMON_H_common.h +1
-1-#include <error.h> +#include <err.h>
extern char *childobj;
#defineERROR(format, ...)\
-error(1, 0, "ERROR: %s: %s: %d: " format, childobj, __FUNCTION__, __LINE__, ##__VA_ARGS__)
common.h line 12
Quoted 4 lines
common.h +4
-0+({ \ + fflush(stdout); \ + errx(1, "ERROR: %s: %s: %d: " format "\n", childobj, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +})
Did you mean to add "\n" here? Wouldn't that result in a double new line?
With that removed (can be done during commit),
Quoted 46 lines · Ross Lagerwall
Quoted 38 lines
From: Roger Pau Monne <[email protected]>
Sent: Thursday, April 6, 2023 12:41 PM
To: [email protected] <[email protected]>
Cc: Roger Pau Monne <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Ross Lagerwall <[email protected]>
Subject: [PATCH v2] livepatch-tools: remove usage oferror.h
It's a GNU libc specific header which prevents building on musl for
example. Instead useerrx()inERROR()andDIFF_FATAL()macros.Signed-off-by Roger Pau Monné <[email protected]>---
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Ross Lagerwall <[email protected]>
---
Changes since v1:
- Useerrx().
---
common.h | 9 ++++++---create-diff-object.c| 1 -
lookup.c | 7 +++++-- prelink.c | 1 -4 files changed, 11 insertions(+), 7 deletions(-)common.h +0
-0@@ -1,18 +1,21 @@ #ifndef _COMMON_H_ #define _COMMON_H_common.h +1
-1-#include <error.h> +#include <err.h>
extern char *childobj;
#defineERROR(format, ...)\
-error(1, 0, "ERROR: %s: %s: %d: " format, childobj, __FUNCTION__, __LINE__, ##__VA_ARGS__)common.h line 12
Quoted 4 lines
common.h +4
-0+({ \ + fflush(stdout); \ + errx(1, "ERROR: %s: %s: %d: " format "\n", childobj, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +})Did you mean to add "\n" here? Wouldn't that result in a double new line?
Quoted 3 lines
With that removed (can be done during commit),
Reviewed-by Ross Lagerwall <[email protected]>
Thanks, please adjust at commit. This is a leftover from v1 when I wasn't using errx.
Roger.