public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] strstr: avoid warnings
Date: Fri,  3 Sep 2021 10:52:58 +0000 (GMT)	[thread overview]
Message-ID: <20210903105258.2C38E385840F@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c2fe205b508c32117d2d0f132953d096254d5a7b

commit c2fe205b508c32117d2d0f132953d096254d5a7b
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Fri Sep 3 12:51:30 2021 +0200

    strstr: avoid warnings
    
    unused function warning for two_way_short_needle,
    different char type warnings for standard string functions
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 newlib/libc/string/str-two-way.h |  4 ++--
 newlib/libc/string/strstr.c      | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/newlib/libc/string/str-two-way.h b/newlib/libc/string/str-two-way.h
index 90345a8de..e13f94907 100644
--- a/newlib/libc/string/str-two-way.h
+++ b/newlib/libc/string/str-two-way.h
@@ -195,7 +195,7 @@ critical_factorization (const unsigned char *needle, size_t needle_len,
    most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching.
    If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
    HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching.  */
-static RETURN_TYPE
+static RETURN_TYPE __attribute__ ((__used__))
 two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
 		      const unsigned char *needle, size_t needle_len)
 {
@@ -289,7 +289,7 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
    If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
    HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and
    sublinear performance is not possible.  */
-_NOINLINE_STATIC RETURN_TYPE
+_NOINLINE_STATIC RETURN_TYPE __attribute__ ((__used__))
 two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
 		     const unsigned char *needle, size_t needle_len)
 {
diff --git a/newlib/libc/string/strstr.c b/newlib/libc/string/strstr.c
index 00fe060e9..84e4632f1 100644
--- a/newlib/libc/string/strstr.c
+++ b/newlib/libc/string/strstr.c
@@ -90,7 +90,7 @@ strstr (const char *hs, const char *ne)
 
 # define RETURN_TYPE char *
 # define AVAILABLE(h, h_l, j, n_l) (((j) <= (h_l) - (n_l)) \
-   || ((h_l) += strnlen ((h) + (h_l), (n_l) | 2048), ((j) <= (h_l) - (n_l))))
+   || ((h_l) += strnlen ((const char *) (h) + (h_l), (n_l) | 2048), ((j) <= (h_l) - (n_l))))
 
 # include "str-two-way.h"
 
@@ -151,7 +151,7 @@ strstr (const char *haystack, const char *needle)
   if (ne[0] == '\0')
     return (char *) hs;
   if (ne[1] == '\0')
-    return (char*)strchr (hs, ne[0]);
+    return (char*)strchr ((const char *) hs, ne[0]);
   if (ne[2] == '\0')
     return strstr2 (hs, ne);
   if (ne[3] == '\0')
@@ -159,8 +159,8 @@ strstr (const char *haystack, const char *needle)
   if (ne[4] == '\0')
     return strstr4 (hs, ne);
 
-  size_t ne_len = strlen (ne);
-  size_t hs_len = strnlen (hs, ne_len | 512);
+  size_t ne_len = strlen ((const char *) ne);
+  size_t hs_len = strnlen ((const char *) hs, ne_len | 512);
 
   /* Ensure haystack length is >= needle length.  */
   if (hs_len < ne_len)
@@ -191,7 +191,7 @@ strstr (const char *haystack, const char *needle)
 	    }
 	  if (end[ne_len] == 0)
 	    return NULL;
-	  end += strnlen (end + ne_len, 2048);
+	  end += strnlen ((const char *) (end + ne_len), 2048);
 	}
       while (hs <= end);


                 reply	other threads:[~2021-09-03 10:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210903105258.2C38E385840F@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=newlib-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).