[audio] Fix 'Uninitialized pointer field' defect on test code 19/219819/2 accepted/tizen/unified/20191213.042437 submit/tizen/20191212.093208
authorSeungbae Shin <seungbae.shin@samsung.com>
Tue, 10 Dec 2019 08:44:17 +0000 (17:44 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Tue, 10 Dec 2019 10:37:06 +0000 (19:37 +0900)
Side fixes for following warnings by Clang-Tidy:
  constructor does not initialize these fields [cppcoreguidelines-pro-type-member-init]
  single-argument constructors must be marked explicit to avoid unintentional implicit conversions [google-explicit-constructor]
  use nullptr [modernize-use-nullptr]

[Version] 0.0.27
[Profile] Common
[Issue Type] Coverity

Change-Id: I53abd19c26923d2176d519d3dd43108284eb3c33

packaging/mm-hal-interface.spec
testcase/audio/parser.cpp
testcase/audio/parser.hh

index b2863d1..54a9c00 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       mm-hal-interface
 Summary:    Multimedia HAL Interface
-Version:    0.0.26
+Version:    0.0.27
 Release:    0
 Group:      Multimedia/Development
 License:    Apache-2.0
index a9c5609..608ed3a 100644 (file)
@@ -4,7 +4,7 @@
 #include <string.h>
 #include <string>
 
-#include <parser.hh>
+#include "parser.hh"
 
 #define DEVICE_FILE_OBJECT                  "device-files"
 #define DEVICE_TYPE_PROP_PLAYBACK_DEVICES   "playback-devices"
 using namespace std;
 
 CDeviceMapParser::CDeviceMapParser()
+       : m_json_obj(nullptr), m_json_device_files_obj(nullptr)
 {
        open_json("/etc/pulse/device-map.json");
 }
 
 CDeviceMapParser::CDeviceMapParser(const char* map_file)
+       : m_json_obj(nullptr), m_json_device_files_obj(nullptr)
 {
        open_json(map_file);
 }
@@ -65,7 +67,7 @@ void CDeviceMapParser::open_json(const char* json_file)
        if (!json_object_is_type(m_json_device_files_obj, json_type_object)) {
                cout << "json object type failed" << endl;
                json_object_put(m_json_obj);
-               m_json_obj = NULL;
+               m_json_obj = nullptr;
                return;
        }
 
@@ -84,7 +86,7 @@ void CDeviceMapParser::close_json()
 
 void CDeviceMapParser::parse_playback()
 {
-       json_object *playback_devices_o = NULL;
+       json_object *playback_devices_o = nullptr;
 
        if (!json_object_object_get_ex(m_json_device_files_obj, DEVICE_TYPE_PROP_PLAYBACK_DEVICES, &playback_devices_o)) {
                cout << "failed to get playback" << endl;
@@ -98,7 +100,7 @@ void CDeviceMapParser::parse_playback()
 
 void CDeviceMapParser::parse_capture()
 {
-       json_object *capture_devices_o = NULL;
+       json_object *capture_devices_o = nullptr;
 
        if (!json_object_object_get_ex(m_json_device_files_obj, DEVICE_TYPE_PROP_CAPTURE_DEVICES, &capture_devices_o)) {
                cout << "failed to get capture" << endl;
@@ -226,7 +228,7 @@ void CDeviceMapParser::parse_device_role_object(json_object *device_role_o, stri
 
 void CDeviceMapParser::parse_device_file_object(json_object *device_file_o, pair<string, string>& device)
 {
-       json_object *device_file_prop_o = NULL;
+       json_object *device_file_prop_o = nullptr;
        string device_string, device_param;
 
        assert(device_file_o);
@@ -262,7 +264,7 @@ void CDeviceMapParser::parse_device_file_object(json_object *device_file_o, pair
 void CDeviceMapParser::parse_device_file_array_object(json_object *device_file_array_o, pair<string, string>& device)
 {
        int num, idx;
-       json_object *device_file_o = NULL;
+       json_object *device_file_o = nullptr;
 
        assert(device_file_array_o);
        assert(json_object_is_type(device_file_array_o, json_type_array));
index c0d421f..34b7f14 100644 (file)
@@ -26,7 +26,7 @@ class CDeviceMapParser
 {
 public:
        CDeviceMapParser();
-       CDeviceMapParser(const char* map_file);
+       explicit CDeviceMapParser(const char* map_file);
        virtual ~CDeviceMapParser();
 
        void dump_devices();
@@ -48,7 +48,7 @@ private:
        void get_params(string& s, int& rate, int& channels);
        void get_single_param(string& s, int& rate, int& channels);
 
-       // FixMe, pair doens't define what is paired clearly....
+       // FixMe, pair doesn't define what is paired clearly....
        pair<string, string> m_playback; // device_string, device_params
        pair<string, string> m_capture;  // device_string, device_params