Skip to content

Commit

Permalink
tools/xenstore: Check the format printf for xprintf() and barf{,_perr…
Browse files Browse the repository at this point in the history
…or}()

Allow GCC to analyze the format printf for xprintf() and
barf{,_perror}().

Take the opportunity to define __noreturn to make the prototype for
barf{,_perror})() easier to read.

Also document why 'extern' is used for xprintf().

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Ian Jackson <iwj@xenproject.org>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
  • Loading branch information
Julien Grall committed Mar 11, 2021
1 parent 209b309 commit 1fff444
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/xenstore/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ const char *dump_state_align(FILE *fp);

#define PRINTF_ATTRIBUTE(a1, a2) __attribute__((format (printf, a1, a2)))

void barf(const char *fmt, ...) __attribute__((noreturn));
void barf_perror(const char *fmt, ...) __attribute__((noreturn));
#define __noreturn __attribute__((noreturn))

extern void (*xprintf)(const char *fmt, ...);
void barf(const char *fmt, ...) __noreturn PRINTF_ATTRIBUTE(1, 2);
void barf_perror(const char *fmt, ...) __noreturn PRINTF_ATTRIBUTE(1, 2);

/* Function pointer as xprintf() can be configured at runtime. */
extern void (*xprintf)(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);

#define eprintf(_fmt, _args...) xprintf("[ERR] %s" _fmt, __FUNCTION__, ##_args)

Expand Down

0 comments on commit 1fff444

Please sign in to comment.