bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] test-parse-datetime.c: accommodate a relatively strict gcc warni


From: Jim Meyering
Subject: [PATCH] test-parse-datetime.c: accommodate a relatively strict gcc warning
Date: Wed, 31 Aug 2011 16:44:52 +0200

Using this new code in coreutils exposed a minor problem,
due to its use of -Werror=missing-declarations:

    test-parse-datetime.c:97:1: error: no previous declaration for \
      'gmt_offset' [-Werror=missing-declarations]
    cc1: all warnings being treated as errors

I fixed it and some style issues like this:

>From 8af631b398b3b97adc501810007d1d8eecffc8b0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 31 Aug 2011 16:43:29 +0200
Subject: [PATCH] test-parse-datetime.c: accommodate a relatively strict gcc
 warning

* tests/test-parse-datetime.c (gmt_offset): Declare function "static",
to avoid a warning from gcc's -Werror=missing-declarations.
Insert a few spaces-before-funcall-parenthesis.
---
 ChangeLog                   |    7 +++++++
 tests/test-parse-datetime.c |   18 +++++++++---------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b112f74..2c86304 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-08-31  Jim Meyering  <address@hidden>
+
+       test-parse-datetime.c: accommodate a relatively strict gcc warning
+       * tests/test-parse-datetime.c (gmt_offset): Declare function "static",
+       to avoid a warning from gcc's -Werror=missing-declarations.
+       Insert a few spaces-before-funcall-parenthesis.
+
 2011-08-17  J.T. Conklin  <address@hidden>

        parse-datetime: accept ISO 8601 date and time rep with "T" separator
diff --git a/tests/test-parse-datetime.c b/tests/test-parse-datetime.c
index 4cb85d5..ac408cc 100644
--- a/tests/test-parse-datetime.c
+++ b/tests/test-parse-datetime.c
@@ -36,7 +36,7 @@
 #define LOG(str, now, res) (void) 0
 #endif

-static const char* const day_table[] =
+static const char *const day_table[] =
 {
   "SUNDAY",
   "MONDAY",
@@ -93,21 +93,21 @@ tm_diff (struct tm const *a, struct tm const *b)
 }
 #endif /* ! HAVE_TM_GMTOFF */

-long
-gmt_offset()
+static long
+gmt_offset ()
 {
   time_t now;
   long gmtoff;

-  time(&now);
+  time (&now);

 #if !HAVE_TM_GMTOFF
-  struct tm tm_local = *localtime(&now);
-  struct tm tm_gmt   = *gmtime(&now);
+  struct tm tm_local = *localtime (&now);
+  struct tm tm_gmt   = *gmtime (&now);

-  gmtoff = tm_diff(&tm_local, &tm_gmt);
+  gmtoff = tm_diff (&tm_local, &tm_gmt);
 #else
-  gmtoff = localtime(&now)->tm_gmtoff;
+  gmtoff = localtime (&now)->tm_gmtoff;
 #endif

   return gmtoff;
@@ -126,7 +126,7 @@ main (int argc _GL_UNUSED, char **argv)

   set_program_name (argv[0]);

-  gmtoff = gmt_offset();
+  gmtoff = gmt_offset ();


   /* ISO 8601 extended date and time of day representation,
--
1.7.7.rc0.362.g5a14



reply via email to

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