Cast "const char *" pointers to "char *" to avoid compiler warnings.
Christophe Lyon
christophe.lyon@linaro.org
Mon Oct 1 21:34:00 GMT 2018
Hi,
GCC complains that some assignments loose the const-ness of several
data. This small patch adds explicit (char *) casts, but I'm not
familiar enough with what newlib does with these to be sure that they
are not modified. Maybe the proper fix would be to declare the
destinations as "const"?
Christophe
-------------- next part --------------
commit 349a08c43cd4baf0d93f28ea8ca7351bf9606d50
Author: Christophe Lyon <christophe.lyon@linaro.org>
Date: Mon Oct 1 18:53:37 2018 +0000
Cast "const char *" pointers to "char *" to avoid compiler warnings.
2018-10-01 Christophe Lyon <christophe.lyon@linaro.org>
* newlib/libc/ctype/ctype_.c (__set_ctype): Cast "_ctype_" to "char *".
* newlib/libc/ctype/jp2uc.c (_jp2uc_l, _uc2jp_l): Cast output of
"__locale_charset()" and "__current_locale_charset()" to "char *".
* newlib/libc/locale/locale.c (__loadlocale): Cast "new_locale" to
"char *".
diff --git a/newlib/libc/ctype/ctype_.c b/newlib/libc/ctype/ctype_.c
index 28727e8..851fc06 100644
--- a/newlib/libc/ctype/ctype_.c
+++ b/newlib/libc/ctype/ctype_.c
@@ -176,7 +176,7 @@ __set_ctype (struct __locale_t *loc, const char *charset)
# if defined(ALLOW_NEGATIVE_CTYPE_INDEX)
ctype_ptr = _ctype_b;
# else
- ctype_ptr = _ctype_;
+ ctype_ptr = (char *) _ctype_;
# endif
}
# if defined(ALLOW_NEGATIVE_CTYPE_INDEX)
diff --git a/newlib/libc/ctype/jp2uc.c b/newlib/libc/ctype/jp2uc.c
index b89b5ea..00272eb 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();
+ char * cs = l ? (char *) __locale_charset(l) : (char *) __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();
+ char * cs = l ? (char *) __locale_charset(l) : (char *) __current_locale_charset();
if (0 == strcmp (cs, "JIS"))
c = __uc2jp (c, JP_JIS);
else if (0 == strcmp (cs, "SJIS"))
diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c
index 791a775..79da35f 100644
--- a/newlib/libc/locale/locale.c
+++ b/newlib/libc/locale/locale.c
@@ -515,7 +515,7 @@ restart:
}
# define FAIL goto restart
#else
- locale = new_locale;
+ locale = (char *) new_locale;
# define FAIL return NULL
#endif
More information about the Newlib
mailing list