From 770354d7e6cd471daed426fcf04bf7246e7cb18b Mon Sep 17 00:00:00 2001 From: Dima Zavin Date: Tue, 5 May 2009 18:33:07 -0700 Subject: [PATCH] init: Fix segfault when log_write() was missing an arg to format. Also, flag log_write() as a printf-like beast to gcc. Signed-off-by: Dima Zavin --- init/init.c | 2 +- init/init.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/init/init.c b/init/init.c index b8b4f4037..a748ec36b 100644 --- a/init/init.c +++ b/init/init.c @@ -421,7 +421,7 @@ static void msg_stop(const char *name) if (svc) { service_stop(svc); } else { - ERROR("no such service '%s'\n"); + ERROR("no such service '%s'\n", name); } } diff --git a/init/init.h b/init/init.h index b68686930..c9363daf4 100644 --- a/init/init.h +++ b/init/init.h @@ -29,7 +29,8 @@ void *read_file(const char *fn, unsigned *_sz); void log_init(void); void log_set_level(int level); void log_close(void); -void log_write(int level, const char *fmt, ...); +void log_write(int level, const char *fmt, ...) + __attribute__ ((format(printf, 2, 3))); #define ERROR(x...) log_write(3, "<3>init: " x) #define NOTICE(x...) log_write(5, "<5>init: " x)