Skip to content

Commit

Permalink
rdisc / ninfod: fix format string warning
Browse files Browse the repository at this point in the history
warning: format string is not a string literal [-Wformat-nonliteral]

The above was reported for rdisc.c lines 210 and 212, and ninfod/ninfod.c
lines 162 and 165.

Reviewed-by: Petr Vorel <[email protected]>
Signed-off-by: Sami Kerola <[email protected]>
  • Loading branch information
kerolasa committed Nov 24, 2019
1 parent 7c4049b commit 2711701
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions iputils_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
!!__builtin_types_compatible_p(__typeof__(arr), \
__typeof__(&arr[0]))])) * 0)

#ifdef __GNUC__
# define iputils_attribute_format(t, n, m) __attribute__((__format__ (t, n, m)))
#else
# define iputils_attribute_format(t, n, m)
#endif

#if defined(USE_IDN) || defined(ENABLE_NLS)
# include <locale.h>
#endif
Expand Down
3 changes: 2 additions & 1 deletion ninfod/ninfod.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ __inline__ static const char * log_level(int priority) {
}
}

void DEBUG(int pri, char *fmt, ...)
iputils_attribute_format(__printf__, 2, 3)
void DEBUG(int const pri, char const *const fmt, ...)
{
int saved_errno = errno;
va_list ap;
Expand Down
2 changes: 1 addition & 1 deletion ninfod/ninfod.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int ni_recv(struct packetcontext *p);
int ni_send(struct packetcontext *p);

/* ninfod_core.c */
extern void DEBUG(int pri, char *fmt, ...);
extern void DEBUG(int const pri, char const *const fmt, ...);

void init_core(int forced);
int pr_nodeinfo(struct packetcontext *p);
Expand Down
3 changes: 2 additions & 1 deletion rdisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ static unsigned short in_cksum(unsigned short *addr, int len);

static int logging = 0;

static void logmsg(int prio, char *fmt, ...)
iputils_attribute_format(__printf__, 2, 3)
static void logmsg(int const prio, char const *const fmt, ...)
{
va_list ap;

Expand Down

0 comments on commit 2711701

Please sign in to comment.