s4/net_drs: Utility macros for conditions checking
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>
Thu, 11 Feb 2010 23:47:55 +0000 (01:47 +0200)
committerAnatoliy Atanasov <anatoliy.atanasov@postpath.com>
Wed, 24 Feb 2010 12:14:07 +0000 (14:14 +0200)
source4/utils/net/drs/net_drs.h

index 5bca47d2c2e3b4c49f8d6f4414447a8750d71c87..4aeeb6fa4f4d28efa191dd298b8eb4bea727fd0c 100644 (file)
 
 #include "librpc/gen_ndr/ndr_drsuapi_c.h"
 
+
+/**
+ * Check for critical error
+ */
+#define NET_DRS_CHECK_GOTO(_condition,_label,_msg) \
+       do { \
+       if (!(_condition)) { \
+               d_printf(__location__": "#_condition" - %s\n", _msg); \
+               goto _label; \
+       } \
+       } while (0)
+
+/**
+ * check allocated memory macro
+ */
+#define NET_DRS_NOMEM_GOTO(_ptr,_label) \
+       NET_DRS_CHECK_GOTO(_ptr, _label, "Not enough memory!")
+
+
+
 /* net drs commands context */
 struct net_drs_context {
        struct net_context      *net_ctx;