lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] use of struct timeval in sys_jiffies, UNIX port


From: steinarl
Subject: [lwip-users] use of struct timeval in sys_jiffies, UNIX port
Date: Thu, 19 Jun 2008 16:37:30 +0200
User-agent: Internet Messaging Program (IMP) H3 (4.1.5)

My compiler complained about tv.tv_sec being used before it was
initialized, and upon inspection I must say I don't really understand
what is happening.

Depending on the compiler, isn't the value of tv_sec at best
initialized to zero, otherwise unpredictable? And the result from gettimeofday is not used for anything?

 From sys_arch.c, UNIX port, latest version in CVS.

unsigned long
sys_jiffies(void)
{
     struct timeval tv;
     unsigned long sec = tv.tv_sec;
     long usec = tv.tv_usec;

     gettimeofday(&tv,NULL);

     if (sec >= (MAX_JIFFY_OFFSET / HZ))
        return MAX_JIFFY_OFFSET;
     usec += 1000000L / HZ - 1;
     usec /= 1000000L / HZ;
     return HZ * sec + usec;
}






reply via email to

[Prev in Thread] Current Thread [Next in Thread]