mirror of
https://github.com/dynup/kpatch
synced 2025-04-25 12:37:56 +00:00
kpatch-build: add exit status enum
Convert magic exit status values into a common enum for clarity. Suggested-by: Artem Savkov <asavkov@redhat.com> Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
This commit is contained in:
parent
9f7c76b9c1
commit
1f4551a49e
@ -52,11 +52,12 @@
|
|||||||
#include "kpatch-patch.h"
|
#include "kpatch-patch.h"
|
||||||
#include "kpatch-elf.h"
|
#include "kpatch-elf.h"
|
||||||
#include "kpatch-intermediate.h"
|
#include "kpatch-intermediate.h"
|
||||||
|
#include "kpatch.h"
|
||||||
|
|
||||||
#define DIFF_FATAL(format, ...) \
|
#define DIFF_FATAL(format, ...) \
|
||||||
({ \
|
({ \
|
||||||
fprintf(stderr, "ERROR: %s: " format "\n", childobj, ##__VA_ARGS__); \
|
fprintf(stderr, "ERROR: %s: " format "\n", childobj, ##__VA_ARGS__); \
|
||||||
error(2, 0, "unreconcilable difference"); \
|
error(EXIT_STATUS_DIFF_FATAL, 0, "unreconcilable difference"); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#ifdef __powerpc__
|
#ifdef __powerpc__
|
||||||
@ -3084,7 +3085,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (!hint) {
|
if (!hint) {
|
||||||
log_normal("WARNING: FILE symbol not found in base. Stripped object file or assembly source?\n");
|
log_normal("WARNING: FILE symbol not found in base. Stripped object file or assembly source?\n");
|
||||||
return 3; /* NO_CHANGE */
|
return EXIT_STATUS_NO_CHANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create symbol lookup table */
|
/* create symbol lookup table */
|
||||||
@ -3132,7 +3133,7 @@ int main(int argc, char *argv[])
|
|||||||
log_debug("no changed functions were found, but callbacks exist\n");
|
log_debug("no changed functions were found, but callbacks exist\n");
|
||||||
else {
|
else {
|
||||||
log_debug("no changed functions were found\n");
|
log_debug("no changed functions were found\n");
|
||||||
return 3; /* 1 is ERROR, 2 is DIFF_FATAL */
|
return EXIT_STATUS_NO_CHANGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3192,5 +3193,5 @@ int main(int argc, char *argv[])
|
|||||||
kpatch_elf_teardown(kelf_out);
|
kpatch_elf_teardown(kelf_out);
|
||||||
kpatch_elf_free(kelf_out);
|
kpatch_elf_free(kelf_out);
|
||||||
|
|
||||||
return 0;
|
return EXIT_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
11
kpatch-build/kpatch.h
Normal file
11
kpatch-build/kpatch.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef _KPATCH_H_
|
||||||
|
#define _KPATCH_H_
|
||||||
|
|
||||||
|
enum exit_status {
|
||||||
|
EXIT_STATUS_SUCCESS = 0,
|
||||||
|
EXIT_STATUS_ERROR = 1,
|
||||||
|
EXIT_STATUS_DIFF_FATAL = 2,
|
||||||
|
EXIT_STATUS_NO_CHANGE = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _KPATCH_H_ */
|
@ -2,13 +2,14 @@
|
|||||||
#define _LOG_H_
|
#define _LOG_H_
|
||||||
|
|
||||||
#include <error.h>
|
#include <error.h>
|
||||||
|
#include "kpatch.h"
|
||||||
|
|
||||||
/* Files that include log.h must define loglevel and childobj */
|
/* Files that include log.h must define loglevel and childobj */
|
||||||
extern enum loglevel loglevel;
|
extern enum loglevel loglevel;
|
||||||
extern char *childobj;
|
extern char *childobj;
|
||||||
|
|
||||||
#define ERROR(format, ...) \
|
#define ERROR(format, ...) \
|
||||||
error(1, 0, "ERROR: %s: %s: %d: " format, childobj, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
error(EXIT_STATUS_ERROR, 0, "ERROR: %s: %s: %d: " format, childobj, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||||
|
|
||||||
#define log_debug(format, ...) log(DEBUG, format, ##__VA_ARGS__)
|
#define log_debug(format, ...) log(DEBUG, format, ##__VA_ARGS__)
|
||||||
#define log_normal(format, ...) log(NORMAL, "%s: " format, childobj, ##__VA_ARGS__)
|
#define log_normal(format, ...) log(NORMAL, "%s: " format, childobj, ##__VA_ARGS__)
|
||||||
|
Loading…
Reference in New Issue
Block a user