Skip to content

Commit

Permalink
tree: Wrap error() with macros
Browse files Browse the repository at this point in the history
TODO: finish

Signed-off-by: Petr Vorel <[email protected]>
  • Loading branch information
pevik committed Aug 28, 2024
1 parent 0f12e6d commit fe10922
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions iputils_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ void error(int status, int errnum, const char *format, ...)
}
#endif

/* exit without errno message */
#define EXIT_NO_PACKETS(...) error(EXIT_FAILURE, 0, __VA_ARGS__)
#define EXIT_OTHER(status, ...) error(2, 0, __VA_ARGS__)

/* exit with errno message */
#define EXIT_NO_PACKETS_ERRNO(errnum...) error(EXIT_FAILURE, errnum, __VA_ARGS__)
#define EXIT_OTHER_ERRNO(status, errnum...) error(2, errnum, __VA_ARGS__)

/* warn only */
#define WARN(...) error(0, 0, __VA_ARGS__)
#define WARN_ERRNO(errnum, ...) error(0, errnum, __VA_ARGS__)

int close_stream(FILE *stream)
{
const int flush_status = fflush(stream);
Expand Down

0 comments on commit fe10922

Please sign in to comment.