summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-06-19 14:09:57 +0000
committerLennart Poettering <lennart@poettering.net>2005-06-19 14:09:57 +0000
commit60a978410f8c8e13ee130619cf5b0bb912d5d601 (patch)
tree17a18c02befe37afd5f7116dea88f08a87ab427b
parent6153c625e2ad104a784253ec136fa7a3b16f4a69 (diff)
* add gcc printf warning support
git-svn-id: file:///home/lennart/svn/public/libdaemon/trunk@85 153bfa13-eec0-0310-be40-b0cb6a0e1b4b
-rw-r--r--libdaemon/dlog.h9
-rw-r--r--libdaemon/dpid.c4
2 files changed, 11 insertions, 2 deletions
diff --git a/libdaemon/dlog.h b/libdaemon/dlog.h
index 55b641a..8e42c86 100644
--- a/libdaemon/dlog.h
+++ b/libdaemon/dlog.h
@@ -50,11 +50,18 @@ extern enum daemon_log_flags daemon_log_use;
* to set this to a sensible value or generate your own. */
extern char* daemon_log_ident;
+#ifdef __GNUC__
+/** A macro for making use of GCCs printf compilation warnings */
+#define DAEMON_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
+#else
+#define DAEMON_GCC_PRINTF_ATTR(a,b)
+#endif
+
/** Log a message using printf format strings using the specified syslog priority
* @param prio The syslog priority (PRIO_xxx constants)
* @param t,... The text message to log
*/
-void daemon_log(int prio, const char* t, ...);
+void daemon_log(int prio, const char* t, ...) DAEMON_GCC_PRINTF_ATTR(2,3);
/** Return a sensible syslog identification for daemon_log_ident
* generated from argv[0]. This will return a pointer to the file name
diff --git a/libdaemon/dpid.c b/libdaemon/dpid.c
index 7c90297..678826c 100644
--- a/libdaemon/dpid.c
+++ b/libdaemon/dpid.c
@@ -147,8 +147,10 @@ int daemon_pid_file_kill_wait(int s, int m) {
int r;
struct timeval tv = { 0, 100000 };
- if (time(NULL) > t)
+ if (time(NULL) > t) {
+ errno = ETIME;
return -1;
+ }
if ((r = kill(pid, 0)) < 0 && errno != ESRCH)
return -1;