diff options
author | John Kacur <jkacur@redhat.com> | 2012-03-22 01:19:40 +0100 |
---|---|---|
committer | John Kacur <jkacur@redhat.com> | 2012-03-23 02:15:19 +0100 |
commit | 6f2665250edf49194a4b383d0897050ee57c760d (patch) | |
tree | f9085706c0006161d4905f5fc6531a5a609c95c8 | |
parent | fb7ef61416b6b191a5186a715e51792847de883c (diff) | |
download | cyclictest-6f2665250edf49194a4b383d0897050ee57c760d.tar.gz |
Move info, warn, and fatal functions to error.[ch]
Move warning, error and fatal function to the error files.
This is a first step in cleaning up rt-tests.
Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r-- | src/cyclictest/rt_numa.h | 1 | ||||
-rw-r--r-- | src/include/error.h | 3 | ||||
-rw-r--r-- | src/include/rt-utils.h | 5 | ||||
-rw-r--r-- | src/lib/error.c | 31 | ||||
-rw-r--r-- | src/lib/rt-utils.c | 32 | ||||
-rw-r--r-- | src/pmqtest/pmqtest.c | 1 | ||||
-rw-r--r-- | src/ptsematest/ptsematest.c | 1 | ||||
-rw-r--r-- | src/svsematest/svsematest.c | 1 |
8 files changed, 39 insertions, 36 deletions
diff --git a/src/cyclictest/rt_numa.h b/src/cyclictest/rt_numa.h index 2b91615..4ae10ee 100644 --- a/src/cyclictest/rt_numa.h +++ b/src/cyclictest/rt_numa.h @@ -15,6 +15,7 @@ #define _RT_NUMA_H #include "rt-utils.h" +#include "error.h" static int numa = 0; diff --git a/src/include/error.h b/src/include/error.h index 512b3a6..1e33f6c 100644 --- a/src/include/error.h +++ b/src/include/error.h @@ -10,6 +10,9 @@ void err_exit(int err, char *fmt, ...); void err_msg(char *fmt, ...); void err_msg_n(int err, char *fmt, ...); void err_quit(char *fmt, ...); +void info(char *fmt, ...); +void warn(char *fmt, ...); +void fatal(char *fmt, ...); void err_doit(int err, const char *fmt, va_list ap); #endif /* __ERROR_H */ diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h index 316b09c..4a7d01f 100644 --- a/src/include/rt-utils.h +++ b/src/include/rt-utils.h @@ -1,7 +1,6 @@ #ifndef __RT_UTILS_H #define __RT_UTILS_H - #define _STR(x) #x #define STR(x) _STR(x) #define MAX_PATH 256 @@ -18,8 +17,4 @@ int event_disable(char *event); int event_enable_all(void); int event_disable_all(void); -void warn(char *fmt, ...); -void fatal(char *fmt, ...); -void info(char *fmt, ...); - #endif /* __RT_UTILS.H */ diff --git a/src/lib/error.c b/src/lib/error.c index e9fe58f..1b5de5d 100644 --- a/src/lib/error.c +++ b/src/lib/error.c @@ -46,6 +46,37 @@ void err_quit(char *fmt, ...) exit(1); } +void info(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + fputs("INFO: ", stderr); + err_doit(0, fmt, ap); + va_end(ap); +} + +void warn(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + fputs("WARN: ", stderr); + err_doit(0, fmt, ap); + va_end(ap); +} + +void fatal(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + fputs("FATAL: ", stderr); + err_doit(0, fmt, ap); + va_end(ap); + exit(EXIT_FAILURE); +} + void err_doit(int err, const char *fmt, va_list ap) { if (err) diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c index ec71dbd..f4da4b3 100644 --- a/src/lib/rt-utils.c +++ b/src/lib/rt-utils.c @@ -17,6 +17,7 @@ #include <sys/stat.h> #include <unistd.h> #include "rt-utils.h" +#include "error.h" static char debugfileprefix[MAX_PATH]; @@ -272,34 +273,3 @@ int check_privs(void) return sched_setscheduler(0, policy, &old_param); } -void info(char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - fputs("INFO: ", stderr); - vfprintf(stderr, fmt, ap); - va_end(ap); -} - -void warn(char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - fputs("WARNING: ", stderr); - vfprintf(stderr, fmt, ap); - va_end(ap); -} - -void fatal(char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - fputs("FATAL: ", stderr); - vfprintf(stderr, fmt, ap); - va_end(ap); - exit(EXIT_FAILURE); -} - diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c index 2ac6c55..b811d95 100644 --- a/src/pmqtest/pmqtest.c +++ b/src/pmqtest/pmqtest.c @@ -37,6 +37,7 @@ #include <mqueue.h> #include "rt-utils.h" #include "rt-get_cpu.h" +#include "error.h" #include <pthread.h> diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c index 14c3f81..92f0ab5 100644 --- a/src/ptsematest/ptsematest.c +++ b/src/ptsematest/ptsematest.c @@ -36,6 +36,7 @@ #include <utmpx.h> #include "rt-utils.h" #include "rt-get_cpu.h" +#include "error.h" #include <pthread.h> diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c index d4ee1c4..89473a5 100644 --- a/src/svsematest/svsematest.c +++ b/src/svsematest/svsematest.c @@ -42,6 +42,7 @@ #include <sys/mman.h> #include "rt-utils.h" #include "rt-get_cpu.h" +#include "error.h" #define gettid() syscall(__NR_gettid) |