From b0405ceec4391f08cd5c7bb31f55e13e009ee16f Mon Sep 17 00:00:00 2001 From: Seungbae Shin Date: Tue, 10 Dec 2019 17:44:17 +0900 Subject: [PATCH] [audio] Fix 'Uninitialized pointer field' defect on test code 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 | 2 +- testcase/audio/parser.cpp | 14 ++++++++------ testcase/audio/parser.hh | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packaging/mm-hal-interface.spec b/packaging/mm-hal-interface.spec index b2863d1..54a9c00 100755 --- a/packaging/mm-hal-interface.spec +++ b/packaging/mm-hal-interface.spec @@ -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 diff --git a/testcase/audio/parser.cpp b/testcase/audio/parser.cpp index a9c5609..608ed3a 100644 --- a/testcase/audio/parser.cpp +++ b/testcase/audio/parser.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include "parser.hh" #define DEVICE_FILE_OBJECT "device-files" #define DEVICE_TYPE_PROP_PLAYBACK_DEVICES "playback-devices" @@ -36,11 +36,13 @@ 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& 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& 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)); diff --git a/testcase/audio/parser.hh b/testcase/audio/parser.hh index c0d421f..34b7f14 100644 --- a/testcase/audio/parser.hh +++ b/testcase/audio/parser.hh @@ -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 m_playback; // device_string, device_params pair m_capture; // device_string, device_params -- 2.7.4