Fix coverity issue
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_gstcommon.c
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;
 }