From e6db777a99ddd03fdaff7f24cd4bf55fa597b8c6 Mon Sep 17 00:00:00 2001 From: hj kim Date: Mon, 16 Sep 2019 11:22:35 +0900 Subject: [PATCH] Update code for checking input parameter Change-Id: I86146cc21aabea5c48b9dc26cac0bbb6ce49338d --- src/metadata_editor.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index be3c632..33f86ac 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -778,8 +778,7 @@ int __metadata_editor_get_picture_info(const char *path, void **picture, int *si // *** This function is used to allocate the metadata_editor_s in memory *** // // *** The structure metadata_editor_s contains all information about the file *** // extern "C" int metadata_editor_create(metadata_editor_h *metadata) { - // Check if we have a valid argument to work with - metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); + metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata"); metadata_editor_s *_metadata = new metadata_editor_s; // Allocate a structure for handler metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); @@ -798,8 +797,8 @@ extern "C" int metadata_editor_create(metadata_editor_h *metadata) { // *** This function is used to open the file. It creates the instance that is responsible for connection with file *** // extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char *path) { // Check if we have valid arguments to work with - metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Handle"); - metadata_editor_retvm_if(path == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Handle"); + metadata_editor_retvm_if(!metadata, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata"); + metadata_editor_retvm_if(!path, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid path"); int exist; @@ -1728,12 +1727,11 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const int size = 0; char *type = NULL; - metadata_editor_retvm_if(path == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); - metadata_editor_s* _metadata = (metadata_editor_s*) metadata; ret = __check_metadata_set_parameter(_metadata); metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret); + metadata_editor_retvm_if(!path, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid path"); ret = __metadata_editor_get_picture_info(path, &picture, &size, &type); metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); @@ -1992,10 +1990,8 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in // *** This function is used to free memory that was allocated with metadata_editor_create(...) and metadata_editor_set_path(...) functions *** // extern "C" int metadata_editor_destroy(metadata_editor_h metadata) { - // Check if we have a valid argument to work with - metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); - metadata_editor_s *_metadata = (metadata_editor_s*)metadata; + metadata_editor_retvm_if(!_metadata, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata"); switch (_metadata->filetype) { case METADATA_EDITOR_FORMAT_MP3: { -- 2.7.4