mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] syslog.h: fix warning "initialization discards 'const' qualifier from pointer target type"
@ 2017-08-16  9:18 Denys Vlasenko
  2017-08-16 13:24 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Denys Vlasenko @ 2017-08-16  9:18 UTC (permalink / raw)
  To: Rich Felker; +Cc: Denys Vlasenko, musl

This happens when syslog.h is included with "#define SYSLOG_NAMES 1"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
CC: musl@lists.openwall.com
---
 include/syslog.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/syslog.h b/include/syslog.h
index 5b4d296..25eb3e4 100644
--- a/include/syslog.h
+++ b/include/syslog.h
@@ -70,7 +70,7 @@ void vsyslog (int, const char *, va_list);
 #define	INTERNAL_NOPRI 0x10
 #define	INTERNAL_MARK (LOG_NFACILITIES<<3)
 typedef struct {
-	char *c_name;
+	const char *c_name;
 	int c_val;
 } CODE;
 #define prioritynames ((CODE *)(const CODE []){ \
-- 
2.9.2



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] syslog.h: fix warning "initialization discards 'const' qualifier from pointer target type"
  2017-08-16  9:18 [PATCH] syslog.h: fix warning "initialization discards 'const' qualifier from pointer target type" Denys Vlasenko
@ 2017-08-16 13:24 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2017-08-16 13:24 UTC (permalink / raw)
  To: musl

On Wed, Aug 16, 2017 at 11:18:37AM +0200, Denys Vlasenko wrote:
> This happens when syslog.h is included with "#define SYSLOG_NAMES 1"
> 
> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
> CC: musl@lists.openwall.com
> ---
>  include/syslog.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/syslog.h b/include/syslog.h
> index 5b4d296..25eb3e4 100644
> --- a/include/syslog.h
> +++ b/include/syslog.h
> @@ -70,7 +70,7 @@ void vsyslog (int, const char *, va_list);
>  #define	INTERNAL_NOPRI 0x10
>  #define	INTERNAL_MARK (LOG_NFACILITIES<<3)
>  typedef struct {
> -	char *c_name;
> +	const char *c_name;
>  	int c_val;
>  } CODE;
>  #define prioritynames ((CODE *)(const CODE []){ \
> -- 
> 2.9.2

This is not the right fix; it changes the type of a struct member
that's a public interface and thereby invalidates correct code that
was using it.

The cause is a bug (#61579) in GCC whereby -Wwrite-strings changes the
language semantics (changes the type of string literals) rather than
just generating a warning. Removing this option will fix it.

However there are other reasons that having the names done with a
compound literal rather than an external symbol is a bad idea (and
contributing significant size waste to busybox, IIRC), and I suspect
the right fix will make your problem go away too.

Rich


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-16 13:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-16  9:18 [PATCH] syslog.h: fix warning "initialization discards 'const' qualifier from pointer target type" Denys Vlasenko
2017-08-16 13:24 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).