Fix coverity issue - UNCHECKED_RETURN 48/301548/1 accepted/tizen/unified/20231121.102919
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:31:34 +0000 (11:31 +0900)
[Version] 0.6.40
[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 5f2fc05a5922d4907342173a97f60ccbeb90e90c..a9426e278562b0cc4960bfdaf213afefa97c94b3 100644 (file)
@@ -4,7 +4,7 @@
 
 Name:       capi-media-codec
 Summary:    A Media Codec library in Tizen Native API
-Version:    0.6.39
+Version:    0.6.40
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index ee24d4da86efe81a9e5e64fbed9832466bffa3eb..34c0d7f7bd4c80d0d1e4fd06032efb5fb5c671ad 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 dc9701e9738c8a65eca1bee06bc4c386a3d3d5bf..0cb366644bc7467323f9d7cfefb73ab4adca0c43 100644 (file)
@@ -1061,6 +1061,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;
 
@@ -1073,8 +1074,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;
@@ -1106,7 +1111,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;