Fix build warnings 14/126814/1
authorHyunjee Kim <hj0426.kim@samsung.com>
Tue, 25 Apr 2017 05:59:23 +0000 (14:59 +0900)
committerHyunjee Kim <hj0426.kim@samsung.com>
Tue, 25 Apr 2017 05:59:34 +0000 (14:59 +0900)
Change-Id: Ia895013e7a5bff9c8fcaeed0843f83e654da17f9
Signed-off-by: Hyunjee Kim <hj0426.kim@samsung.com>
CMakeLists.txt
i18ninfo/i18ninfo.c

index 1808f4b..20b3c5b 100755 (executable)
@@ -12,12 +12,12 @@ INCLUDE_DIRECTORIES(
        ${common_pkgs_INCLUDE_DIRS}
 )
 
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
 
 SET(common_pc_requires "capi-base-common")
-SET(common_libs 
+SET(common_libs
        ${common_pkgs_LDFLAGS}
 )
 
index 07bee02..b9cd2c1 100644 (file)
@@ -1,9 +1,10 @@
+#define _GNU_SOURCE 1
+#include <time.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
 #include <string.h>
 #include <assert.h>
-#include <time.h>
 #include "i18ninfo_argp.h"
 
 #include <utils_i18n.h>
@@ -35,7 +36,7 @@ static int ASCIIDOC_FLAG = 0;
 
 #define PRINT_ASCIIDOC_LOG(fmt) if (ASCIIDOC_FLAG) printf(fmt)
 
-char *default_locale = I18N_ULOCALE_UK;
+const char *default_locale = I18N_ULOCALE_UK;
 i18n_uchar default_timezone_id[BUF_SIZE] = {0,};
 
 i18n_udate_format_style_e eTimeFormatStyle[] = {
@@ -111,7 +112,7 @@ char *__print_i18n_type_string(char *type, int num)
 {
        char *str = calloc(300, sizeof(char));
        PRINT_DEBUG_LOG("input type: %s, num: %d\n", type, num);
-       if (type == "time") {
+       if (!strcmp(type, "time")) {
                switch (num) {
                case 0:
                        COPY_STR(str, "I18N_UDATE_FULL", strlen("I18N_UDATE_FULL"));
@@ -132,7 +133,7 @@ char *__print_i18n_type_string(char *type, int num)
                        COPY_STR(str, "err", strlen("err"));
                        break;
                }
-       } else if (type == "date") {
+       } else if (!strcmp(type, "date")) {
                switch (num) {
                case 0:
                        COPY_STR(str, "I18N_UDATE_FULL", strlen("I18N_UDATE_FULL"));
@@ -165,7 +166,7 @@ char *__print_i18n_type_string(char *type, int num)
                        COPY_STR(str, "err", strlen("err"));
                        break;
                }
-       } else if (type == "number_format") {
+       } else if (!strcmp(type, "number_format")) {
                switch (num) {
                case 1:
                        COPY_STR(str, "I18N_UNUMBER_DECIMAL", strlen("I18N_UNUMBER_DECIMAL"));
@@ -207,7 +208,7 @@ char *__print_i18n_type_string(char *type, int num)
                        COPY_STR(str, "err", strlen("err"));
                        break;
                }
-       } else if (type == "symbol") {
+       } else if (!strcmp(type, "symbol")) {
                switch (num) {
                case 1:
                        COPY_STR(str, "I18N_UNUMBER_DECIMAL_SEPARATOR_SYMBOL", strlen("I18N_UNUMBER_DECIMAL_SEPARATOR_SYMBOL"));
@@ -294,7 +295,7 @@ char *__print_i18n_type_string(char *type, int num)
                        COPY_STR(str, "err", strlen("err"));
                        break;
                }
-       } else if (type == "iter_type") {
+       } else if (!strcmp(type, "iter_type")) {
                switch (num) {
                case 0:
                        COPY_STR(str, "I18N_UBRK_CHARACTER", strlen("I18N_UBRK_CHARACTER"));
@@ -317,7 +318,7 @@ char *__print_i18n_type_string(char *type, int num)
        return str;
 }
 
-static const char *_date_basic_format_convert(char *input_pattern, int i, char *type)
+static char *_date_basic_format_convert(char *input_pattern, int i, char *type)
 {
        i18n_udate_format_h format_h = NULL;
        i18n_uchar timezone[BUF_SIZE] = {0,};
@@ -328,8 +329,8 @@ static const char *_date_basic_format_convert(char *input_pattern, int i, char *
 
        i18n_udate date_now = 259200000;
 
-       if (type == "day") date_now += i * 86400000;
-       else if (type == "month") {
+       if (!strcmp(type, "day")) date_now += i * 86400000;
+       else if (!strcmp(type, "month")) {
                int k;
                for (k = 0; k < i; k++)
                        date_now += 2678400000;
@@ -420,7 +421,6 @@ static int __get_date_basic_format()
 
 i18n_udate _time_convert(char *input_time)
 {
-       long long int lli;
        i18n_ucalendar_h ucal;
        i18n_udate date;
        int ret = I18N_ERROR_NONE;
@@ -465,6 +465,7 @@ static int __get_date_and_time(char *input_time)
        i18n_udate date_now;
        if (!input_time) {
                int error_code = i18n_ucalendar_get_now(&date_now);
+               CHECK_ERROR("i18n_ucalendar_get_now", error_code);
                PRINT_DEBUG_LOG("i18n_ucalendar_get_now = %lf\n", date_now);
        } else {
                date_now = _time_convert(input_time);
@@ -479,9 +480,11 @@ static int __get_date_and_time(char *input_time)
        i18n_uchar format[BUF_SIZE];
        i18n_ustring_copy_ua_n(format, "ddMMMyyyyHHmmssz", BUF_SIZE);
 
-       int pattern_len;
-       i18n_uchar pattern[BUF_SIZE];
-       error_code = i18n_udatepg_get_best_pattern(udatepg, I18N_UDATE_MONTH_DAY, BUF_SIZE, pattern, BUF_SIZE, &pattern_len);
+       int pattern_len, len;
+       i18n_uchar pattern[BUF_SIZE], skeleton[BUF_SIZE];
+       i18n_ustring_copy_ua(skeleton, I18N_UDATE_MONTH_DAY);
+       len = i18n_ustring_get_length(skeleton);
+       error_code = i18n_udatepg_get_best_pattern(udatepg, skeleton, len, pattern, BUF_SIZE, &pattern_len);
        CHECK_ERROR("i18n_udatepg_get_best_pattern", error_code);
 
        PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
@@ -697,7 +700,7 @@ static int __manage_string_iteration(char *input_string)
        i18n_ubreak_iterator_h boundary;
 
        if (!input_string) {
-               char *input_text = "Twinkle, twinkle, little star.\ How I wonder what you are";
+               char *input_text = "Twinkle, twinkle, little star. How I wonder what you are";
                printf("\nInput string : %s\n", input_text);
                string_to_examine =
                    (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1));
@@ -790,8 +793,6 @@ static int __analyze_string(char *custom_string)
                i18n_ustring_copy_ua(string_to_examine, input_text);
        }
 
-       int i;
-
        PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
        PRINT_ASCIIDOC_LOG("|===\n");
        printf("| KEY           | VALUE\n");
@@ -816,7 +817,7 @@ static int __analyze_string(char *custom_string)
        printf("| to lower      | %s\n", s);
 
        /* To title */
-       i18n_ustring_to_title_new(dest, BUF_SIZE + 1, string_to_examine, BUF_SIZE, NULL, &error_code);
+       i18n_ustring_to_title_new(dest, BUF_SIZE + 1, string_to_examine, BUF_SIZE, NULL, NULL);
        CHECK_ERROR("i18n_ustring_to_title_new", error_code);
        i18n_ustring_copy_au(s, dest);
        printf("| To Title      | %s\n", s);
@@ -864,7 +865,6 @@ static int __get_timezone_info()
         * local standard time to get the local wall clock time.
         */
        int32_t dst_savings;
-       char ms[BUF_SIZE];
        error_code = i18n_timezone_get_dst_savings(tmz, &dst_savings);
        CHECK_ERROR("i18n_timezone_get_dst_savings", error_code);
        printf("| DST savings in [min]   | %d\n", dst_savings / MS_TO_MIN);
@@ -1156,8 +1156,6 @@ void testStringIter(char *input)
 
 int main(int argc, char *argv[])
 {
-       int ret = 0, i = 0;
-
        struct arguments arguments = {0,};
 
        init_env();