Fix some warnings in time sources
Freddie Chopin
freddie_chopin@op.pl
Wed Sep 3 18:16:00 GMT 2014
Patches and ChangeLog entry attached.
Regards,
FCh
-------------- next part --------------
2014-09-03 Freddie Chopin <freddie_chopin@op.pl>
* libc/time/clock.c (clock): Fix warnings about signed-unsigned
comparisons.
* libc/time/strftime.c (strftime): Likewise.
* libc/time/strptime.c (match_string): Fix warning about discarding
'restrict' qualifier from pointer target type.
-------------- next part --------------
From 64bf9acee35a830268c6e09b3ecb04b591ea8407 Mon Sep 17 00:00:00 2001
From: Freddie Chopin <freddie.chopin@gmail.com>
Date: Wed, 3 Sep 2014 20:06:51 +0200
Subject: [PATCH 1/2] libc/time/clock.c, libc/time/strftime.c: fix "comparison
between signed and unsigned integer expressions" warnings
---
newlib/libc/time/clock.c | 2 +-
newlib/libc/time/strftime.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/newlib/libc/time/clock.c b/newlib/libc/time/clock.c
index 64cf438..0bcfbb6 100644
--- a/newlib/libc/time/clock.c
+++ b/newlib/libc/time/clock.c
@@ -59,7 +59,7 @@ clock ()
struct tms tim_s;
clock_t res;
- if ((res = (clock_t) _times_r (_REENT, &tim_s)) != -1)
+ if ((res = (clock_t) _times_r (_REENT, &tim_s)) != (clock_t) -1)
res = (clock_t) (tim_s.tms_utime + tim_s.tms_stime +
tim_s.tms_cutime + tim_s.tms_cstime);
diff --git a/newlib/libc/time/strftime.c b/newlib/libc/time/strftime.c
index f95a85d..9bdde82 100644
--- a/newlib/libc/time/strftime.c
+++ b/newlib/libc/time/strftime.c
@@ -694,12 +694,12 @@ _DEFUN (strftime, (s, maxsize, format, tim_p),
#endif /* !_WANT_C99_TIME_FORMATS */
{
size_t count = 0;
- int i, len = 0;
+ int len = 0;
const CHAR *ctloc;
#if defined (MAKE_WCSFTIME) && !defined (__HAVE_LOCALE_INFO_EXTENDED__)
CHAR ctlocbuf[CTLOCBUFLEN];
#endif
- size_t ctloclen;
+ size_t i, ctloclen;
CHAR alt;
CHAR pad;
unsigned long width;
@@ -1299,7 +1299,7 @@ recurse:
case CQ('Z'):
if (tim_p->tm_isdst >= 0)
{
- int size;
+ size_t size;
TZ_LOCK;
size = strlen(_tzname[tim_p->tm_isdst > 0]);
for (i = 0; i < size; i++)
--
1.8.1.msysgit.1
-------------- next part --------------
From aef671536ee6833b2257c207c6beb247c4bdd8a8 Mon Sep 17 00:00:00 2001
From: Freddie Chopin <freddie.chopin@gmail.com>
Date: Wed, 3 Sep 2014 20:10:31 +0200
Subject: [PATCH 2/2] libc/time/strptime.c (match_string): add __restrict
keyword to fix "passing argument 1 of 'match_string' discards 'restrict'
qualifier from pointer target type" warning
---
newlib/libc/time/strptime.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/newlib/libc/time/strptime.c b/newlib/libc/time/strptime.c
index d7dd7a2..19b9fce 100644
--- a/newlib/libc/time/strptime.c
+++ b/newlib/libc/time/strptime.c
@@ -68,7 +68,7 @@ is_leap_year (int year)
/* Needed for strptime. */
static int
-match_string (const char **buf, const char **strs)
+match_string (const char *__restrict *buf, const char **strs)
{
int i = 0;
--
1.8.1.msysgit.1
More information about the Newlib
mailing list