From: Roland McGrath <roland@hack.frob.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: Re: [PATCH] libdwfl: Fix wrong type to make gcc -fsanitize=undefined happy.
Date: Tue, 21 Apr 2015 13:26:12 -0700 [thread overview]
Message-ID: <20150421202612.E9A172C3AC8@topped-with-meat.com> (raw)
In-Reply-To: 1429624875-19909-1-git-send-email-mjw@redhat.com
[-- Attachment #1: Type: text/plain, Size: 1911 bytes --]
I think it's cleaner to do:
[PATCH] libdwfl: Make dwfl_error.c C99-kosher.
Signed-off-by: Roland McGrath <roland@hack.frob.com>
---
libdwfl/ChangeLog | 7 +++++++
libdwfl/dwfl_error.c | 21 +++++++++++++++++----
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index d4cd3f5..045adb0 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,10 @@
+2015-04-21 Roland McGrath <roland@hack.frob.com>
+
+ * dwfl_error.c (struct msgtable): Break type definition out of
+ the 'msgtable' initializer.
+ (msgtable): Make it a union of struct msgtable and a char array.
+ (msgstr): Use the full-table char array rather than the msg_0 entry.
+
2015-04-02 Mark Wielaard <mjw@redhat.com>
* segment.c (insert): Check correct number of lookup_elts.
diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
index d9ca9e7..f46b160 100644
--- a/libdwfl/dwfl_error.c
+++ b/libdwfl/dwfl_error.c
@@ -1,5 +1,5 @@
/* Error handling in libdwfl.
- Copyright (C) 2005-2010 Red Hat, Inc.
+ Copyright (C) 2005-2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -54,18 +54,31 @@ dwfl_errno (void)
INTDEF (dwfl_errno)
-static const struct msgtable
+struct msgtable
{
#define DWFL_ERROR(name, text) char msg_##name[sizeof text];
DWFL_ERRORS
#undef DWFL_ERROR
+};
+
+static const union
+{
+ struct msgtable table;
+ char strings[
+#define DWFL_ERROR(name, text) sizeof text +
+ DWFL_ERRORS
+#undef DWFL_ERROR
+ + 0];
} msgtable =
{
+ .table =
+ {
#define DWFL_ERROR(name, text) text,
- DWFL_ERRORS
+ DWFL_ERRORS
#undef DWFL_ERROR
+ }
};
-#define msgstr (&msgtable.msg_NOERROR[0])
+#define msgstr (msgtable.strings)
static const uint_fast16_t msgidx[] =
{
next reply other threads:[~2015-04-21 20:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-21 20:26 Roland McGrath [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-05-06 20:50 Roland McGrath
2015-05-06 10:00 Mark Wielaard
2015-04-28 15:37 Mark Wielaard
2015-04-23 17:49 Mark Wielaard
2015-04-23 17:05 Roland McGrath
2015-04-23 17:04 Roland McGrath
2015-04-23 15:06 Alexander Cherepanov
2015-04-22 11:59 Mark Wielaard
2015-04-21 14:01 Mark Wielaard
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=20150421202612.E9A172C3AC8@topped-with-meat.com \
--to=roland@hack.frob.com \
--cc=elfutils-devel@lists.fedorahosted.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).