From: YoungHun Kim Date: Tue, 6 Aug 2024 07:00:36 +0000 (+0900) Subject: Fix the svace and coverity issue X-Git-Tag: accepted/tizen/unified/20240821.081502^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_unified;p=platform%2Fcore%2Fmultimedia%2Fresource-info.git Fix the svace and coverity issue - UNINIT.CTOR.MANY COMPARE_RESULT_OF_NEW etc Change-Id: Ia0302a06605aec731f3b970ad443486a6c66c7f6 --- diff --git a/include_internal/CImageCodec.h b/include_internal/CImageCodec.h index 445a84f..a3c7d1d 100644 --- a/include_internal/CImageCodec.h +++ b/include_internal/CImageCodec.h @@ -21,7 +21,7 @@ class CImageCodec { public: - CImageCodec(std::string name); + CImageCodec(std::string name) : m_name(name) {} ~CImageCodec(); void SetMaxResolution(int w, int h) { m_width_max = w, m_height_max = h; } @@ -31,10 +31,10 @@ public: private: std::string m_name; - int m_width_max; - int m_height_max; - int m_width_min; - int m_height_min; + int m_width_max {}; + int m_height_max {}; + int m_width_min {}; + int m_height_min {}; }; #endif// __CIMAGE_CODEC_H__ diff --git a/include_internal/CModelInfo.h b/include_internal/CModelInfo.h index fd98baf..6102e96 100644 --- a/include_internal/CModelInfo.h +++ b/include_internal/CModelInfo.h @@ -51,8 +51,8 @@ private: int ReadIndex(std::string filename) const; std::string GetChipSetName(void); - bool m_has_dedicated_category_h264_fhd_portrait; - bool m_exclusive_bw_for_h264_fhd_n_decoding; + bool m_has_dedicated_category_h264_fhd_portrait {}; + bool m_exclusive_bw_for_h264_fhd_n_decoding {}; std::string m_chipset_name; std::map m_chipset_info; diff --git a/include_internal/CMultiview.h b/include_internal/CMultiview.h index 68d476f..13da5d7 100644 --- a/include_internal/CMultiview.h +++ b/include_internal/CMultiview.h @@ -55,7 +55,7 @@ private: void Init(void); void SetPolicy(const int strategy, const ReclaimPolicy reclaim, const InterlacedPlayback interlaced, const SeamlessPlayback seamless, const AV1DualDecoding dual_decoding); - int strategy_; + int strategy_ {}; ReclaimPolicy reclaim_policy_; InterlacedPlayback interlaced_playback_; SeamlessPlayback seamless_playback_; diff --git a/include_internal/CResourceInfo.h b/include_internal/CResourceInfo.h index 441306d..bc1285a 100644 --- a/include_internal/CResourceInfo.h +++ b/include_internal/CResourceInfo.h @@ -25,8 +25,8 @@ class CResourceInfo { public: - CResourceInfo(); - ~CResourceInfo(); + CResourceInfo() {} + ~CResourceInfo() {}; static CResourceInfo* GetInstance(void); ri_rsc_category_e GetVideoCategoryID(const char *codec_name, int color_depth, int h_size, int framerate, int sampling_format); @@ -39,7 +39,7 @@ public: int GetCapableAudioDecoderCategoryID(ri_audio_category_option_request_s* option); private: - static CResourceInfo* m_instance; + static CResourceInfo *m_instance; ri_color_depth GetColorDepthID(int color_depth, int sampling_format); ri_framerate GetFrameRateID(int framerate); diff --git a/include_internal/CResourceInfoDB.h b/include_internal/CResourceInfoDB.h index a2017d8..74882b5 100644 --- a/include_internal/CResourceInfoDB.h +++ b/include_internal/CResourceInfoDB.h @@ -44,8 +44,8 @@ class CategoryElement; class CResourceInfoDB { public: - CResourceInfoDB(); - ~CResourceInfoDB(); + CResourceInfoDB() {} + ~CResourceInfoDB() {} static CResourceInfoDB* GetInstance(void); ri_rsc_category_e IsSupportedVideoFormat(ri_rsc_category_e decoder_id); @@ -125,7 +125,7 @@ public: ri_device_common_attr_s *GetDeviceAttr(int device_id); private: - static CResourceInfoDB* m_instance; + static CResourceInfoDB *m_instance; std::map m_resource_categories; std::map m_device_attr_map_by_dev_id; @@ -145,9 +145,9 @@ private: std::map m_video_decoders; std::map> video_capabilities_; - int m_system_bw; - int m_vdecs; - int m_n_scalers; + int m_system_bw {}; + int m_vdecs {}; + int m_n_scalers {}; bool GetDeviceNodePathNames(int category, char** device_node); bool GetClassOptions(const char *codec, ri_video_decoder_class_e class_value, bool *is_uhd_decoder, int *class_cat, bool *is_class_uhd, char **class_device_node); @@ -158,6 +158,6 @@ private: bool IsScaler(int category); void InitVideoDecCategories(void); bool IsCodecSupporting2KPortrait(std::string codec_name); - CCategoryIdBuilder* GetVideoDecCategoryBuilder(std::string codec_name); + CCategoryIdBuilder *GetVideoDecCategoryBuilder(std::string codec_name); }; #endif //_RESOURCE_INFO_DB_H_ diff --git a/include_internal/CVideoCapability.h b/include_internal/CVideoCapability.h index 9720556..ae74480 100644 --- a/include_internal/CVideoCapability.h +++ b/include_internal/CVideoCapability.h @@ -19,8 +19,8 @@ class VideoCapability { public: - VideoCapability(const std::string device, const int w, const int h, const int fps): device_(device), width_(w), height_(h), fps_(fps) {} - VideoCapability(const VideoCapability& capa): device_(""), width_(0), height_(0), fps_(0) { + VideoCapability(const std::string device, const int w, const int h, const int fps) : device_(device), width_(w), height_(h), fps_(fps) {} + VideoCapability(const VideoCapability& capa) : device_(""), width_(0), height_(0), fps_(0) { device_ = capa.GetDeviceProperty(); width_ = capa.GetWidth(); height_ = capa.GetHeight(); diff --git a/include_internal/CVideoCodecNDecoding.h b/include_internal/CVideoCodecNDecoding.h index 4d93971..f402e64 100644 --- a/include_internal/CVideoCodecNDecoding.h +++ b/include_internal/CVideoCodecNDecoding.h @@ -21,7 +21,8 @@ class CVideoCodecNDecoding { public: - CVideoCodecNDecoding(std::string codec_name, int rsz, int framerate):m_name(codec_name), m_max_rsz(rsz), m_max_fps(framerate) { } + CVideoCodecNDecoding(std::string codec_name, int rsz, int framerate) + : m_name(codec_name), m_max_rsz(rsz), m_max_fps(framerate) { } ~CVideoCodecNDecoding() = default; void SetMaxResolution(int rsz) { m_max_rsz = rsz; } @@ -33,8 +34,8 @@ public: private: std::string m_name; - int m_max_rsz; - int m_max_fps; - int m_category_id; + int m_max_rsz {}; + int m_max_fps {}; + int m_category_id {}; }; #endif //__CVideoCodecNDecoding_H__ diff --git a/include_internal/CVideoEncoder.h b/include_internal/CVideoEncoder.h index 526f3ad..a853bc6 100644 --- a/include_internal/CVideoEncoder.h +++ b/include_internal/CVideoEncoder.h @@ -31,16 +31,16 @@ public: unsigned long long GetMaxBandWidthMultiEncodingSingle(void) const; private: - CVideoEncoder():max_w_(0), max_h_(0), max_fps_(0), max_w_multi_(0), max_h_multi_(0), max_fps_multi_(0), margin_(0) {} + CVideoEncoder() {} ~CVideoEncoder() = default; - int max_w_; - int max_h_; - int max_fps_; - int max_w_multi_; - int max_h_multi_; - int max_fps_multi_; - int margin_; + int max_w_ {}; + int max_h_ {}; + int max_fps_ {}; + int max_w_multi_ {}; + int max_h_multi_ {}; + int max_fps_multi_ {}; + int margin_ {}; }; #endif //__CVIDEO_ENCODER_H__ \ No newline at end of file diff --git a/include_internal/parser/CCategory.h b/include_internal/parser/CCategory.h index 3722428..55a2364 100644 --- a/include_internal/parser/CCategory.h +++ b/include_internal/parser/CCategory.h @@ -45,12 +45,12 @@ public: private: std::string m_name; - ri_rsc_category_e m_id; - category_type_e m_type; + ri_rsc_category_e m_id {}; + category_type_e m_type {}; std::string m_codec_name; - ri_resolution m_rsz; - int m_framerate; - bool m_n_decoding; + ri_resolution m_rsz {}; + int m_framerate {}; + bool m_n_decoding {}; }; #endif//__CCATEGORY_H_ diff --git a/include_internal/parser/CResourceTableProviderDefault.h b/include_internal/parser/CResourceTableProviderDefault.h index b0ee306..7ad1be3 100644 --- a/include_internal/parser/CResourceTableProviderDefault.h +++ b/include_internal/parser/CResourceTableProviderDefault.h @@ -22,16 +22,17 @@ class CResourceTableProviderDefault { public: - CResourceTableProviderDefault(const int table_index, const int product_type, const bool support_android); + CResourceTableProviderDefault(const int table_index, const int product_type, const bool support_android) + :table_index_(table_index), product_type_(product_type), support_android_(support_android) {} ~CResourceTableProviderDefault() = default; private: std::string FindResourceTablePath(const std::map &table_paths, const int index) const; std::string FindResourceTablePathAOT(const std::map &table_paths, const int index) const; - int table_index_; - int product_type_; - bool support_android_; + int table_index_ {}; + int product_type_ {}; + bool support_android_ {}; }; #endif // __CRESOURCE_PROVIDER_TABLE_DEFAULT_H__ diff --git a/include_internal/parser/CResourceTableProviderLicense.h b/include_internal/parser/CResourceTableProviderLicense.h index 9d439b1..174ce3c 100644 --- a/include_internal/parser/CResourceTableProviderLicense.h +++ b/include_internal/parser/CResourceTableProviderLicense.h @@ -26,13 +26,13 @@ class CResourceTableProviderLicense { public: - CResourceTableProviderLicense(const int table_index):table_index_(table_index) {}; + CResourceTableProviderLicense(const int table_index) :table_index_(table_index) {}; ~CResourceTableProviderLicense() = default; std::string GetResourceTablePath(void) const; private: - int table_index_; + int table_index_ {}; }; #endif //__CRESOURCE_TABLE_PROVIDER_LICENSE_H__ diff --git a/include_internal/parser/element/CCapabilityElement.h b/include_internal/parser/element/CCapabilityElement.h index 34e173c..cab3c02 100644 --- a/include_internal/parser/element/CCapabilityElement.h +++ b/include_internal/parser/element/CCapabilityElement.h @@ -21,7 +21,7 @@ class CapabilityElement : public Element { public: - CapabilityElement(const std::string device, const int w, const int h, const int fps): device_(device), width_(w), height_(h), fps_(fps) {}; + CapabilityElement(const std::string device, const int w, const int h, const int fps) : device_(device), width_(w), height_(h), fps_(fps) {}; ~CapabilityElement() = default; std::string GetDevice(void) const { return device_; } @@ -30,10 +30,10 @@ public: int GetFPS(void) const { return fps_; } private: - CapabilityElement(): device_(""), width_(0), height_(0), fps_(0) {}; + CapabilityElement() {} std::string device_; - int width_; - int height_; - int fps_; + int width_ {}; + int height_ {}; + int fps_ {}; }; \ No newline at end of file diff --git a/include_internal/parser/element/CCategoryElement.h b/include_internal/parser/element/CCategoryElement.h index 6ecfc26..efa048a 100644 --- a/include_internal/parser/element/CCategoryElement.h +++ b/include_internal/parser/element/CCategoryElement.h @@ -23,7 +23,7 @@ class CategoryElement : public Element { public: - CategoryElement(void){} + CategoryElement(void) : Element() {} CategoryElement(char *category_name, char *category_type, int class_id, bool is_uhd_device); ~CategoryElement(void); @@ -135,8 +135,8 @@ public: // LCOV_EXCL_END protected: - ri_rsc_category_e m_promotion_category_enum; - ri_rsc_category_e m_category_enum; + ri_rsc_category_e m_promotion_category_enum { RI_CATEGORY_NONE }; + ri_rsc_category_e m_category_enum { RI_CATEGORY_NONE }; private: }; diff --git a/include_internal/parser/element/CDecodingElement.h b/include_internal/parser/element/CDecodingElement.h index a646030..5b03858 100644 --- a/include_internal/parser/element/CDecodingElement.h +++ b/include_internal/parser/element/CDecodingElement.h @@ -20,7 +20,7 @@ class DecodingElement : public Element { public: - DecodingElement(const std::string codec): codec_(codec) {} + DecodingElement(const std::string codec) : codec_(codec) {} ~DecodingElement(); void SetCodec(const std::string codec) { codec_ = codec; } @@ -31,7 +31,7 @@ public: void ReleaseChildElement(void) override; private: - DecodingElement(): codec_("empty") {} + DecodingElement() : codec_("empty") {} std::string codec_; }; \ No newline at end of file diff --git a/include_internal/parser/element/CElement.h b/include_internal/parser/element/CElement.h index 3637feb..2f3cbfb 100644 --- a/include_internal/parser/element/CElement.h +++ b/include_internal/parser/element/CElement.h @@ -25,10 +25,13 @@ class Element { public: - Element(void); - Element(char *element_name, char *element_type, int class_id, bool is_uhd_device); - Element(char *element_name, char *element_type); - Element(char *element_name); + Element(void) {} + Element(char *element_name, char *element_type, int class_id, bool is_uhd_device) + : m_element_name(element_name), m_element_type(element_type), m_class_id(class_id), m_is_uhd_decoder(is_uhd_device) { SetElementAttr(ELEMENT_CATEGORY); } + Element(char *element_name, char *element_type) + : m_element_name(element_name), m_element_type(element_type) {} + Element(char *element_name) + : m_element_name(element_name) {} virtual ~Element(void){} virtual void SetElementAttr(ri_element_attribute_e element_attr); @@ -67,28 +70,28 @@ public: virtual int GetMaxResolution(void) { return m_max_rez; } protected: - ri_element_attribute_e m_element_attr; //category, device, feature - char *m_element_name; - char *m_element_type; - unsigned int m_element_bw; - ri_mem_cluster_s* m_element_mem_cluster; - int m_id; - int m_class_id; //for category + ri_element_attribute_e m_element_attr { ELEMENT_ROOT }; //category, device, feature + char *m_element_name {}; + char *m_element_type {}; + unsigned int m_element_bw {}; + ri_mem_cluster_s* m_element_mem_cluster {}; + int m_id {}; + int m_class_id {}; //for category std::set m_child_element; - int m_sharable_count; - int m_mixing; - bool m_is_uhd_decoder; - int m_device_id; - int m_is_main_device; - int m_max_rez; - bool m_is_support_overlay; - int m_max_sampling_format; - char *m_element_codec_name; + int m_sharable_count {}; + int m_mixing {}; + bool m_is_uhd_decoder {}; + int m_device_id {}; + int m_is_main_device {}; + int m_max_rez {}; + bool m_is_support_overlay {}; + int m_max_sampling_format {}; + char *m_element_codec_name {}; - char *m_device_path; - char *m_omx_comp_name; - char *m_audio_codec; + char *m_device_path {}; + char *m_omx_comp_name {}; + char *m_audio_codec {}; private: }; diff --git a/packaging/resource-information.spec b/packaging/resource-information.spec index 5341b74..ebe781f 100644 --- a/packaging/resource-information.spec +++ b/packaging/resource-information.spec @@ -1,7 +1,7 @@ Name: resource-information Summary: Resource Information Version: 0.1 -Release: 1 +Release: 2 Group: Multimedia/Libraries License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/CImageCodec.cpp b/src/CImageCodec.cpp index ab56086..903401f 100644 --- a/src/CImageCodec.cpp +++ b/src/CImageCodec.cpp @@ -17,11 +17,6 @@ #include #include -CImageCodec::CImageCodec(std::string name) -{ - m_name = name; -} - // LCOV_EXCL_START CImageCodec::~CImageCodec() { diff --git a/src/CModelInfo.cpp b/src/CModelInfo.cpp index 825a0a0..8dc3b96 100644 --- a/src/CModelInfo.cpp +++ b/src/CModelInfo.cpp @@ -39,7 +39,7 @@ CModelInfo& CModelInfo::GetInstance(void) return instance_; } -CModelInfo::CModelInfo(void): m_has_dedicated_category_h264_fhd_portrait(false), m_exclusive_bw_for_h264_fhd_n_decoding(false) +CModelInfo::CModelInfo(void) : m_has_dedicated_category_h264_fhd_portrait(false), m_exclusive_bw_for_h264_fhd_n_decoding(false) { InitFeatures(); } diff --git a/src/CMultiview.cpp b/src/CMultiview.cpp index 9e4dba7..63dcb84 100644 --- a/src/CMultiview.cpp +++ b/src/CMultiview.cpp @@ -25,7 +25,7 @@ // LCOV_EXCL_START -CMultiview::CMultiview(void):strategy_(RI_MV_STRATEGY_NOT_SUPPORT), reclaim_policy_(ReclaimPolicy::Default), interlaced_playback_(InterlacedPlayback::All), \ +CMultiview::CMultiview(void) : strategy_(RI_MV_STRATEGY_NOT_SUPPORT), reclaim_policy_(ReclaimPolicy::Default), interlaced_playback_(InterlacedPlayback::All), seamless_playback_(SeamlessPlayback::All), av1_dual_decoding_(AV1DualDecoding::Support) { Init(); diff --git a/src/CResourceInfo.cpp b/src/CResourceInfo.cpp index eb1a042..88b8441 100644 --- a/src/CResourceInfo.cpp +++ b/src/CResourceInfo.cpp @@ -42,12 +42,6 @@ CResourceInfo* CResourceInfo::m_instance = NULL; -CResourceInfo::CResourceInfo(void) -{ -} - -CResourceInfo::~CResourceInfo(void){} - CResourceInfo* CResourceInfo::GetInstance(void) { if (m_instance == NULL) { @@ -89,19 +83,19 @@ ri_rsc_category_e CResourceInfo::GetCapableVideoCategoryID(std::string codec_nam int rsz_id = GetResolutionID(width, height, n_decoding, codec_name); if (rsz_id == RI_RESOLUTION_UNDEFINED) { - RI_ERR("failed to get resolution id codec(%s)/h(%d)/v(%d)\n", codec_name.c_str(), width, height); + RI_ERR("failed to get resolution id codec(%s)/h(%d)/v(%d)", codec_name.c_str(), width, height); return RI_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED; } int color_depth_id = GetColorDepthID(color_depth, sampling_format); if (color_depth_id == (ri_color_depth) RI_ERROR) { - RI_ERR("failed to get color depth id(%d)\n", color_depth_id); + RI_ERR("failed to get color depth id(%d)", color_depth_id); return RI_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED; } int framerate_id = GetFrameRateID(framerate); if (framerate_id == RI_FRAMERATE_UNDEFINED) { - RI_ERR("failed to get framerate(%d)\n",framerate_id); + RI_ERR("failed to get framerate(%d)",framerate_id); return RI_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED; } @@ -121,7 +115,7 @@ ri_rsc_category_e CResourceInfo::GetCapableVideoCategoryID(std::string codec_nam // LCOV_EXCL_END RI_INFO("n_decoding(%d), category id : %d", n_decoding, category_id); - return (n_decoding) ? db->IsNDecodingSupportedVideoFormat((ri_rsc_category_e) category_id):db->IsSupportedVideoFormat((ri_rsc_category_e) category_id); + return (n_decoding) ? db->IsNDecodingSupportedVideoFormat((ri_rsc_category_e) category_id) :db->IsSupportedVideoFormat((ri_rsc_category_e) category_id); } ri_rsc_category_e CResourceInfo::GetCapableVideoCategoryID(ri_video_category_option_request_s* option, bool n_decoding) @@ -134,7 +128,7 @@ ri_rsc_category_e CResourceInfo::GetCapableVideoCategoryID(ri_video_property* pr ri_rsc_category_e category_id = GetCapableVideoCategoryID(prop->codec_name, prop->width, prop->height, prop->fps, prop->sampling_format, prop->color_depth, n_decoding); if (prop->detiled) return ToCategoryDedicatedToDetiled(category_id); - return (prop->progressive) ? ToCategoryDedicatedToProgressive(category_id):category_id; + return (prop->progressive) ? ToCategoryDedicatedToProgressive(category_id) :category_id; } ri_rsc_category_e CResourceInfo::ToCategoryDedicatedToProgressive(ri_rsc_category_e category_id) @@ -383,7 +377,7 @@ ri_color_depth CResourceInfo::GetColorDepthID(int color_depth, int sampling_form } else if (color_depth == 10) { //sampling_format, RI_SAMPLING_FORMAT_OTHERS return RI_COLOR_DEPTH_10BIT; } else { - RI_ERR("unknown color depth (%d)\n", color_depth); + RI_ERR("unknown color depth (%d)", color_depth); return (ri_color_depth)-1; } } @@ -399,7 +393,7 @@ ri_framerate CResourceInfo::GetFrameRateID(int framerate) } else if (IS_FRAMERATE_120P(framerate)) { framerate_e = RI_FRAMERATE_120; } else { - RI_ERR("unexpected frame rate (%d)\n", framerate); + RI_ERR("unexpected frame rate (%d)", framerate); } return framerate_e; diff --git a/src/CResourceInfoDB.cpp b/src/CResourceInfoDB.cpp index 9eeb617..8c61506 100644 --- a/src/CResourceInfoDB.cpp +++ b/src/CResourceInfoDB.cpp @@ -53,13 +53,6 @@ static pthread_mutex_t db_instance_mutex = PTHREAD_MUTEX_INITIALIZER; -CResourceInfoDB::CResourceInfoDB(void) -{ - m_system_bw = 0; -} - -CResourceInfoDB::~CResourceInfoDB(void){} - CResourceInfoDB* CResourceInfoDB::m_instance = NULL; CResourceInfoDB* CResourceInfoDB::GetInstance(void) @@ -367,7 +360,7 @@ const char *CResourceInfoDB::GetDeviceName(const int device_id) if (IsVirtualDeviceIdScaler(device_id)) { name = GetDeviceNameScaler(device_id); RI_INFO("DEVICE ID : %d, DEVICE NAME : %s", device_id, name.c_str()); - return strdup(name.c_str()); + return name.c_str(); } RI_INFO("[NULL] DEVICE ID : %d CANNOT GET NAME", device_id); diff --git a/src/CVideoCodec.cpp b/src/CVideoCodec.cpp index 5bfc224..cbc7af1 100644 --- a/src/CVideoCodec.cpp +++ b/src/CVideoCodec.cpp @@ -17,8 +17,8 @@ #include #include -CVideoCodec::CVideoCodec(const std::string name, const unsigned int resolution, const int fps, const bool support_2k_portrait):\ - name_(name), max_resolution_(resolution), max_fps_(fps), support_2k_portrait_(support_2k_portrait), vr360_codec_(false) +CVideoCodec::CVideoCodec(const std::string name, const unsigned int resolution, const int fps, const bool support_2k_portrait) + : name_(name), max_resolution_(resolution), max_fps_(fps), support_2k_portrait_(support_2k_portrait), vr360_codec_(false) { InitResolutions(); auto it = vr360_codecs_.find(name); diff --git a/src/CVideoResolution.cpp b/src/CVideoResolution.cpp index ca819c9..a58c306 100644 --- a/src/CVideoResolution.cpp +++ b/src/CVideoResolution.cpp @@ -39,7 +39,7 @@ static resolution_size_s default_size[] = { {7680, 4320, 4320, 7680} /** RI_RESOLUTION_8K_UHD */ }; -CVideoResolution::CVideoResolution(const unsigned int resolution):resolution_(resolution), w_(0), h_(0), wp_(0), hp_(0) +CVideoResolution::CVideoResolution(const unsigned int resolution) :resolution_(resolution), w_(0), h_(0), wp_(0), hp_(0) { if (!ValidResolution(resolution)) return; diff --git a/src/parser/CResourceTableProviderDefault.cpp b/src/parser/CResourceTableProviderDefault.cpp index e5469f3..170737d 100644 --- a/src/parser/CResourceTableProviderDefault.cpp +++ b/src/parser/CResourceTableProviderDefault.cpp @@ -19,10 +19,6 @@ #include #include -CResourceTableProviderDefault::CResourceTableProviderDefault(const int table_index, const int product_type, const bool support_android):table_index_(table_index), product_type_(product_type), support_android_(support_android) -{ -} - std::string CResourceTableProviderDefault::FindResourceTablePath(const std::map &table_paths, const int index) const { auto it = table_paths.find(index); diff --git a/src/parser/element/CCategoryElement.cpp b/src/parser/element/CCategoryElement.cpp index d4498e1..f74b770 100644 --- a/src/parser/element/CCategoryElement.cpp +++ b/src/parser/element/CCategoryElement.cpp @@ -24,9 +24,8 @@ CategoryElement::CategoryElement(char *category_name, char *category_type, int c m_element_name = category_name; m_element_type = category_type; m_class_id = class_id; - m_id = 0; - SetElementAttr(ELEMENT_CATEGORY); m_is_uhd_decoder = is_uhd_device; + SetElementAttr(ELEMENT_CATEGORY); } CategoryElement::~CategoryElement() @@ -65,6 +64,6 @@ void CategoryElement::PrintInfo(void) else device->PrintInfo(); } - RI_DBG("---------------------------------------------\n"); + RI_DBG("---------------------------------------------"); } // LCOV_EXCL_STOP diff --git a/src/parser/element/CElement.cpp b/src/parser/element/CElement.cpp index 335c088..f964a97 100644 --- a/src/parser/element/CElement.cpp +++ b/src/parser/element/CElement.cpp @@ -17,23 +17,8 @@ #include #include - -Element::Element(void):m_element_name(NULL), m_element_type(NULL), m_class_id(0) -{} - -Element::Element(char *element_name, char *element_type, int class_id, bool is_uhd_device) -:m_element_name(element_name), m_element_type(element_type), m_class_id(class_id), m_is_uhd_decoder(is_uhd_device) -{} - -Element::Element(char *element_name, char *element_type):m_element_name(element_name), m_element_type(element_type), m_class_id(0) -{} - -Element::Element(char *element_name):m_element_name(element_name), m_element_type(NULL), m_class_id(0) -{} - void Element::SetElementAttr(ri_element_attribute_e element_attr) { - //RI_DBG("[DEVICE ELEMENT] element attr : %s", element_attr); m_element_attr = element_attr; } diff --git a/src/parser/element/CResourceInfoDoc.cpp b/src/parser/element/CResourceInfoDoc.cpp index e5351c6..b91f055 100644 --- a/src/parser/element/CResourceInfoDoc.cpp +++ b/src/parser/element/CResourceInfoDoc.cpp @@ -83,8 +83,9 @@ void ResourceInfoDoc::PrintInfo(void) { RI_DBG("\n---------------- INFORMATION ----------------"); for (auto &it : category_elements_) { - CategoryElement* category = dynamic_cast(it); - category->PrintInfo(); + CategoryElement *category = dynamic_cast(it); + if (category) + category->PrintInfo(); } } // LCOV_EXCL_STOP diff --git a/src/parser/ri-resource-info-dbmaker.cpp b/src/parser/ri-resource-info-dbmaker.cpp index 8a2c8d5..67cca97 100644 --- a/src/parser/ri-resource-info-dbmaker.cpp +++ b/src/parser/ri-resource-info-dbmaker.cpp @@ -26,10 +26,10 @@ static void CopyToResourceCategory(CategoryElement* category_element, ri_resourc category->is_uhd_device = category_element->IsUHDDecoder(); char *category_name = category_element->GetElementName(); - category->name = (category_name == NULL) ? strndup("", strlen("")): strndup(category_name, strlen(category_name)); + category->name = (category_name == NULL) ? strndup("", strlen("")) : strndup(category_name, strlen(category_name)); char *codec_name = category_element->GetCodecName(); - category->codec = (codec_name == NULL) ? strndup("", strlen("")): strndup(codec_name, strlen(codec_name)); + category->codec = (codec_name == NULL) ? strndup("", strlen("")) : strndup(codec_name, strlen(codec_name)); } static void CopyToDevice(DeviceElement* dev_element, CategoryElement* category_element, ri_device_common_attr_s* device) @@ -47,7 +47,7 @@ static void CopyToDevice(DeviceElement* dev_element, CategoryElement* category_e device->audio_codec = dev_element->GetAudioCodec(); char *dev_name = dev_element->GetElementName(); - device->name = (dev_name == NULL) ? strndup("", strlen("")): strndup(dev_name, strlen(dev_name)); + device->name = (dev_name == NULL) ? strndup("", strlen("")) : strndup(dev_name, strlen(dev_name)); ri_mem_cluster_s* mem_info = dev_element->GetDeviceMemCluster(); @@ -79,7 +79,7 @@ static void CopyToDeviceUniqueAttritue(DeviceElement* dev_elem, CategoryElement* //RI_INFO("id(%d)/support_overlay(%d)/max_rez(%d)/max_sampling(%d)", attr->id, attr->support_overlay, attr->max_rez, attr->max_sampling_format); char *dev_name = dev_elem->GetElementName(); - attr->name = (dev_name == NULL) ? strndup("", strlen("")): strndup(dev_name, strlen(dev_name)); + attr->name = (dev_name == NULL) ? strndup("", strlen("")) : strndup(dev_name, strlen(dev_name)); } int ConstructResourceDB(void *InfoDB, std::vector* device_info) diff --git a/src/parser/ri-resource-info-parser.cpp b/src/parser/ri-resource-info-parser.cpp index fd5bc90..5718771 100644 --- a/src/parser/ri-resource-info-parser.cpp +++ b/src/parser/ri-resource-info-parser.cpp @@ -561,7 +561,7 @@ int ParseXMLFile(void* InfoDB) fileSize = m_GetXMLRawData(filename.c_str(), &xmlRawData); if (fileSize == -1) { - RI_ERR("fail to get XMLdata\n"); + RI_ERR("fail to get XMLdata"); if (xmlRawData) { free(xmlRawData); xmlRawData = NULL; @@ -613,7 +613,7 @@ int ParseXMLFile(void* InfoDB, const char *filename) int fileSize = 0; if (filename == NULL) { - printf("Invalid resource file path\n"); + RI_ERR("Invalid resource file path"); return -1; } @@ -624,7 +624,7 @@ int ParseXMLFile(void* InfoDB, const char *filename) fileSize = m_GetXMLRawData(filename, &xmlRawData); if (fileSize == -1) { - printf("fail to get XML data (%s)\n", filename); + RI_ERR("fail to get XML data (%s)", filename); //variable xmlRawData going out of scope leaks the storage it points to. if (xmlRawData) { @@ -729,7 +729,7 @@ int m_ParseResourceInfo(char *xmlRawData, int rawDataSize) xmlParser = XML_ParserCreate(NULL); if (!xmlParser) { - RI_ERR("parser create error\n"); + RI_ERR("parser create error"); return PARSE_ERROR; } @@ -737,7 +737,7 @@ int m_ParseResourceInfo(char *xmlRawData, int rawDataSize) XML_SetCharacterDataHandler (xmlParser, m_ProcessCharacterData); if (XML_Parse(xmlParser, xmlRawData, rawDataSize, 1) == XML_STATUS_ERROR) { - RI_ERR("Failed to parse xml data (Error from expat library)\n"); + RI_ERR("Failed to parse xml data (Error from expat library)"); return PARSE_ERROR; } @@ -998,29 +998,6 @@ void m_ProcessDeviceStartElement(const char **atts) int max_sampling_format = m_GetIntAttributeValue(atts, "max_format"); DeviceElement* pDeviceElement = new DeviceElement(device_name, pCategoryElement->GetElementType(), device_bw, mem_cluster_info, sharable_count, mixing, device_enum_type, is_main_device); - - if (pDeviceElement == NULL) { - RI_ERR("cannot get device element. Dev[%s]", device_name); - - if (device_name) { - free(device_name); - device_name = NULL; - } - - free(mem_cluster_info); - mem_cluster_info = NULL; - - if (omx) { - free(omx); - omx = NULL; - } - - if (audio_codec) - free(audio_codec); - - return; - } - pDeviceElement->SetElementID(g_ResourceID++); pDeviceElement->SetDevicePath(device_path); pDeviceElement->SetOmxCompName(omx); @@ -1112,6 +1089,9 @@ void m_ProcessVCodecStartElement(const char **atts, CResourceInfoDB* InfoDB) if (w_8k > 0 || h_8k > 0 || wp_8k > 0 || hp_8k > 0) InfoDB->Set8KSize(codec_name, w_8k, h_8k, wp_8k, hp_8k); + + if (codec_name) + free(codec_name); } void m_ProcessCategoryStartElement(const char **atts) @@ -1173,22 +1153,6 @@ void m_ProcessCategoryStartElement(const char **atts) /* Put the element into the Category Class */ CategoryElement* pCategoryElement = new CategoryElement(category_name, category_type, category_class_id, is_uhd); - - if (pCategoryElement == NULL) { - RI_ERR("cannot get category element. Cat[%s]", category_name); - - if (category_name) { - free(category_name); - category_name = NULL; - } - - if (category_type) { - free(category_type); - category_type = NULL; - } - return; - } - pCategoryElement->SetCategoryEnum(category_id); pCategoryElement->SetCodecName(codec_name); @@ -1235,7 +1199,7 @@ int m_GetStringAttributeValue(const char** atts, const char *attribute_name, cha *attribute_value = strndup(value, strlen(value)); - return (*attribute_value) ? PARSE_OK:PARSE_ERROR; + return (*attribute_value) ? PARSE_OK : PARSE_ERROR; } @@ -1243,7 +1207,7 @@ const char *m_GetAttributeValue(const char **atts, const char *attribute_name) { /* Attributes are passed to the start handler as a pointer to a vector of char pointers. - Each attribute seen in a start (or empty) tag occupies 2 consecutive places in this vector: the attribute name followed by the attribute value. + Each attribute seen in a start (or empty) tag occupies 2 consecutive places in this vector : the attribute name followed by the attribute value. These pairs are terminated by a null pointer. Note that an empty tag generates a call to both start and end handlers (in that order). */ diff --git a/src/ri-api.cpp b/src/ri-api.cpp index 4b1d06b..c63a625 100644 --- a/src/ri-api.cpp +++ b/src/ri-api.cpp @@ -154,6 +154,10 @@ ri_video_property_h ri_create_video_property(const char *vcodec, int w, int h, i RI_RETURN_NULL_IF_NULL(vcodec, "invalid param"); ri_video_property *prop = (ri_video_property*) calloc(1, sizeof(ri_video_property)); + + if (!prop) + return NULL; + prop->width = w; prop->height = h; prop->fps = fps; @@ -204,6 +208,10 @@ ri_rsc_category_e ri_get_capable_video_category(ri_video_property_h prop) ri_video_encoder_property_h ri_create_video_encoder_property(const int w, const int h, const int fps) { ri_video_encoder_property *prop = (ri_video_encoder_property*) calloc(1, sizeof(ri_video_encoder_property)); + + if (!prop) + return NULL; + prop->width = w; prop->height = h; prop->fps = fps; diff --git a/src/ri-video-capability.cpp b/src/ri-video-capability.cpp index 8ad9ce9..57c919d 100644 --- a/src/ri-video-capability.cpp +++ b/src/ri-video-capability.cpp @@ -32,7 +32,10 @@ ri_video_decoding_property_h ri_create_video_decoding_property(const char *codec } ri_video_decoding_property* prop = (ri_video_decoding_property*) calloc(1, sizeof(ri_video_decoding_property)); - prop->codec_name = strdup(codec_name); + + if (prop) + prop->codec_name = strdup(codec_name); + return prop; } @@ -111,6 +114,8 @@ int ri_get_dual_decoding_capability(const ri_video_decoding_property_h prop, ri_ for (auto it : capabilities) { ri_video_capability* capa = (ri_video_capability *) calloc(1, sizeof(ri_video_capability)); + if (!capa) + continue; capa->device_prop = (it->GetDeviceProperty().compare("main") == 0) ? RI_DEVICE_PROPERTY_MAIN : RI_DEVICE_PROPERTY_SUB; capa->width = it->GetWidth(); capa->height = it->GetHeight();