From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Mark Wielaard <mark@klomp.org>, "Frank Ch . Eigler" <fche@redhat.com>
Cc: elfutils-devel@sourceware.org, Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH v3 2/4] printversion: Fix unused variable
Date: Mon, 13 Feb 2023 17:45:49 +0100 [thread overview]
Message-ID: <20230213164551.550400-3-iii@linux.ibm.com> (raw)
In-Reply-To: <20230213164551.550400-1-iii@linux.ibm.com>
clang complains:
debuginfod.cxx:354:1: error: unused variable 'apba__' [-Werror,-Wunused-const-variable]
ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
^
../lib/printversion.h:47:21: note: expanded from macro 'ARGP_PROGRAM_BUG_ADDRESS_DEF'
const char *const apba__ __asm ("argp_program_bug_address")
^
The default linkage for consts in C++ is internal, so declare them
extern. While at it, remove the debuginfod workaround for
argp_program_version_hook.
Co-developed-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
debuginfod/debuginfod.cxx | 3 +--
lib/printversion.h | 5 ++++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index 4271acf4..99b1f2b9 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -348,7 +348,7 @@ static const char DEBUGINFOD_SQLITE_CLEANUP_DDL[] =
/* Name and version of program. */
-/* ARGP_PROGRAM_VERSION_HOOK_DEF = print_version; */ // not this simple for C++
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
@@ -4171,7 +4171,6 @@ main (int argc, char *argv[])
/* Parse and process arguments. */
int remaining;
- argp_program_version_hook = print_version; // this works
(void) argp_parse (&argp, argc, argv, ARGP_IN_ORDER, &remaining, NULL);
if (remaining != argc)
error (EXIT_FAILURE, 0,
diff --git a/lib/printversion.h b/lib/printversion.h
index a9e059ff..4154b328 100644
--- a/lib/printversion.h
+++ b/lib/printversion.h
@@ -39,10 +39,13 @@ void print_version (FILE *stream, struct argp_state *state);
argp_program_bug_address, in all programs. argp.h declares these
variables as non-const (which is correct in general). But we can
do better, it is not going to change. So we want to move them into
- the .rodata section. Define macros to do the trick. */
+ the .rodata section. Define macros to do the trick. The default
+ linkage for consts in C++ is internal, so declare them extern. */
+extern void (*const apvh) (FILE *, struct argp_state *);
#define ARGP_PROGRAM_VERSION_HOOK_DEF \
void (*const apvh) (FILE *, struct argp_state *) \
__asm ("argp_program_version_hook")
+extern const char *const apba__;
#define ARGP_PROGRAM_BUG_ADDRESS_DEF \
const char *const apba__ __asm ("argp_program_bug_address")
--
2.39.1
next prev parent reply other threads:[~2023-02-13 16:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-13 16:45 [PATCH v3 0/4] Add Memory Sanitizer support Ilya Leoshkevich
2023-02-13 16:45 ` [PATCH v3 1/4] tests: Ignore dwfl-report-offline-memory Ilya Leoshkevich
2023-02-14 13:38 ` (subset) " Mark Wielaard
2023-02-13 16:45 ` Ilya Leoshkevich [this message]
2023-02-14 13:42 ` (subset) [PATCH v3 2/4] printversion: Fix unused variable Mark Wielaard
2023-02-13 16:45 ` [PATCH v3 3/4] backends: Support returning lvalue and rvalue references Ilya Leoshkevich
2023-02-14 14:16 ` Mark Wielaard
2023-02-13 16:45 ` [PATCH v3 4/4] configure: Add --enable-sanitize-memory Ilya Leoshkevich
2023-02-14 14:25 ` 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=20230213164551.550400-3-iii@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=elfutils-devel@sourceware.org \
--cc=fche@redhat.com \
--cc=mark@klomp.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).