From: David Goulet Date: Fri, 20 Jan 2012 21:43:59 +0000 (-0500) Subject: Rename lttngerr.h to error.h X-Git-Tag: v2.0-pre18~12 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=db7586006bc1a2b9057a2c108bf1e7d20fd6903f Rename lttngerr.h to error.h Also add this header in common.h. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c index b501be873..ab83c6a75 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.c +++ b/src/bin/lttng-consumerd/lttng-consumerd.c @@ -40,12 +40,12 @@ #include #include -#include +#include +#include +#include #include #include -#include #include -#include #include "lttng-consumerd.h" diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index d7fdbaec6..b5202fe6a 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -19,10 +19,9 @@ #include #include -#include -#include #include #include +#include #include "channel.h" #include "kernel.h" diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c index 7fc455438..0144f7824 100644 --- a/src/bin/lttng-sessiond/context.c +++ b/src/bin/lttng-sessiond/context.c @@ -22,8 +22,8 @@ #include #include +#include #include -#include #include "context.h" #include "kernel.h" diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index 31c0c9715..4a86c22cd 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -21,8 +21,8 @@ #include #include +#include #include -#include #include "channel.h" #include "event.h" diff --git a/src/bin/lttng-sessiond/futex.c b/src/bin/lttng-sessiond/futex.c index eda1fa313..0a8a2bb24 100644 --- a/src/bin/lttng-sessiond/futex.c +++ b/src/bin/lttng-sessiond/futex.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include "futex.h" diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 2ebd5acbd..afa5e604f 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -24,9 +24,8 @@ #include #include -#include -#include #include +#include #include "kernel.h" diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 8b512f01d..d7ed4eb0b 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -39,12 +39,11 @@ #include #include -#include -#include -#include #include -#include #include +#include +#include +#include #include "lttng-sessiond.h" #include "channel.h" diff --git a/src/bin/lttng-sessiond/session.c b/src/bin/lttng-sessiond/session.c index ba2cefaae..97fc94fe5 100644 --- a/src/bin/lttng-sessiond/session.c +++ b/src/bin/lttng-sessiond/session.c @@ -25,9 +25,8 @@ #include #include -#include -#include #include +#include #include "session.h" diff --git a/src/bin/lttng-sessiond/shm.c b/src/bin/lttng-sessiond/shm.c index 64c712e85..77c09995c 100644 --- a/src/bin/lttng-sessiond/shm.c +++ b/src/bin/lttng-sessiond/shm.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include "shm.h" diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 79e4a2f4e..7de98b03a 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -22,7 +22,6 @@ #include #include -#include #include #include diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index ed6658d7f..80644ac83 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -21,7 +21,6 @@ #include #include -#include #include #include diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index bd91b3c39..e2b32a51a 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -27,7 +27,6 @@ #include #include -#include #include #include "ust-app.h" diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index 63381cea4..26ebfac49 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -22,11 +22,10 @@ #include #include -#include #include +#include #include #include -#include #include "ust-consumer.h" diff --git a/src/bin/lttng-sessiond/utils.c b/src/bin/lttng-sessiond/utils.c index 313f4cf78..6c4ef0636 100644 --- a/src/bin/lttng-sessiond/utils.c +++ b/src/bin/lttng-sessiond/utils.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include "utils.h" diff --git a/src/bin/lttng/command.h b/src/bin/lttng/command.h index 9caa7b403..887502bf0 100644 --- a/src/bin/lttng/command.h +++ b/src/bin/lttng/command.h @@ -20,7 +20,6 @@ #define _LTTNG_CMD_H #include -#include #include #include diff --git a/src/bin/lttng/conf.c b/src/bin/lttng/conf.c index 9d2bfbb66..d326378f7 100644 --- a/src/bin/lttng/conf.c +++ b/src/bin/lttng/conf.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include "conf.h" diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index 3181d9012..2ee93253f 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include "command.h" diff --git a/src/bin/lttng/utils.c b/src/bin/lttng/utils.c index 25d463adf..e993f0f72 100644 --- a/src/bin/lttng/utils.c +++ b/src/bin/lttng/utils.c @@ -18,7 +18,7 @@ #include -#include +#include #include "conf.h" diff --git a/src/common/Makefile.am b/src/common/Makefile.am index ade89de86..e9ec3db82 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -4,7 +4,7 @@ SUBDIRS = hashtable kernel-ctl sessiond-comm kernel-consumer ust-consumer AM_CFLAGS = -fno-strict-aliasing -noinst_HEADERS = lttngerr.h lttng-kernel.h defaults.h macros.h +noinst_HEADERS = lttng-kernel.h defaults.h macros.h noinst_LTLIBRARIES = libcommon.la diff --git a/src/common/common.h b/src/common/common.h index 952a10a55..cc4a4c7a9 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -19,7 +19,7 @@ #ifndef _COMMON_H #define _COMMON_H -#include "lttngerr.h" +#include "error.h" #include "macros.h" #include "runas.h" diff --git a/src/common/compat/compat-epoll.c b/src/common/compat/compat-epoll.c index 460bc3b37..dc1a3b926 100644 --- a/src/common/compat/compat-epoll.c +++ b/src/common/compat/compat-epoll.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include "poll.h" diff --git a/src/common/compat/compat-poll.c b/src/common/compat/compat-poll.c index 7b15c737e..51bf22c86 100644 --- a/src/common/compat/compat-poll.c +++ b/src/common/compat/compat-poll.c @@ -19,8 +19,8 @@ #include #include -#include #include +#include #include "poll.h" diff --git a/src/common/consumer.c b/src/common/consumer.c index cba9e6406..b605591e4 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -30,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/src/common/error.h b/src/common/error.h new file mode 100644 index 000000000..2ce6f57c2 --- /dev/null +++ b/src/common/error.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2011 - David Goulet + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; only version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _ERROR_H +#define _ERROR_H + +#include +#include + +/* Stringify the expansion of a define */ +#define XSTR(d) STR(d) +#define STR(s) #s + +extern int opt_quiet; +extern int opt_verbose; + +#define PRINT_ERR 0x1 +#define PRINT_WARN 0x2 +#define PRINT_BUG 0x3 +#define PRINT_MSG 0x4 +#define PRINT_DBG 0x10 +#define PRINT_DBG2 0x20 +#define PRINT_DBG3 0x30 + +/* + * Macro for printing message depending on command line option and verbosity. + */ +#define __lttng_print(type, fmt, args...) \ + do { \ + if (opt_quiet == 0) { \ + if (type == PRINT_MSG) { \ + fprintf(stdout, fmt, ## args); \ + } else if (((type & PRINT_DBG) && opt_verbose == 1) || \ + ((type & (PRINT_DBG | PRINT_DBG2)) && \ + opt_verbose == 2) || \ + ((type & (PRINT_DBG | PRINT_DBG2 | PRINT_DBG3)) && \ + opt_verbose == 3)) { \ + fprintf(stderr, fmt, ## args); \ + } else if (type & (PRINT_ERR | PRINT_WARN | PRINT_BUG)) { \ + fprintf(stderr, fmt, ## args); \ + } \ + } \ + } while (0); + +#define MSG(fmt, args...) \ + __lttng_print(PRINT_MSG, fmt "\n", ## args) +#define ERR(fmt, args...) \ + __lttng_print(PRINT_ERR, "Error: " fmt "\n", ## args) +#define WARN(fmt, args...) \ + __lttng_print(PRINT_WARN, "Warning: " fmt "\n", ## args) +#define BUG(fmt, args...) \ + __lttng_print(PRINT_BUG, "BUG: " fmt "\n", ## args) + +/* Three level of debug. Use -v, -vv or -vvv for the levels */ +#define DBG(fmt, args...) __lttng_print(PRINT_DBG, "DEBUG1: " fmt \ + " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__) +#define DBG2(fmt, args...) __lttng_print(PRINT_DBG2, "DEBUG2: " fmt \ + " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__) +#define DBG3(fmt, args...) __lttng_print(PRINT_DBG3, "DEBUG3: " fmt \ + " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__) + +#define _PERROR(fmt, args...) \ + __lttng_print(PRINT_ERR, "perror " fmt "\n", ## args) + +#define PERROR(call, args...) \ + do { \ + char *buf; \ + char tmp[200]; \ + buf = strerror_r(errno, tmp, sizeof(tmp)); \ + _PERROR(call ": %s", ## args, buf); \ + } while(0); + +#endif /* _ERROR_H */ diff --git a/src/common/lttngerr.h b/src/common/lttngerr.h deleted file mode 100644 index b14f23218..000000000 --- a/src/common/lttngerr.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2011 - David Goulet - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; only version 2 - * of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _LTTNGERR_H -#define _LTTNGERR_H - -#include -#include - -/* Stringify the expansion of a define */ -#define XSTR(d) STR(d) -#define STR(s) #s - -extern int opt_quiet; -extern int opt_verbose; - -#define PRINT_ERR 0x1 -#define PRINT_WARN 0x2 -#define PRINT_BUG 0x3 -#define PRINT_MSG 0x4 -#define PRINT_DBG 0x10 -#define PRINT_DBG2 0x20 -#define PRINT_DBG3 0x30 - -/* - * Macro for printing message depending on command line option and verbosity. - */ -#define __lttng_print(type, fmt, args...) \ - do { \ - if (opt_quiet == 0) { \ - if (type == PRINT_MSG) { \ - fprintf(stdout, fmt, ## args); \ - } else if (((type & PRINT_DBG) && opt_verbose == 1) || \ - ((type & (PRINT_DBG | PRINT_DBG2)) && \ - opt_verbose == 2) || \ - ((type & (PRINT_DBG | PRINT_DBG2 | PRINT_DBG3)) && \ - opt_verbose == 3)) { \ - fprintf(stderr, fmt, ## args); \ - } else if (type & (PRINT_ERR | PRINT_WARN | PRINT_BUG)) { \ - fprintf(stderr, fmt, ## args); \ - } \ - } \ - } while (0); - -#define MSG(fmt, args...) \ - __lttng_print(PRINT_MSG, fmt "\n", ## args) -#define ERR(fmt, args...) \ - __lttng_print(PRINT_ERR, "Error: " fmt "\n", ## args) -#define WARN(fmt, args...) \ - __lttng_print(PRINT_WARN, "Warning: " fmt "\n", ## args) -#define BUG(fmt, args...) \ - __lttng_print(PRINT_BUG, "BUG: " fmt "\n", ## args) - -/* Three level of debug. Use -v, -vv or -vvv for the levels */ -#define DBG(fmt, args...) __lttng_print(PRINT_DBG, "DEBUG1: " fmt \ - " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__) -#define DBG2(fmt, args...) __lttng_print(PRINT_DBG2, "DEBUG2: " fmt \ - " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__) -#define DBG3(fmt, args...) __lttng_print(PRINT_DBG3, "DEBUG3: " fmt \ - " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__) - -#define _PERROR(fmt, args...) \ - __lttng_print(PRINT_ERR, "perror " fmt "\n", ## args) - -#define PERROR(call, args...) \ - do { \ - char *buf; \ - char tmp[200]; \ - buf = strerror_r(errno, tmp, sizeof(tmp)); \ - _PERROR(call ": %s", ## args, buf); \ - } while(0); - -#endif /* _LTTNGERR_H */ diff --git a/src/common/runas.c b/src/common/runas.c index cc5034126..497a96ad8 100644 --- a/src/common/runas.c +++ b/src/common/runas.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include "runas.h" diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 838afedba..9fbc7358c 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -28,10 +28,9 @@ #include #include -#include -#include #include #include +#include #include /* Socket to session daemon for communication */