This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cast "const char *" pointers to "char *" to avoid compiler warnings.


On Thu, 11 Oct 2018 at 09:11, Corinna Vinschen <vinschen@redhat.com> wrote:
>
> On Oct 10 22:37, Christophe Lyon wrote:
> > On Wed, 10 Oct 2018 at 17:02, Corinna Vinschen <vinschen@redhat.com> wrote:
> > >
> > > On Oct 10 16:37, Christophe Lyon wrote:
> > > > And I think my patch (or something similar) is still needed for jp2uc.c ?
> > >
> > > I only had a look into the __loadlocal issue due to this discussion.
> > > For everything else, please send a new patch.
> > >
> >
> > OK, here is the patch for jp2uc.c:
>
> Can you please send it in `git format-patch' format?  The patch
> doesn't apply as is.  There's also no requirement anymore to add
> CVS-like commit messages.
>

Is this new version OK?

>
> Thanks,
> Corinna
>
> --
> Corinna Vinschen
> Cygwin Maintainer
> Red Hat
From dfb509574e1cbbdf4fe9d4d3e8319bd3ffdca98c Mon Sep 17 00:00:00 2001
From: Christophe Lyon <christophe.lyon@linaro.org>
Date: Fri, 5 Oct 2018 09:11:05 +0000
Subject: [PATCH] newlib/libc/ctype/jp2uc.c: Declare "cs" variable as "const
 char *"

Instead of "char *" to avoid compiler warnings.
This is OK because "cs" is only used as input of strcmp.
---
 newlib/libc/ctype/jp2uc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/ctype/jp2uc.c b/newlib/libc/ctype/jp2uc.c
index b89b5ea..5e30f09 100644
--- a/newlib/libc/ctype/jp2uc.c
+++ b/newlib/libc/ctype/jp2uc.c
@@ -166,7 +166,7 @@ __uc2jp (wint_t c, int type)
 wint_t
 _jp2uc_l (wint_t c, struct __locale_t * l)
 {
-  char * cs = l ? __locale_charset(l) : __current_locale_charset();
+  const char * cs = l ? __locale_charset(l) : __current_locale_charset();
   if (0 == strcmp (cs, "JIS"))
     c = __jp2uc (c, JP_JIS);
   else if (0 == strcmp (cs, "SJIS"))
@@ -186,7 +186,7 @@ _jp2uc (wint_t c)
 wint_t
 _uc2jp_l (wint_t c, struct __locale_t * l)
 {
-  char * cs = l ? __locale_charset(l) : __current_locale_charset();
+  const char * cs = l ? __locale_charset(l) : __current_locale_charset();
   if (0 == strcmp (cs, "JIS"))
     c = __uc2jp (c, JP_JIS);
   else if (0 == strcmp (cs, "SJIS"))
-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]