Improve macros for checking condition 13/250813/1
authorSangchul Lee <sangchul1011@gmail.com>
Tue, 5 Jan 2021 02:55:00 +0000 (11:55 +0900)
committerSangchul Lee <sangchul1011@gmail.com>
Tue, 5 Jan 2021 03:00:03 +0000 (12:00 +0900)
Use do-while.
Remove empty if statement.

[Version] 0.1.28
[Issue Type] Refactoring

Change-Id: Idf23e60c01c72bf70b7986701468d5e895f4982e
Signed-off-by: Sangchul Lee <sangchul1011@gmail.com>
include/media_format_private.h
include/media_packet_pool_private.h
include/media_packet_private.h
packaging/capi-media-tool.spec

index fecc2d37f9d76d8e113b1153dce6e6dafe1122c9..e6cb0bc2b780a16e54f0b5eeff66580326dbbd7a 100644 (file)
@@ -30,12 +30,20 @@ extern "C" {
 #define LOG_TAG "TIZEN_MEDIA_TOOL"
 
 #define MEDIA_FORMAT_CHECK_CONDITION(condition, error, msg)     \
-       if (condition) {} else \
-       { LOGE("%s(0x%08x)", msg, error); return error; };
+do { \
+       if (!(condition)) { \
+               LOGE("%s(0x%08x)", msg, error); \
+               return error; \
+       } \
+} while (0)
 
 #define MEDIA_FORMAT_CHECK_CONDITION_VOID(condition, msg)     \
-       if (condition) {} else \
-       { LOGE("%s", msg); return; };
+do { \
+       if (!(condition)) { \
+               LOGE("%s", msg); \
+               return; \
+       } \
+} while (0)
 
 
 #define MEDIA_FORMAT_INSTANCE_CHECK(media_format)   \
index a082d2221b32dbfd4eca3d4dbdc508d728dace66..057d533a1ae90277e7bdb59ce7b2279b001c8284 100644 (file)
@@ -32,8 +32,12 @@ extern "C" {
 #define MAX_PACKET     25
 
 #define MEDIA_PACKET_POOL_CHECK_CONDITION(condition, error, msg)     \
-       if (condition) {} else \
-       { LOGE("%s(0x%08x)", msg, error); return error; };
+do { \
+       if (!(condition)) { \
+               LOGE("%s(0x%08x)", msg, error); \
+               return error; \
+       } \
+} while (0)
 
 #define MEDIA_PACKET_POOL_INSTANCE_CHECK(pool)   \
        MEDIA_PACKET_POOL_CHECK_CONDITION(pool != NULL, MEDIA_PACKET_ERROR_INVALID_PARAMETER, "MEDIA_PACKET_ERROR_INVALID_PARAMETER")
index 0ef6bd0d8d8435b1d8b277319d5773582079577d..aab463a53760915f2580268ce35c81a3820085ee 100644 (file)
@@ -30,8 +30,12 @@ extern "C" {
 #define LOG_TAG "TIZEN_MEDIA_TOOL"
 
 #define MEDIA_PACKET_CHECK_CONDITION(condition, error, msg)     \
-       if (condition) {} else \
-       { LOGE("%s(0x%08x)", msg, error); return error; };
+do { \
+       if (!(condition)) { \
+               LOGE("%s(0x%08x)", msg, error); \
+               return error; \
+       } \
+} while (0)
 
 #define MEDIA_PACKET_INSTANCE_CHECK(media_packet)   \
        MEDIA_PACKET_CHECK_CONDITION(media_packet != NULL, MEDIA_PACKET_ERROR_INVALID_PARAMETER, "MEDIA_PACKET_ERROR_INVALID_PARAMETER")
index 7ff7582dabddb0c02839472a28534c504e69bb78..2fa979f21ffb315eb3f369a3b64b10535813c492 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-tool
 Summary:    A Core API media tool library in Tizen Native API
-Version:    0.1.27
+Version:    0.1.28
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0