summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-29 15:46:30 +1100
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-30 13:43:43 +1100
commitd5fe8bfe926f643e32d2bc0097dbee45f8410e28 (patch)
tree861ce1e973dc686b47210c7d8f4694c17f2438a2
parent49b861b4066d56ffb2c7ec71da6843d8e3c5e04b (diff)
Fix debug macros
No need to use asprintf to format debug output. Add debug prints. Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
-rw-r--r--src/avirt-config.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/avirt-config.c b/src/avirt-config.c
index b2e0d34..5fb714f 100644
--- a/src/avirt-config.c
+++ b/src/avirt-config.c
@@ -33,27 +33,15 @@
#define AVIRT_ERROR(errmsg) \
fprintf(stderr, "AVIRT ERROR: %s\n", errmsg);
-
-#define AVIRT_ERROR_V(errmsg, ...) \
- do { \
- char *errmsg_done; \
- asprintf(&errmsg_done, errmsg, ##__VA_ARGS__); \
- fprintf(stderr, "AVIRT ERROR: %s\n", errmsg_done); \
- free(errmsg_done); \
- } while (0)
+#define AVIRT_ERROR_V(fmt, args...) \
+ fprintf(stderr, "AVIRT ERROR: " fmt "\n", ##args);
#define AVIRT_DEBUG_ON
#ifdef AVIRT_DEBUG_ON
# define AVIRT_DEBUG(debugmsg) \
fprintf(stderr, "AVIRT DEBUG: %s\n", debugmsg);
-
-# define AVIRT_DEBUG_V(debugmsg, ...) \
- do { \
- char *debugmsg_done; \
- asprintf(&debugmsg_done, debugmsg, ##__VA_ARGS__); \
- fprintf(stderr, "[%s]: AVIRT DEBUG: %s\n", __func__, debugmsg_done); \
- free(debugmsg_done); \
- } while (0)
+# define AVIRT_DEBUG_V(fmt, args...) \
+ fprintf(stderr, "[%s]: AVIRT DEBUG: " fmt "\n", __func__, ##args);
#endif
#define WRITE_TO_PATH(path, fmt, args...) \
@@ -146,6 +134,8 @@ int AVIRT_CreateStream(const char *name, unsigned int channels, int direction,
WRITE_TO_PATH(path_attr, "%s", map);
}
+ AVIRT_DEBUG_V("Created stream: %s", name);
+
return 0;
}
@@ -173,5 +163,7 @@ int AVIRT_SealCard()
strcat(path_sealed, "/sealed");
WRITE_TO_PATH(path_sealed, "%d", 1);
+ AVIRT_DEBUG("Card sealed!");
+
card_sealed = true;
}