summaryrefslogtreecommitdiffstats
path: root/libfdisk
diff options
context:
space:
mode:
authorKarel Zak2014-03-21 10:59:58 +0100
committerKarel Zak2014-03-21 10:59:58 +0100
commit9a7769141a71fdccae518e74ac5657c19c78b653 (patch)
tree9f7f657e87f13c166cf41ea80e95af71c3a2058f /libfdisk
parentbuild-sys: gettexts 0.18 -> 0.18.2 due to MKDIR_P (diff)
parentclean up redundant macros and defines (diff)
downloadkernel-qcow2-util-linux-9a7769141a71fdccae518e74ac5657c19c78b653.tar.gz
kernel-qcow2-util-linux-9a7769141a71fdccae518e74ac5657c19c78b653.tar.xz
kernel-qcow2-util-linux-9a7769141a71fdccae518e74ac5657c19c78b653.zip
Merge branch 'common_debug' of https://github.com/ooprala/util-linux
* 'common_debug' of https://github.com/ooprala/util-linux: clean up redundant macros and defines libfdisk: use include/debug.h libblkid: use include/debug.h libmount: further debug.h integration libcommon: don't mention lib versions in debug macros libcommon: define more debugging macros libmount: use macros from include/debug.h libcommon: add common debugging routines
Diffstat (limited to 'libfdisk')
-rw-r--r--libfdisk/src/fdiskP.h28
-rw-r--r--libfdisk/src/init.c18
2 files changed, 11 insertions, 35 deletions
diff --git a/libfdisk/src/fdiskP.h b/libfdisk/src/fdiskP.h
index cde75c1fa..a945ed3a7 100644
--- a/libfdisk/src/fdiskP.h
+++ b/libfdisk/src/fdiskP.h
@@ -23,6 +23,7 @@
#include "nls.h" /* temporary before dialog API will be implamented */
#include "list.h"
#include "tt.h"
+#include "debug.h"
/* features */
#define CONFIG_LIBFDISK_ASSERT
@@ -39,7 +40,6 @@
#define CONFIG_LIBFDISK_DEBUG
#endif
-#ifdef CONFIG_LIBFDISK_DEBUG
# include <stdio.h>
# include <stdarg.h>
@@ -55,22 +55,19 @@
#define FDISK_DEBUG_TAB (1 << 9)
#define FDISK_DEBUG_ALL 0xFFFF
+#define FDISK_DEF_FLAG(m) UL_DEFINE_FLAG(FDISK_DEBUG_, m)
+
+#define DBG(m, x) do { __UL_DBG(libfdisk, FDISK_DEBUG_, m, x); } while (0)
+
# define ON_DBG(m, x) do { \
- if ((FDISK_DEBUG_ ## m) & fdisk_debug_mask) { \
+ if ((FDISK_DEBUG_ ## m) & libfdisk_debug_mask) { \
x; \
} \
} while (0)
-# define DBG(m, x) do { \
- if ((FDISK_DEBUG_ ## m) & fdisk_debug_mask) { \
- fprintf(stderr, "%d: fdisk: %8s: ", getpid(), # m); \
- x; \
- } \
- } while (0)
-
# define DBG_FLUSH do { \
- if (fdisk_debug_mask && \
- fdisk_debug_mask != FDISK_DEBUG_INIT) \
+ if (libfdisk_debug_mask && \
+ libfdisk_debug_mask != FDISK_DEBUG_INIT) \
fflush(stderr); \
} while(0)
@@ -84,14 +81,7 @@ dbgprint(const char *mesg, ...)
fputc('\n', stderr);
}
-extern int fdisk_debug_mask;
-
-#else /* !CONFIG_LIBFDISK_DEBUG */
-# define ON_DBG(m,x) do { ; } while (0)
-# define DBG(m,x) do { ; } while (0)
-# define DBG_FLUSH do { ; } while(0)
-#endif
-
+UL_DEBUG_DECLARE_MASK(libfdisk);
#ifdef TEST_PROGRAM
struct fdisk_test {
diff --git a/libfdisk/src/init.c b/libfdisk/src/init.c
index 7d875ee8f..e30c8b976 100644
--- a/libfdisk/src/init.c
+++ b/libfdisk/src/init.c
@@ -1,8 +1,7 @@
#include "fdiskP.h"
-int fdisk_debug_mask;
-
+UL_DEBUG_DEFINE_MASK(libfdisk);
/**
* fdisk_init_debug:
@@ -16,18 +15,5 @@ int fdisk_debug_mask;
*/
void fdisk_init_debug(int mask)
{
- if (fdisk_debug_mask & FDISK_DEBUG_INIT)
- return;
- if (!mask) {
- char *str = getenv("LIBFDISK_DEBUG");
- if (str)
- fdisk_debug_mask = strtoul(str, 0, 0);
- } else
- fdisk_debug_mask = mask;
-
- if (fdisk_debug_mask)
- fprintf(stderr, "libfdisk: debug mask set to 0x%04x.\n",
- fdisk_debug_mask);
-
- fdisk_debug_mask |= FDISK_DEBUG_INIT;
+ __UL_INIT_DEBUG(libfdisk, FDISK_DEBUG_, mask, LIBFDISK_DEBUG);
}