-void warn_elem(struct uci_element *e, const char *format, ...);
-void warn(const char *format, ...);
-void error(const char *format, ...);
-void info(const char *format, ...);
-
-#define setbit(field, flag) field |= (1 << (flag))
-#define delbit(field, flag) field &= ~(1 << (flag))
-#define hasbit(field, flag) (field & (1 << (flag)))
-
-#define set(field, family, flag) setbit(field[family == FW3_FAMILY_V6], flag)
-#define del(field, family, flag) delbit(field[family == FW3_FAMILY_V6], flag)
-#define has(field, family, flag) hasbit(field[family == FW3_FAMILY_V6], flag)
+struct fw3_address;
+
+void warn_elem(struct uci_element *e, const char *format, ...)
+ __attribute__ ((format (printf, 2, 3)));
+void warn(const char *format, ...)
+ __attribute__ ((format (printf, 1, 2)));
+void error(const char *format, ...)
+ __attribute__ ((format (printf, 1, 2)));
+void info(const char *format, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
+#define warn_section(t, r, e, fmt, ...) \
+ do { \
+ if (e) \
+ warn_elem(e, fmt, ##__VA_ARGS__); \
+ else \
+ warn("Warning: ubus " t " (%s) " fmt, \
+ (r && r->name) ? r->name : "?", ##__VA_ARGS__); \
+ } while(0)
+
+#define fw3_setbit(field, flag) field |= (1 << (flag))
+#define fw3_delbit(field, flag) field &= ~(1 << (flag))
+#define fw3_hasbit(field, flag) (field & (1 << (flag)))
+
+#define set(field, family, flag) fw3_setbit(field[family == FW3_FAMILY_V6], flag)
+#define del(field, family, flag) fw3_delbit(field[family == FW3_FAMILY_V6], flag)
+#define has(field, family, flag) fw3_hasbit(field[family == FW3_FAMILY_V6], flag)