Fix coverity issue - UNCHECKED_RETURN 47/301547/1 accepted/tizen/7.0/unified/20231121.121603
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 20 Nov 2023 02:26:17 +0000 (11:26 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 20 Nov 2023 02:30:54 +0000 (11:30 +0900)
[Version] 0.6.34
[Issue Type] Coverity

Change-Id: I7abaec8c1e32f54329024381ce9a2f8d3d5b0553
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/capi-media-codec.spec
src/media_codec_port.c
src/media_codec_port_gst.c

index 36ff021..ea359b4 100644 (file)
@@ -4,7 +4,7 @@
 
 Name:       capi-media-codec
 Summary:    A Media Codec library in Tizen Native API
-Version:    0.6.33
+Version:    0.6.34
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index ee24d4d..34c0d7f 100644 (file)
@@ -270,7 +270,7 @@ int mc_set_aenc_info(MMHandleType mediacodec, int samplerate, int channel, int b
 
 int mc_configure(MMHandleType mediacodec, media_format_h format, int flags)
 {
-       int ret = MC_ERROR_NONE;
+       int ret = MEDIA_FORMAT_ERROR_NONE;
        mc_handle_t *mc_handle = (mc_handle_t *) mediacodec;
        int i;
        const int codec_mask = 0xFFF0;
@@ -296,7 +296,11 @@ int mc_configure(MMHandleType mediacodec, media_format_h format, int flags)
        }
 
        if (type == MEDIA_FORMAT_AUDIO) {
-               media_format_get_audio_info(format, &mimetype, &channel, &samplerate, &bit, &bitrate);
+               ret = media_format_get_audio_info(format, &mimetype, &channel, &samplerate, &bit, &bitrate);
+               if (ret != MEDIA_FORMAT_ERROR_NONE) {
+                       LOGE("get audio info failed[0x%x]", ret);
+                       return MC_INVALID_ARG;
+               }
 
                codec_id = mimetype & codec_mask;
 
@@ -325,8 +329,13 @@ int mc_configure(MMHandleType mediacodec, media_format_h format, int flags)
                        return MC_PARAM_ERROR;
                }
        } else if (type == MEDIA_FORMAT_VIDEO) {
-               media_format_get_video_info(format, &mimetype, &width, &height, &bitrate, NULL);
-               media_format_get_video_frame_rate(format, &fps);
+               ret = media_format_get_video_info(format, &mimetype, &width, &height, &bitrate, NULL);
+               ret |= media_format_get_video_frame_rate(format, &fps);
+               if (ret != MEDIA_FORMAT_ERROR_NONE) {
+                       LOGE("get video info/frame_rate failed[0x%x]", ret);
+                       return MC_INVALID_ARG;
+               }
+
                codec_id = mimetype & codec_mask;
 
                if (GET_IS_ENCODER(flags)) {
@@ -382,7 +391,7 @@ int mc_configure(MMHandleType mediacodec, media_format_h format, int flags)
        LOGD("encoder : %d, hardware : %d, codec_id : %x, video : %d",
                        mc_handle->is_encoder, mc_handle->is_hw, mc_handle->codec_id, mc_handle->is_video);
 
-       return ret;
+       return MC_ERROR_NONE;
 }
 
 int mc_prepare(MMHandleType mediacodec)
index 52ac3dc..c05b084 100644 (file)
@@ -1082,6 +1082,7 @@ static void mc_gst_port_free(mc_gst_port_t *port)
 
 gboolean _mc_update_packet_info(mc_gst_core_t *core, media_format_h format)
 {
+       int ret = MEDIA_FORMAT_ERROR_NONE;
        gint bitrate = 0;
        gboolean is_format_change = FALSE;
 
@@ -1094,8 +1095,12 @@ gboolean _mc_update_packet_info(mc_gst_core_t *core, media_format_h format)
                gchar *sformat = NULL;
                media_format_mimetype_e mimetype = 0;
 
-               media_format_get_video_info(format, &mimetype, &width, &height, &bitrate, NULL);
-               media_format_get_video_frame_rate(format, &framerate);
+               ret = media_format_get_video_info(format, &mimetype, &width, &height, &bitrate, NULL);
+               ret |= media_format_get_video_frame_rate(format, &framerate);
+               if (ret != MEDIA_FORMAT_ERROR_NONE) {
+                       LOGE("get video info/frame_rate failed[0x%x]", ret);
+                       return FALSE;
+               }
 
                is_format_change |= input_port_def->info.video.width != width;
                is_format_change |= input_port_def->info.video.height != height;
@@ -1127,7 +1132,11 @@ gboolean _mc_update_packet_info(mc_gst_core_t *core, media_format_h format)
                gint samplerate;
                gint bit;
 
-               media_format_get_audio_info(format, NULL, &channel, &samplerate, &bit, &bitrate);
+               ret = media_format_get_audio_info(format, NULL, &channel, &samplerate, &bit, &bitrate);
+               if (ret != MEDIA_FORMAT_ERROR_NONE) {
+                       LOGE("get audio info failed[0x%x]", ret);
+                       return FALSE;
+               }
 
                is_format_change |= input_port_def->info.audio.channel != channel;
                is_format_change |= input_port_def->info.audio.samplerate != samplerate;