Check the return value of the gettimeofday() in 'jerry_port_get_time_zone' and 'jerry_port_get_current_time' functions.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
This commit is contained in:
Robert Sipka 2016-05-06 10:06:31 +02:00
parent 3de4170c15
commit 94161d350a
2 changed files with 9 additions and 3 deletions

View File

@ -65,5 +65,5 @@ int
gettimeofday (void *tp __attr_unused___, /**< struct timeval */
void *tzp __attr_unused___) /**< struct timezone */
{
return 0;
return -1;
} /* gettimeofday */

View File

@ -32,7 +32,10 @@ bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p)
tz.tz_minuteswest = 0;
tz.tz_dsttime = 0;
gettimeofday (&tv, &tz);
if (gettimeofday (&tv, &tz) != 0)
{
return false;
}
tz_p->offset = tz.tz_minuteswest;
tz_p->daylight_saving_time = tz.tz_dsttime > 0 ? 1 : 0;
@ -47,7 +50,10 @@ double jerry_port_get_current_time ()
{
struct timeval tv;
gettimeofday (&tv, NULL);
if (gettimeofday (&tv, NULL) != 0)
{
return 0;
}
return ((double) tv.tv_sec) * 1000.0 + ((double) tv.tv_usec) / 1000.0;
} /* jerry_port_get_current_time */