Rearrange the scope of each temporary variables
[platform/core/uifw/voice-control.git] / common / vc_command.c
index 1c63b22..e6b5767 100644 (file)
@@ -1763,8 +1763,6 @@ static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist)
        int hour = -1;
        int min = -1;
 
-       char *tempstr = NULL;
-
        *exist = 0;
        ret = regexec(&reg[3], str, 1, pmatch, 0);
        if (0 == ret) {
@@ -1782,7 +1780,7 @@ static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist)
                                SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid string length");
                                return VC_ERROR_OPERATION_FAILED;
                        }
-                       tempstr = strndup(str + pmatch[1].rm_so, (size_t)len);
+                       char *tempstr = strndup(str + pmatch[1].rm_so, (size_t)len);
 
                        if (NULL == tempstr) {
                                SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed");
@@ -1808,7 +1806,7 @@ static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist)
                                SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid string length");
                                return VC_ERROR_OPERATION_FAILED;
                        }
-                       tempstr = strndup(str + pmatch[1].rm_so, (size_t)len);
+                       char *tempstr = strndup(str + pmatch[1].rm_so, (size_t)len);
 
                        if (NULL == tempstr) {
                                SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed");
@@ -1861,7 +1859,6 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist)
        int min = -1;
        int sidx = -1;
        int eidx = -1;
-       char *tempstr = NULL;
 
        *exist = 0;
        ret = regexec(&reg[0], str, 5, pmatch, 0);
@@ -1882,7 +1879,7 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist)
                        SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid string length");
                        return VC_ERROR_OPERATION_FAILED;
                }
-               tempstr = strndup(str + pmatch[1].rm_so, (size_t)len);
+               char *tempstr = strndup(str + pmatch[1].rm_so, (size_t)len);
 
                if (NULL == tempstr) {
                        SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed");
@@ -1922,7 +1919,7 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist)
                idx = 1;
                len = pmatch[idx].rm_eo - pmatch[idx].rm_so;
                if (0 < len) {
-                       tempstr = strndup(str + pmatch[idx].rm_so, (size_t)len);
+                       char *tempstr = strndup(str + pmatch[idx].rm_so, (size_t)len);
 
                        if (NULL == tempstr) {
                                SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed");