Remove a remaining warning from GCC-9 32/222432/1 accepted/tizen/unified/20200116.101824 submit/tizen/20200115.023341
authorKiseok Chang <kiso.chang@samsung.com>
Wed, 15 Jan 2020 02:23:32 +0000 (11:23 +0900)
committerKiseok Chang <kiso.chang@samsung.com>
Wed, 15 Jan 2020 02:23:32 +0000 (11:23 +0900)
     - 'format-truncation' warnings

Change-Id: Ib4c8f0c75d15aa9a15b49ebd70a05f1f1ad1e0ad

setting-time/src/setting-time-main.c

index c982c02fc8ae00ddd9be0672f2828fd286e2e331..0acb1e953c74307750dab79a19d0b81c5ec9294e 100755 (executable)
@@ -1548,11 +1548,13 @@ static void get_gmt_offset(char *str_buf, int size)
        int gmtoffset_hour = (pdata->tm_gmtoff) / 3600; /* result: hour */
        int gmtoffset_min = ((pdata->tm_gmtoff) % 3600) / 60; /* result: min */
 
-       snprintf(str_buf, size, "%+d:%02d", gmtoffset_hour, abs(gmtoffset_min));
+       int ret = snprintf(str_buf, size, "%+d:%02d", gmtoffset_hour, abs(gmtoffset_min));
+       if(ret >= size)
+               str_buf[size - 1] = '\0';
        SETTING_TRACE_DEBUG("szTimezone is of a valid format: GMT: %s",
                        str_buf);
 
-       int ret = vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_INT, str_buf);
+       ret = vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_INT, str_buf);
        if (ret == -1)
                SETTING_TRACE_ERROR("set vconf failed");
 }