diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-11-05 07:47:41 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-11-05 07:52:22 +0100 |
commit | 929d8870d22e970e9513f9f194e005857b7317e6 (patch) | |
tree | 8c0789ea0ab6c06f979fe90189d1d048690a5377 | |
parent | af270a41e37f897d7598fcff173bbaa4f6454afd (diff) |
Change msgb_abort() function in MSGB_ABORT argument with variable arguments
This enables callers to provide format string and arguments to it
Also, put conditionals into the macro, and remove them from the caller
site.
-rw-r--r-- | include/osmocore/msgb.h | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/include/osmocore/msgb.h b/include/osmocore/msgb.h index 395c7c2c..af0dd1ed 100644 --- a/include/osmocore/msgb.h +++ b/include/osmocore/msgb.h @@ -62,10 +62,11 @@ extern void msgb_reset(struct msgb *m); #ifdef MSGB_DEBUG #include <osmocore/panic.h> -static inline void msgb_abort(struct msgb *msg, const char *text) -{ - osmo_panic("%s", text); -} +#define MSGB_ABORT(msg, fmt, args ...) do { \ + osmo_panic("msgb(%p)" fmt, ## args); \ + } while(0) +#else +#define MSGB_ABORT(msg, fmt, args ...) #endif #define msgb_l1(m) ((void *)(m->l1h)) @@ -106,10 +107,9 @@ static inline int msgb_headroom(const struct msgb *msgb) static inline unsigned char *msgb_put(struct msgb *msgb, unsigned int len) { unsigned char *tmp = msgb->tail; -#ifdef MSGB_DEBUG if (msgb_tailroom(msgb) < len) - msgb_abort(msgb, "Not enough tailroom\n"); -#endif + MSGB_ABORT(msgb, "Not enough tailroom msgb_push (%u < %u)\n", + msgb_tailroom(msgb), len); msgb->tail += len; msgb->len += len; return tmp; @@ -157,10 +157,9 @@ static inline uint32_t msgb_get_u32(struct msgb *msgb) } static inline unsigned char *msgb_push(struct msgb *msgb, unsigned int len) { -#ifdef MSGB_DEBUG if (msgb_headroom(msgb) < len) - msgb_abort(msgb, "Not enough headroom\n"); -#endif + MSGB_ABORT(msgb, "Not enough headroom msgb_push (%u < %u)\n", + msgb_headroom(msgb), len); msgb->data -= len; msgb->len += len; return msgb->data; |