Skip to content

Commit

Permalink
util: Add printf format GCC attribute to panic() function
Browse files Browse the repository at this point in the history
This fixes the following GCC warning:

  util.h:55:2: warning: function might be possible candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  • Loading branch information
tklauser committed Jan 13, 2017
1 parent 2ae121c commit 0028136
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion compiler.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015 Tobias Klauser <tklauser@distanz.ch>
* Copyright (C) 2015-2017 Tobias Klauser <tklauser@distanz.ch>
*
* This file is part of llmnrd.
*
Expand Down Expand Up @@ -28,6 +28,10 @@
# ifndef __unused
# define __unused __attribute__((unused))
# endif
# ifndef __check_format_printf
# define __check_format_printf(__fmt, __args) \
__attribute__ ((format (printf, (__fmt), (__args))))
# endif
# ifndef offsetof
# define offsetof(a, b) __builtin_offsetof(a, b)
# endif
Expand Down
4 changes: 3 additions & 1 deletion util.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2015 Tobias Klauser <tklauser@distanz.ch>
* Copyright (C) 2014-2017 Tobias Klauser <tklauser@distanz.ch>
* Copyright (C) 2009-2012 Daniel Borkmann
*
* This file is part of llmnrd.
Expand Down Expand Up @@ -47,6 +47,8 @@
(void) (&_max1 == &_max2); \
_max1 > _max2 ? _max1 : _max2; })

static inline void panic(const char *fmt, ...) __check_format_printf(1, 2);

static inline void __noreturn panic(const char *fmt, ...)
{
va_list vl;
Expand Down

0 comments on commit 0028136

Please sign in to comment.