From 34bfce62150d07cf9894f2d9cbd0c989a203ea52 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Mon, 31 Mar 2014 13:21:06 +0200 Subject: link: Catch missing io_free() implementations Signed-off-by: Thomas Graf Signed-off-by: Thomas Haller --- include/netlink-private/netlink.h | 7 +++++++ lib/route/link.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h index ee2a8b1..e366d1e 100644 --- a/include/netlink-private/netlink.h +++ b/include/netlink-private/netlink.h @@ -102,6 +102,13 @@ struct trans_list { assert(0); \ } while (0) +#define BUG_ON(condition) \ + do { \ + if (condition) \ + BUG(); \ + } while (0) + + #define APPBUG(msg) \ do { \ fprintf(stderr, "APPLICATION BUG: %s:%d:%s: %s\n", \ diff --git a/lib/route/link.c b/lib/route/link.c index d609b17..3263096 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -194,6 +194,10 @@ static void release_link_info(struct rtnl_link *link) if (io != NULL) { if (io->io_free) io->io_free(link); + else { + /* Catch missing io_free() implementations */ + BUG_ON(link->l_info); + } rtnl_link_info_ops_put(io); link->l_info_ops = NULL; } -- cgit v0.12