mv_barcode: code cleanup to mv_barcode_generate_open.cpp 37/282337/2
authorInki Dae <inki.dae@samsung.com>
Fri, 30 Sep 2022 03:02:52 +0000 (12:02 +0900)
committerInki Dae <inki.dae@samsung.com>
Fri, 30 Sep 2022 03:58:55 +0000 (12:58 +0900)
[Version]: 0.23.31-0
[Issue type] : code cleanup

Just drop unnecessary code and use LOGE instead of LOGW in case of an error.

Change-Id: I696731722df593527e92b58888f881177d9d8728
Signed-off-by: Inki Dae <inki.dae@samsung.com>
mv_barcode/barcode_generator/src/mv_barcode_generate_open.cpp
packaging/capi-media-vision.spec

index 17da765..c140bea 100644 (file)
@@ -246,40 +246,26 @@ int mv_barcode_generate_source_open(mv_engine_config_h engine_cfg, const char *m
        if (engine_cfg != NULL) {
                error = mv_engine_config_get_int_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_TEXT", &showText);
                if (error != MEDIA_VISION_ERROR_NONE) {
-                       LOGW("mv_engine_config_get_int_attribute failed");
+                       LOGE("mv_engine_config_get_int_attribute failed");
                        return error;
                }
 
                if (showText == BARCODE_GEN_TEXT_VISIBLE && type == MV_BARCODE_QR) {
-                       LOGW("QR code generation with visible text is not supported");
+                       LOGE("QR code generation with visible text is not supported");
                        return MEDIA_VISION_ERROR_INVALID_OPERATION;
                }
 
                /* set color value */
                error = mv_engine_config_get_string_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_COLOR_FRONT", &fgcolour);
                if (error != MEDIA_VISION_ERROR_NONE) {
-                       if (fgcolour) {
-                               free(fgcolour);
-                               fgcolour = NULL;
-                       }
-
-                       LOGW("mv_engine_config_get_string_attribute failed");
+                       LOGE("mv_engine_config_get_string_attribute failed");
                        return error;
                }
 
                error = mv_engine_config_get_string_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_COLOR_BACK", &bgcolour);
                if (error != MEDIA_VISION_ERROR_NONE) {
-                       if (bgcolour) {
-                               free(bgcolour);
-                               bgcolour = NULL;
-                       }
-
-                       if (fgcolour) {
-                               free(fgcolour);
-                               fgcolour = NULL;
-                       }
-
-                       LOGW("mv_engine_config_get_string_attribute failed");
+                       free(fgcolour);
+                       LOGE("mv_engine_config_get_string_attribute failed");
                        return error;
                }
 
@@ -309,22 +295,11 @@ int mv_barcode_generate_source_open(mv_engine_config_h engine_cfg, const char *m
                                                                                                          convertEncodingMode(qr_enc_mode), convertECC(qr_ecc), qr_version,
                                                                                                          showText, fgcolour, bgcolour);
 
-       if (fgcolour != NULL) {
-               free(fgcolour);
-               fgcolour = NULL;
-       }
-
-       if (bgcolour != NULL) {
-               free(bgcolour);
-               bgcolour = NULL;
-       }
+       free(fgcolour);
+       free(bgcolour);
 
        if (error != BARCODE_ERROR_NONE) {
                LOGE("Barcode generation to the buffer failed");
-               if (NULL != imageBuffer) {
-                       LOGI("Delete temporal buffer");
-                       delete[] imageBuffer;
-               }
                return convertBarcodeError(error);
        }
 
@@ -337,14 +312,11 @@ int mv_barcode_generate_source_open(mv_engine_config_h engine_cfg, const char *m
        error = mv_source_fill_by_buffer_c(image, imageBuffer, imageBufferSize, imageWidth, imageHeight,
                                                                           MEDIA_VISION_COLORSPACE_RGB888);
 
-       if (error != MEDIA_VISION_ERROR_NONE) {
+       if (error != MEDIA_VISION_ERROR_NONE)
                LOGE("Meidiavision source fill by generated buffer failed");
-       }
 
-       if (NULL != imageBuffer) {
-               LOGI("Delete temporal buffer");
-               delete[] imageBuffer;
-       }
+       // Delete temporal buffer.
+       delete[] imageBuffer;
 
        return error;
 }
@@ -385,40 +357,26 @@ int mv_barcode_generate_image_open(mv_engine_config_h engine_cfg, const char *me
                /* set visible text attribute */
                error = mv_engine_config_get_int_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_TEXT", &showText);
                if (error != MEDIA_VISION_ERROR_NONE) {
-                       LOGW("mv_engine_config_get_int_attribute failed");
+                       LOGE("mv_engine_config_get_int_attribute failed");
                        return error;
                }
 
                if (showText == BARCODE_GEN_TEXT_VISIBLE && type == MV_BARCODE_QR) {
-                       LOGW("QR code generation with visible text is not supported");
+                       LOGE("QR code generation with visible text is not supported");
                        return MEDIA_VISION_ERROR_INVALID_OPERATION;
                }
 
                /* set color value */
                error = mv_engine_config_get_string_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_COLOR_FRONT", &fgcolour);
                if (error != MEDIA_VISION_ERROR_NONE) {
-                       if (fgcolour) {
-                               free(fgcolour);
-                               fgcolour = NULL;
-                       }
-
-                       LOGW("mv_engine_config_get_string_attribute failed");
+                       LOGE("mv_engine_config_get_string_attribute failed");
                        return error;
                }
 
                error = mv_engine_config_get_string_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_COLOR_BACK", &bgcolour);
                if (error != MEDIA_VISION_ERROR_NONE) {
-                       if (bgcolour) {
-                               free(bgcolour);
-                               bgcolour = NULL;
-                       }
-
-                       if (fgcolour) {
-                               free(fgcolour);
-                               fgcolour = NULL;
-                       }
-
-                       LOGW("mv_engine_config_get_string_attribute failed");
+                       free(fgcolour);
+                       LOGE("mv_engine_config_get_string_attribute failed");
                        return error;
                }
 
@@ -448,15 +406,8 @@ int mv_barcode_generate_image_open(mv_engine_config_h engine_cfg, const char *me
                                                                                                         convertEncodingMode(qr_enc_mode), convertECC(qr_ecc), qr_version,
                                                                                                         showText, fgcolour, bgcolour);
 
-       if (fgcolour != NULL) {
-               free(fgcolour);
-               fgcolour = NULL;
-       }
-
-       if (bgcolour != NULL) {
-               free(bgcolour);
-               bgcolour = NULL;
-       }
+       free(fgcolour);
+       free(bgcolour);
 
        if (error != BARCODE_ERROR_NONE) {
                LOGE("Barcode generation to the image file failed");
index a93396f..529d0a1 100644 (file)
@@ -1,6 +1,6 @@
 Name:        capi-media-vision
 Summary:     Media Vision library for Tizen Native API
-Version:     0.23.30
+Version:     0.23.31
 Release:     0
 Group:       Multimedia/Framework
 License:     Apache-2.0 and BSD-3-Clause