aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2024-08-05 16:46:03 -0700
committerIan Lance Taylor <iant@golang.org>2024-08-05 16:46:03 -0700
commit3a51aaf5f4ccd3d2ed871727c16f9c6f9ed54e50 (patch)
tree8744adeeaa7ae617744275fbca92a4d17106de89
parentecb6153e3b9895c6e058646262c7c9e9c9c24a3c (diff)
downloadgcc-3a51aaf5f4ccd3d2ed871727c16f9c6f9ed54e50.zip
gcc-3a51aaf5f4ccd3d2ed871727c16f9c6f9ed54e50.tar.gz
gcc-3a51aaf5f4ccd3d2ed871727c16f9c6f9ed54e50.tar.bz2
libbacktrace: avoid -Wpointer-arith errors
Based on patch from Kirill Müller. * configure.ac (ACX_PROG_CC_WARNING_OPTS): Add -Wpointer-arith. * pecoff.c (coff_add): Cast void pointers. * xcoff.c (xcoff_add): Likewise. * configure: Regenerate.
-rwxr-xr-xlibbacktrace/configure3
-rw-r--r--libbacktrace/configure.ac3
-rw-r--r--libbacktrace/pecoff.c7
-rw-r--r--libbacktrace/xcoff.c4
4 files changed, 11 insertions, 6 deletions
diff --git a/libbacktrace/configure b/libbacktrace/configure
index fe0bb20..db491a7 100755
--- a/libbacktrace/configure
+++ b/libbacktrace/configure
@@ -12385,7 +12385,8 @@ save_CFLAGS="$CFLAGS"
for real_option in -W -Wall -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wold-style-definition \
-Wmissing-format-attribute -Wcast-qual \
- -Wno-attributes -Wno-unknown-attributes; do
+ -Wno-attributes -Wno-unknown-attributes \
+ -Wpointer-arith; do
# Do the check with the no- prefix removed since gcc silently
# accepts any -Wno-* option on purpose
case $real_option in
diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
index bfd7f35..69eb202 100644
--- a/libbacktrace/configure.ac
+++ b/libbacktrace/configure.ac
@@ -145,7 +145,8 @@ AC_SUBST(EXTRA_FLAGS)
ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wold-style-definition \
-Wmissing-format-attribute -Wcast-qual \
- -Wno-attributes -Wno-unknown-attributes],
+ -Wno-attributes -Wno-unknown-attributes \
+ -Wpointer-arith],
[WARN_FLAGS])
AC_ARG_ENABLE([werror],
diff --git a/libbacktrace/pecoff.c b/libbacktrace/pecoff.c
index ccd5ccb..15a73ff 100644
--- a/libbacktrace/pecoff.c
+++ b/libbacktrace/pecoff.c
@@ -704,7 +704,7 @@ coff_add (struct backtrace_state *state, int descriptor,
magic_ok = memcmp (magic, "PE\0", 4) == 0;
fhdr_off += 4;
- memcpy (&fhdr, fhdr_view.data + 4, sizeof fhdr);
+ memcpy (&fhdr, (const unsigned char *) fhdr_view.data + 4, sizeof fhdr);
}
else
{
@@ -738,7 +738,7 @@ coff_add (struct backtrace_state *state, int descriptor,
sects_view_valid = 1;
opt_hdr = (const b_coff_optional_header *) sects_view.data;
sects = (const b_coff_section_header *)
- (sects_view.data + fhdr.size_of_optional_header);
+ ((const unsigned char *) sects_view.data + fhdr.size_of_optional_header);
is_64 = 0;
memset (&image_base, 0, sizeof image_base);
@@ -781,7 +781,8 @@ coff_add (struct backtrace_state *state, int descriptor,
goto fail;
syms_view_valid = 1;
- str_size = coff_read4 (syms_view.data + syms_size);
+ str_size = coff_read4 ((const unsigned char *) syms_view.data
+ + syms_size);
str_off = syms_off + syms_size;
diff --git a/libbacktrace/xcoff.c b/libbacktrace/xcoff.c
index 01443c4..84ce07b 100644
--- a/libbacktrace/xcoff.c
+++ b/libbacktrace/xcoff.c
@@ -1203,7 +1203,9 @@ xcoff_add (struct backtrace_state *state, int descriptor, off_t offset,
goto fail;
syms_view_valid = 1;
- memcpy (&str_size, syms_view.data + syms_size, 4);
+ memcpy (&str_size,
+ (const unsigned char *) syms_view.data + syms_size,
+ 4);
str_off = fhdr.f_symptr + syms_size;