Implement VERIFY_NON_NULL() in terms VERIFY_NON_NULL_RET().
authorOssama Othman <ossama.othman@intel.com>
Tue, 21 Jul 2015 04:03:11 +0000 (21:03 -0700)
committerErich Keane <erich.keane@intel.com>
Tue, 21 Jul 2015 21:49:27 +0000 (21:49 +0000)
Minimize code duplication in the VERIFY_NON_NULL() macro by
implementing it terms of the VERIFY_NON_NULL_RET() macro.

Removed duplicate definitions of these macros as well.

Change-Id: I692b68744a0a1606ca64c7a676d910d32ffbbaf5
Signed-off-by: Ossama Othman <ossama.othman@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1772
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/inc/caadapterutils.h
resource/csdk/connectivity/inc/camessagehandler.h

index 197cc97..5c0b652 100644 (file)
@@ -47,31 +47,28 @@ extern "C"
 #endif
 
 /**
- * @def VERIFY_NON_NULL
+ * @def VERIFY_NON_NULL_RET
  * @brief Macro to verify the validity of input argument
  */
-#define VERIFY_NON_NULL(arg, log_tag, log_message) \
-    if (NULL == arg ){ \
+#define VERIFY_NON_NULL_RET(arg, log_tag, log_message,ret) \
+    if (NULL == arg{ \
         OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
-        return CA_STATUS_INVALID_PARAM; \
+        return ret; \
     } \
 
 /**
- * @def VERIFY_NON_NULL_RET
+ * @def VERIFY_NON_NULL
  * @brief Macro to verify the validity of input argument
  */
-#define VERIFY_NON_NULL_RET(arg, log_tag, log_message,ret) \
-    if (NULL == arg ){ \
-        OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
-        return ret; \
-    } \
+#define VERIFY_NON_NULL(arg, log_tag, log_message) \
+    VERIFY_NON_NULL_RET((arg), (log_tag), (log_message), CA_STATUS_INVALID_PARAM)
 
 /**
  * @def VERIFY_NON_NULL_VOID
  * @brief Macro to verify the validity of input argument
  */
 #define VERIFY_NON_NULL_VOID(arg, log_tag, log_message) \
-    if (NULL == arg ){ \
+    if (NULL == arg{ \
         OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
         return; \
     } \
index 4ffc362..844cb5b 100644 (file)
 #include "cacommon.h"
 #include "coap.h"
 
-/**
- * @def VERIFY_NON_NULL
- * @brief Macro to verify the validity of input argument.
- */
-#define VERIFY_NON_NULL(arg, log_tag, log_message) \
-    if (NULL == arg ){ \
-        OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
-        return CA_STATUS_INVALID_PARAM; \
-    } \
-
-/**
- * @def VERIFY_NON_NULL_VOID
- * @brief Macro to verify the validity of input argument.
- */
-#define VERIFY_NON_NULL_VOID(arg, log_tag, log_message) \
-    if (NULL == arg ){ \
-        OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
-        return; \
-    } \
-
 #define CA_MEMORY_ALLOC_CHECK(arg) { if (NULL == arg) {OIC_LOG(ERROR, TAG, "Out of memory"); \
 goto memory_error_exit;} }