Patches for various warnings in string/...

Freddie Chopin freddie_chopin@op.pl
Mon Sep 15 17:37:00 GMT 2014


Hello!

I attach 4 patches with a single ChangeLog entry for various warnings 
detected in string/ subfolder of newlib's libc. The changes are pretty 
trivial and self-explaining - I hope (;

Regards,
FCh
-------------- next part --------------
2014-09-15  Freddie Chopin  <freddie_chopin@op.pl>

	* libc/string/memccpy.c (memccpy): Fix warning about signed-unsigned
	comparison
	* libc/string/memchr.c (memchr): Ditto.
	* libc/string/memrchr.c (memrchr): Ditto.
	* libc/string/memset.c: (memset): Ditto.
	* libc/string/rawmemchr.c (rawmemchr): Ditto.
	* libc/string/local.h (__locale_cjk_lang): Fix "function declaration
	isn't a prototype" warning.
	* libc/string/strcasestr.c (strcasestr): Ditto.
	* libc/string/u_strerr.c (_user_strerror): Fix "unused parameter"
	warnings.
	* libc/string/rawmemchr.c (rawmemchr): Fix comment type
	"// ..." -> "/* ... */".
-------------- next part --------------
From f1eed1d6e0bca402567b0bbcec648221c2da0ce4 Mon Sep 17 00:00:00 2001
From: Freddie Chopin <freddie.chopin@gmail.com>
Date: Sat, 13 Sep 2014 10:15:50 +0200
Subject: [PATCH 1/4] libc/string/memccpy.c (memccpy): Fix warning about
 signed-unsigned comparison

libc/string/memchr.c (memchr): Ditto.
libc/string/memrchr.c (memrchr): Ditto.
libc/string/memset.c: (memset): Ditto.
libc/string/rawmemchr.c (rawmemchr): Ditto.
---
 newlib/libc/string/memccpy.c   | 2 +-
 newlib/libc/string/memchr.c    | 2 +-
 newlib/libc/string/memrchr.c   | 2 +-
 newlib/libc/string/memset.c    | 2 +-
 newlib/libc/string/rawmemchr.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/newlib/libc/string/memccpy.c b/newlib/libc/string/memccpy.c
index dded857..332ed46 100644
--- a/newlib/libc/string/memccpy.c
+++ b/newlib/libc/string/memccpy.c
@@ -98,7 +98,7 @@ _DEFUN (memccpy, (dst0, src0, endchar, len0),
      then punt into the byte copy loop.  This should be rare.  */
   if (!TOO_SMALL(len0) && !UNALIGNED (src, dst))
     {
-      int i;
+      unsigned int i;
       unsigned long mask = 0;
 
       aligned_dst = (long*)dst;
diff --git a/newlib/libc/string/memchr.c b/newlib/libc/string/memchr.c
index 13ed881..db0af7c 100644
--- a/newlib/libc/string/memchr.c
+++ b/newlib/libc/string/memchr.c
@@ -80,7 +80,7 @@ _DEFUN (memchr, (src_void, c, length),
 #if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
   unsigned long *asrc;
   unsigned long  mask;
-  int i;
+  unsigned int i;
 
   while (UNALIGNED (src))
     {
diff --git a/newlib/libc/string/memrchr.c b/newlib/libc/string/memrchr.c
index 42d9d14..60dee42 100644
--- a/newlib/libc/string/memrchr.c
+++ b/newlib/libc/string/memrchr.c
@@ -80,7 +80,7 @@ _DEFUN (memrchr, (src_void, c, length),
 #if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
   unsigned long *asrc;
   unsigned long  mask;
-  int i;
+  unsigned int i;
 
   while (UNALIGNED (src))
     {
diff --git a/newlib/libc/string/memset.c b/newlib/libc/string/memset.c
index ee91b05..b84e155 100644
--- a/newlib/libc/string/memset.c
+++ b/newlib/libc/string/memset.c
@@ -50,7 +50,7 @@ _DEFUN (memset, (m, c, n),
   char *s = (char *) m;
 
 #if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
-  int i;
+  unsigned int i;
   unsigned long buffer;
   unsigned long *aligned_addr;
   unsigned int d = c & 0xff;	/* To avoid sign extension, copy C to an
diff --git a/newlib/libc/string/rawmemchr.c b/newlib/libc/string/rawmemchr.c
index a9e2acd..9b711c4 100644
--- a/newlib/libc/string/rawmemchr.c
+++ b/newlib/libc/string/rawmemchr.c
@@ -77,7 +77,7 @@ _DEFUN (rawmemchr, (src_void, c),
 #if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
   unsigned long *asrc;
   unsigned long  mask;
-  int i;
+  unsigned int i;
 
   while (UNALIGNED (src))
     {
-- 
1.8.1.msysgit.1

-------------- next part --------------
From d0b41b24b965838e9d571369d7e770d4e184b9d5 Mon Sep 17 00:00:00 2001
From: Freddie Chopin <freddie.chopin@gmail.com>
Date: Sat, 13 Sep 2014 10:17:28 +0200
Subject: [PATCH 2/4] libc/string/local.h (__locale_cjk_lang): Fix "function
 declaration isn't a prototype" warning. libc/string/strcasestr.c
 (strcasestr): Ditto.

---
 newlib/libc/string/local.h      | 2 +-
 newlib/libc/string/strcasestr.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/newlib/libc/string/local.h b/newlib/libc/string/local.h
index dfe01d7..babaad0 100644
--- a/newlib/libc/string/local.h
+++ b/newlib/libc/string/local.h
@@ -6,7 +6,7 @@ int _EXFUN (__wcwidth, (wint_t));
 
 /* Defined in locale/locale.c.  Returns a value != 0 if the current
    language is assumed to use CJK fonts. */
-int __locale_cjk_lang ();
+int _EXFUN (__locale_cjk_lang, (void));
 
 /*
    Taken from glibc:
diff --git a/newlib/libc/string/strcasestr.c b/newlib/libc/string/strcasestr.c
index 1bde1cd..8fff00b 100644
--- a/newlib/libc/string/strcasestr.c
+++ b/newlib/libc/string/strcasestr.c
@@ -96,8 +96,9 @@ QUICKREF
  * Find the first occurrence of find in s, ignore case.
  */
 char *
-strcasestr(s, find)
-	const char *s, *find;
+_DEFUN (strcasestr, (s, find),
+	_CONST char *s _AND
+	_CONST char *find)
 {
 #if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
 
-- 
1.8.1.msysgit.1

-------------- next part --------------
From 6bc841fa5c6e7358c7818366d65582b90dd2ce3f Mon Sep 17 00:00:00 2001
From: Freddie Chopin <freddie.chopin@gmail.com>
Date: Sat, 13 Sep 2014 10:18:12 +0200
Subject: [PATCH 3/4] libc/string/u_strerr.c (_user_strerror): Fix "unused
 parameter" warnings.

---
 newlib/libc/string/u_strerr.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/newlib/libc/string/u_strerr.c b/newlib/libc/string/u_strerr.c
index 7d902fe..2978df0 100644
--- a/newlib/libc/string/u_strerr.c
+++ b/newlib/libc/string/u_strerr.c
@@ -6,5 +6,10 @@ _DEFUN(_user_strerror, (errnum, internal, errptr),
        int internal _AND
        int *errptr)
 {
+  /* prevent warning about unused parameters */
+  _CAST_VOID errnum;
+  _CAST_VOID internal;
+  _CAST_VOID errptr;
+
   return 0;
 }
-- 
1.8.1.msysgit.1

-------------- next part --------------
From ccb79eeba1244aa4d44082adaed2dc075d6af4a6 Mon Sep 17 00:00:00 2001
From: Freddie Chopin <freddie.chopin@gmail.com>
Date: Sat, 13 Sep 2014 10:27:13 +0200
Subject: [PATCH 4/4] libc/string/rawmemchr.c (rawmemchr): Fix comment type "//
 ..." -> "/* ... */".

---
 newlib/libc/string/rawmemchr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/newlib/libc/string/rawmemchr.c b/newlib/libc/string/rawmemchr.c
index 9b711c4..4b5a4cd 100644
--- a/newlib/libc/string/rawmemchr.c
+++ b/newlib/libc/string/rawmemchr.c
@@ -110,7 +110,7 @@ _DEFUN (rawmemchr, (src_void, c),
 
   src = (unsigned char *) asrc;
 
-#endif // !PREFER_SIZE_OVER_SPEED && !__OPTIMIZE_SIZE__
+#endif /* !PREFER_SIZE_OVER_SPEED && !__OPTIMIZE_SIZE__ */
 
   while (1)
     {
-- 
1.8.1.msysgit.1



More information about the Newlib mailing list