Project

General

Profile

Bug #714

gettimeofday uses a deprecated structure

Added by Victor Rosales over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
High
Category:
mdrun
Target version:
-
Affected version - extra info:
4.5.3
Affected version:
Difficulty:
uncategorized
Close

Description

Files:
- src/tools/gmx_tune_pme.c +1917
- src/mdlib/sim_util.c +115

Both use

    ...
    struct timezone tz = { 0,0 };
    double seconds;

    gettimeofday(&t,&tz);
    ...

While the documentation1 of gettimeofday() states that timezone structure
is deprecated and should not be used.

This issue manifest the next compiling error:

...
sim_util.c: In function 'gmx_gettime':
sim_util.c:115: error: variable 'tz' has initializer but incomplete type
sim_util.c:115: warning: excess elements in struct initializer
sim_util.c:115: warning: (near initialization for 'tz')
sim_util.c:115: warning: excess elements in struct initializer
sim_util.c:115: warning: (near initialization for 'tz')
sim_util.c:115: error: storage size of 'tz' isn't known
make[3]: *** [sim_util.lo] Error 1
...

The next patch fix this issue:

[icr@opensrc gromacs-4.5.3]$ diff -Naur ../gromacs-4.5.31/src/mdlib/sim_util.c src/mdlib/sim_util.c
--- ../gromacs-4.5.31/src/mdlib/sim_util.c      2011-02-28 15:55:07.000000000 -0200
+++ src/mdlib/sim_util.c        2010-09-29 08:35:05.000000000 -0300
@@ -112,9 +112,10 @@
 {
 #ifdef HAVE_GETTIMEOFDAY
        struct timeval t;
+       struct timezone tz = { 0,0 };
        double seconds;

-       gettimeofday(&t,NULL);
+       gettimeofday(&t,&tz);

        seconds = (double) t.tv_sec + 1e-6*(double)t.tv_usec;

[icr@opensrc gromacs-4.5.3]$ diff -Naur ../gromacs-4.5.31/src/tools/gmx_tune_pme.c src/tools/gmx_tune_pme.c
--- ../gromacs-4.5.31/src/tools/gmx_tune_pme.c  2011-02-28 15:54:49.000000000 -0200
+++ src/tools/gmx_tune_pme.c    2010-09-29 08:35:06.000000000 -0300
@@ -1914,9 +1914,10 @@
 {
 #ifdef HAVE_GETTIMEOFDAY
     struct timeval t;
+    struct timezone tz = { 0,0 };
     double seconds;

-    gettimeofday(&t,NULL);
+    gettimeofday(&t,&tz);

     seconds = (double) t.tv_sec + 1e-6*(double)t.tv_usec;

[1] - http://www.gnu.org/s/libc/manual/html_node/High_002dResolution-Calendar.html

Associated revisions

Revision 47eef81f (diff)
Added by Carsten Kutzner over 8 years ago

Fixed bug #714: deprecated structure in gettimeofday

History

#1 Updated by Carsten Kutzner over 8 years ago

  • Category changed from build system to mdrun
  • Status changed from New to 3
  • Assignee set to Carsten Kutzner
  • % Done changed from 0 to 100

#2 Updated by Carsten Kutzner over 8 years ago

  • Status changed from 3 to Closed

Also available in: Atom PDF