Fix coverity issue 68/291068/2 accepted/tizen/unified/20230412.152344
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 7 Apr 2023 08:50:30 +0000 (17:50 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 10 Apr 2023 06:36:24 +0000 (15:36 +0900)
- UNUSED_VALUE

[Version] 0.10.289
[Issue Type] Coverity

Change-Id: I265c9c553947c00fd2209d2294736f4dc86cc174
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/mm_camcorder_gstcommon.c
src/mm_camcorder_stillshot.c
src/mm_camcorder_videorec.c

index c6f10a3..addc4a4 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.288
+Version:    0.10.289
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 0eb02ff..4c0eeb4 100644 (file)
@@ -924,10 +924,8 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                goto pipeline_creation_error;
        }
 
-       if (element_list) {
+       if (element_list)
                g_list_free(element_list);
-               element_list = NULL;
-       }
 
        /* extra preview */
        if (extra_preview_enable)
@@ -945,10 +943,8 @@ pipeline_creation_error:
        _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSINK_QUE);
        _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSINK_SINK);
 
-       if (element_list) {
+       if (element_list)
                g_list_free(element_list);
-               element_list = NULL;
-       }
 
        return err;
 }
@@ -1044,7 +1040,6 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
                &audiosrc_element, &audiosrc_name);
 
        free(cat_name);
-       cat_name = NULL;
 
        MMCAM_LOG_INFO("Audio src name : %s", audiosrc_name);
 
@@ -1129,7 +1124,6 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
        if (caps) {
                MMCAMCORDER_G_OBJECT_SET_POINTER((sc->encode_element[_MMCAMCORDER_AUDIOSRC_CAPS].gst), "caps", caps);
                gst_caps_unref(caps);
-               caps = NULL;
        } else {
                MMCAM_LOG_ERROR("create caps error");
                err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
@@ -1152,19 +1146,15 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
        pad = gst_element_get_static_pad(last_element->gst, "src");
        if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst, gst_ghost_pad_new("src", pad))) {
                gst_object_unref(pad);
-               pad = NULL;
                MMCAM_LOG_ERROR("failed to create ghost pad on _MMCAMCORDER_AUDIOSRC_BIN.");
                err = MM_ERROR_CAMCORDER_GST_LINK;
                goto pipeline_creation_error;
        }
 
        gst_object_unref(pad);
-       pad = NULL;
 
-       if (element_list) {
+       if (element_list)
                g_list_free(element_list);
-               element_list = NULL;
-       }
 
        return MM_ERROR_NONE;
 
@@ -1175,10 +1165,8 @@ pipeline_creation_error:
        _MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_AUDIOSRC_VOL);
        _MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_AUDIOSRC_BIN);
 
-       if (element_list) {
+       if (element_list)
                g_list_free(element_list);
-               element_list = NULL;
-       }
 
        return err;
 }
@@ -1321,9 +1309,7 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                        caps_from_pad = gst_pad_get_allowed_caps(pad);
                        video_caps = gst_caps_copy(caps_from_pad);
                        gst_caps_unref(caps_from_pad);
-                       caps_from_pad = NULL;
                        gst_object_unref(pad);
-                       pad = NULL;
 
                        /* fixate caps */
                        video_caps = gst_caps_fixate(video_caps);
@@ -1358,12 +1344,10 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                MMCAM_LOG_INFO("encodebin caps [%s]", caps_str);
 
                g_free(caps_str);
-               caps_str = NULL;
 
                MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_CAPS].gst, "caps", video_caps);
 
                gst_caps_unref(video_caps);
-               video_caps = NULL;
 
                /* video scale */
                if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO &&
@@ -1395,7 +1379,6 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                        MMCAM_LOG_INFO("encodebin videocale [%s][%s]", gst_element_vscale_name, caps_str);
 
                        g_free(caps_str);
-                       caps_str = NULL;
 
                        _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_VSCALE, gst_element_vscale_name, "esink_vs", element_list, err);
                        _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_VSCALE_CAPS, "capsfilter", "esink_vs_c", element_list, err);
@@ -1535,9 +1518,7 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                                        if (video_caps) {
                                                MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "vcaps", video_caps);
                                                MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_VCONV].gst, "dst-buffer-num", _MMCAMCORDER_CONVERT_OUTPUT_BUFFER_NUM);
-
                                                gst_caps_unref(video_caps);
-                                               video_caps = NULL;
                                        } else {
                                                MMCAM_LOG_WARNING("failed to create caps");
                                        }
@@ -1578,7 +1559,6 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                        MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-audio-convert", TRUE);
                        MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "acaps", audio_caps);
                        gst_caps_unref(audio_caps);
-                       audio_caps = NULL;
                }
 
                if (audio_enc == MM_AUDIO_CODEC_OGG) {
@@ -1586,7 +1566,6 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                        MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-audio-convert", TRUE);
                        MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "acaps", audio_caps);
                        gst_caps_unref(audio_caps);
-                       audio_caps = NULL;
                        MMCAM_LOG_INFO("***** MM_AUDIO_CODEC_OGG : setting audio/x-raw-int ");
                }
 
@@ -1688,49 +1667,41 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                pad = gst_element_request_pad_simple(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "video");
                if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("video_sink0", pad))) {
                        gst_object_unref(pad);
-                       pad = NULL;
                        MMCAM_LOG_ERROR("failed to create ghost video_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
                        err = MM_ERROR_CAMCORDER_GST_LINK;
                        goto pipeline_creation_error;
                }
                gst_object_unref(pad);
-               pad = NULL;
 
                if (sc->audio_disable == FALSE) {
                        pad = gst_element_request_pad_simple(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
                        if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("audio_sink0", pad))) {
                                gst_object_unref(pad);
-                               pad = NULL;
                                MMCAM_LOG_ERROR("failed to create ghost audio_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
                                err = MM_ERROR_CAMCORDER_GST_LINK;
                                goto pipeline_creation_error;
                        }
                        gst_object_unref(pad);
-                       pad = NULL;
                }
        } else if (profile == MM_CAMCORDER_ENCBIN_PROFILE_AUDIO) {
                pad = gst_element_request_pad_simple(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
                if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("audio_sink0", pad))) {
                        gst_object_unref(pad);
-                       pad = NULL;
                        MMCAM_LOG_ERROR("failed to create ghost audio_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
                        err = MM_ERROR_CAMCORDER_GST_LINK;
                        goto pipeline_creation_error;
                }
                gst_object_unref(pad);
-               pad = NULL;
        } else {
                /* for stillshot */
                pad = gst_element_request_pad_simple(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "image");
                if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("image_sink0", pad))) {
                        gst_object_unref(pad);
-                       pad = NULL;
                        MMCAM_LOG_ERROR("failed to create ghost image_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
                        err = MM_ERROR_CAMCORDER_GST_LINK;
                        goto pipeline_creation_error;
                }
                gst_object_unref(pad);
-               pad = NULL;
        }
 
        MMCAM_LOG_INFO("Get pad complete");
@@ -1815,7 +1786,6 @@ int _mmcamcorder_create_preview_pipeline(MMHandleType handle)
                        __mmcamcorder_video_dataprobe_preview, hcamcorder);
 
                gst_object_unref(srcpad);
-               srcpad = NULL;
        } else {
                MMCAM_LOG_ERROR("failed to get srcpad");
                goto pipeline_creation_error;
@@ -1831,7 +1801,6 @@ int _mmcamcorder_create_preview_pipeline(MMHandleType handle)
                MMCAMCORDER_ADD_BUFFER_PROBE(srcpad, _MMCAMCORDER_HANDLER_PREVIEW,
                        __mmcamcorder_video_dataprobe_record, hcamcorder);
                gst_object_unref(srcpad);
-               srcpad = NULL;
        }
 
        bus = gst_pipeline_get_bus(GST_PIPELINE(sc->element[_MMCAMCORDER_MAIN_PIPE].gst));
@@ -1840,7 +1809,6 @@ int _mmcamcorder_create_preview_pipeline(MMHandleType handle)
        gst_bus_set_sync_handler(bus, _mmcamcorder_pipeline_bus_sync_callback, (gpointer)hcamcorder, NULL);
 
        gst_object_unref(bus);
-       bus = NULL;
 
        /* capture mode */
        err = _mmcamcorder_initialize_capture_mode(handle);
@@ -2398,7 +2366,6 @@ GstPadProbeReturn __mmcamcorder_eventprobe_monitor(GstPad *pad, GstPadProbeInfo
                }
 
                gst_object_unref(parent);
-               parent = NULL;
                break;
        case GST_EVENT_EOS:
                MMCAM_LOG_WARNING("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
@@ -2873,10 +2840,8 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
                do_set_caps = TRUE;
        }
 
-       if (caps) {
+       if (caps)
                gst_caps_unref(caps);
-               caps = NULL;
-       }
 
        if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
                /* assume that it's camera capture mode */
@@ -3147,7 +3112,6 @@ bool _mmcamcorder_set_sound_stream_info(GstElement *element, char *stream_type,
        MMCAMCORDER_G_OBJECT_SET_POINTER(element, "stream-properties", props);
 
        gst_structure_free(props);
-       props = NULL;
 
        return TRUE;
 }
index 0a6c85f..37a3c36 100644 (file)
@@ -1922,10 +1922,8 @@ static void __mmcamcorder_image_capture_cb(GstElement *element, GstSample *sampl
                        ret = __mmcamcorder_update_exif_info((MMHandleType)hcamcorder, dest.data, dest.length);
                }
 
-               if (ret != MM_ERROR_NONE) {
+               if (ret != MM_ERROR_NONE)
                        MMCAM_LOG_WARNING("Failed set_exif_basic_info [%x], but keep going...", ret);
-                       ret = MM_ERROR_NONE;
-               }
        }
 
        /* get attribute item for EXIF data */
index 42ff6ce..dbebd72 100644 (file)
@@ -320,21 +320,18 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
                MMCAMCORDER_ADD_BUFFER_PROBE(sinkpad, _MMCAMCORDER_HANDLER_VIDEOREC,
                        __mmcamcorder_audioque_dataprobe, hcamcorder);
                gst_object_unref(sinkpad);
-               sinkpad = NULL;
 
                /* for voice mute */
                srcpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, "src");
                MMCAMCORDER_ADD_BUFFER_PROBE(srcpad, _MMCAMCORDER_HANDLER_VIDEOREC,
                        __mmcamcorder_audio_dataprobe_audio_mute, hcamcorder);
                gst_object_unref(srcpad);
-               srcpad = NULL;
 
                if (sc->encode_element[_MMCAMCORDER_ENCSINK_AENC_QUE].gst) {
                        srcpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC_QUE].gst, "src");
                        MMCAMCORDER_ADD_EVENT_PROBE(srcpad, _MMCAMCORDER_HANDLER_VIDEOREC,
                                __mmcamcorder_eventprobe_monitor, hcamcorder);
                        gst_object_unref(srcpad);
-                       srcpad = NULL;
                }
        }
 
@@ -343,7 +340,6 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
                MMCAMCORDER_ADD_EVENT_PROBE(srcpad, _MMCAMCORDER_HANDLER_VIDEOREC,
                        __mmcamcorder_eventprobe_monitor, hcamcorder);
                gst_object_unref(srcpad);
-               srcpad = NULL;
        }
 
        if (sc->audio_disable) {
@@ -351,7 +347,6 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
                MMCAMCORDER_ADD_BUFFER_PROBE(sinkpad, _MMCAMCORDER_HANDLER_VIDEOREC,
                        __mmcamcorder_video_dataprobe_audio_disable, hcamcorder);
                gst_object_unref(sinkpad);
-               sinkpad = NULL;
        }
 
        if (!strcmp(gst_element_rsink_name, "filesink")) {
@@ -359,14 +354,12 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
                MMCAMCORDER_ADD_BUFFER_PROBE(srcpad, _MMCAMCORDER_HANDLER_VIDEOREC,
                        __mmcamcorder_video_dataprobe_encoded, hcamcorder);
                gst_object_unref(srcpad);
-               srcpad = NULL;
 
                if (sc->audio_disable == FALSE) {
                        srcpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst, "src");
                        MMCAMCORDER_ADD_BUFFER_PROBE(srcpad, _MMCAMCORDER_HANDLER_VIDEOREC,
                                __mmcamcorder_audio_dataprobe_check, hcamcorder);
                        gst_object_unref(srcpad);
-                       srcpad = NULL;
                }
        }
 
@@ -376,7 +369,6 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
        MMCAMCORDER_ADD_EVENT_PROBE(sinkpad, _MMCAMCORDER_HANDLER_VIDEOREC,
                __mmcamcorder_eventprobe_monitor, hcamcorder);
        gst_object_unref(sinkpad);
-       sinkpad = NULL;
 
        bus = gst_pipeline_get_bus(GST_PIPELINE(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst));
 
@@ -384,7 +376,6 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
        gst_bus_set_sync_handler(bus, _mmcamcorder_encode_pipeline_bus_sync_callback, (gpointer)hcamcorder, NULL);
 
        gst_object_unref(bus);
-       bus = NULL;
 
        return MM_ERROR_NONE;
 
@@ -461,14 +452,12 @@ int _mmcamcorder_remove_encode_pipeline(MMHandleType handle)
                if (reqpad) {
                        gst_element_release_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, reqpad);
                        gst_object_unref(reqpad);
-                       reqpad = NULL;
                }
 
                reqpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "video");
                if (reqpad) {
                        gst_element_release_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, reqpad);
                        gst_object_unref(reqpad);
-                       reqpad = NULL;
                }
 
                /* release encode main pipeline */
@@ -564,10 +553,8 @@ int _mmcamcorder_remove_recorder_pipeline(MMHandleType handle)
                while ((gst_msg = gst_bus_pop(bus)) != NULL) {
                        _mmcamcorder_pipeline_cb_message(bus, gst_msg, (gpointer)hcamcorder);
                        gst_message_unref(gst_msg);
-                       gst_msg = NULL;
                }
                gst_object_unref(bus);
-               bus = NULL;
        }
 
        MMCAM_LOG_INFO("done");