Fix coverity issue 21/152821/1 accepted/tizen/unified/20171010.063619 submit/tizen/20170928.044334
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 27 Sep 2017 07:18:40 +0000 (16:18 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 27 Sep 2017 07:18:40 +0000 (16:18 +0900)
- Improper use of negative value

[Version] 0.3.5
[Profile] Common
[Issue Type]
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-unified_20170926.2]

Change-Id: I23ec3d9ee2c4fe7e2112a626b5b2fa7b6b450525
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
muse/src/muse_camera_dispatcher.c
packaging/mmsvc-camera.spec

index 1fc8ffe..5a35807 100644 (file)
@@ -48,6 +48,7 @@ static int _camera_remove_export_data(muse_module_h module, int key, int remove_
 static void __camera_dispatcher_send_msg(muse_module_h module, char *msg)
 {
        int len = 0;
+       int sock_fd = 0;
 
        if (!msg) {
                LOGE("NULL msg");
@@ -61,7 +62,13 @@ static void __camera_dispatcher_send_msg(muse_module_h module, char *msg)
 
        /*LOGD("msg [%s]", msg);*/
 
-       len = muse_core_msg_send(muse_server_module_get_msg_fd(module), msg);
+       sock_fd = muse_server_module_get_msg_fd(module);
+       if (sock_fd == (int)MM_ERROR_INVALID_ARGUMENT) {
+               LOGE("failed to get socket fd");
+               goto _DONE;
+       }
+
+       len = muse_core_msg_send(sock_fd, msg);
        if (len <= 0)
                LOGE("sending message[%s] failed. errno %d", msg, errno);
 
@@ -880,6 +887,7 @@ void _camera_dispatcher_preview_cb(MMCamcorderVideoStreamDataType *stream, void
        int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
        int num_buffer_key = 0;
        int send_ret = 0;
+       int sock_fd = 0;
        muse_module_h module = (muse_module_h)user_data;
        unsigned char *buf_pos = NULL;
        char *send_message = NULL;
@@ -1067,7 +1075,13 @@ void _camera_dispatcher_preview_cb(MMCamcorderVideoStreamDataType *stream, void
                MUSE_TYPE_ARRAY, "buffer_key", BUFFER_MAX_PLANE_NUM, buffer_key,
                0);
 
-       send_ret = muse_core_msg_send(muse_server_module_get_msg_fd(module), send_message);
+       sock_fd = muse_server_module_get_msg_fd(module);
+       if (sock_fd == (int)MM_ERROR_INVALID_ARGUMENT) {
+               LOGE("failed to get socket fd from module %p", module);
+               send_ret = 0;
+       } else {
+               send_ret = muse_core_msg_send(sock_fd, send_message);
+       }
 
        muse_core_msg_free(send_message);
 
index 6e255f7..9127d3e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-camera
 Summary:    A Camera module for muse server
-Version:    0.3.4
+Version:    0.3.5
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0