]> granicus.if.org Git - sysstat/commitdiff
Use NULL as an argument for time() system call
authorSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 5 Jun 2020 15:45:22 +0000 (17:45 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 5 Jun 2020 15:45:22 +0000 (17:45 +0200)
According to the time(2) manual page, the argument passed to time()
system call is obsolescent and should always be NULL in new code.
When this argument is NULL, the call cannot fail.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
common.c
systest.c
systest.h
tests/12.0.1/common.c

index c30bdc8b73ef7a3aa11b43b8c776fe0260668746..c086f1387d8dd45a5b3a00ea392e430202cda6d9 100644 (file)
--- a/common.c
+++ b/common.c
@@ -99,7 +99,7 @@ time_t get_localtime(struct tm *rectime, int d_off)
 {
        time_t timer;
 
-       __time(&timer);
+       timer = __time(NULL);
        timer -= SEC_PER_DAY * d_off;
        localtime_r(&timer, rectime);
 
@@ -124,7 +124,7 @@ time_t get_gmtime(struct tm *rectime, int d_off)
 {
        time_t timer;
 
-       __time(&timer);
+       timer = __time(NULL);
        timer -= SEC_PER_DAY * d_off;
        gmtime_r(&timer, rectime);
 
index 088596ccb970ae1a0365a726d6865b93e4d239a6..0f60d820111b2a07a346cb55b6460e211d7ca761 100644 (file)
--- a/systest.c
+++ b/systest.c
@@ -48,13 +48,13 @@ extern int sigint_caught;
  * Test mode: Instead of reading system time, use time given on the command
  * line.
  *
- * OUT:
- * @t  Number of seconds since the epoch, as given on the command line.
+ * RETURNS:
+ * Number of seconds since the epoch, as given on the command line.
  ***************************************************************************
  */
-void get_unix_time(time_t *t)
+time_t get_unix_time(time_t *t)
 {
-       *t = __unix_time;
+       return __unix_time;
 }
 
 /*
index f0fe4d2e94f4e314a2b0d7f2a504e80919858de4..c9ad26564a0cd5133ee2d09708494d370ca06bef 100644 (file)
--- a/systest.h
+++ b/systest.h
@@ -78,7 +78,7 @@ char *get_realname
        (char *, char *);
 void get_uname
        (struct utsname *);
-void get_unix_time
+time_t get_unix_time
        (time_t *);
 struct passwd *get_usrname
        (uid_t);
index b623a4c8b9d3e9223eced398db5f72c2d5ad2b78..5406fc6824161012860eb7f7c0bbdf7d38ee3ade 100644 (file)
@@ -99,7 +99,7 @@ time_t get_localtime(struct tm *rectime, int d_off)
        time_t timer;
        struct tm *ltm;
 
-       time(&timer);
+       timer = time(NULL);
        timer -= SEC_PER_DAY * d_off;
        ltm = localtime(&timer);
 
@@ -128,7 +128,7 @@ time_t get_gmtime(struct tm *rectime, int d_off)
        time_t timer;
        struct tm *ltm;
 
-       time(&timer);
+       timer = time(NULL);
        timer -= SEC_PER_DAY * d_off;
        ltm = gmtime(&timer);