Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
2751-erts-Warn-on-void-pointer-arithmetic.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2751-erts-Warn-on-void-pointer-arithmetic.patch of Package erlang
From 6555380c0fbea72509c1646129d11e36d9f62da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org> Date: Thu, 12 Nov 2020 12:21:02 +0100 Subject: [PATCH] erts: Warn on void pointer arithmetic This is a GCC extension that's enabled by default, which is rather annoying when trying to write portable code. These errors usually aren't noticed until the Windows builds run, or worse, the debug builds that only run during the night. --- erts/configure.in | 2 +- erts/emulator/beam/dist.c | 2 +- erts/emulator/beam/external.c | 8 ++++---- erts/emulator/sys/unix/sys_drivers.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/erts/configure.in b/erts/configure.in index f45a3f0b17..379fc74689 100644 --- a/erts/configure.in +++ b/erts/configure.in @@ -544,7 +544,7 @@ if test "x$GCC" = xyes; then # until the emulator can handle this, I suggest we turn it off! #WFLAGS="-Wall -Wshadow -Wcast-qual -Wmissing-declarations" - WFLAGS="-Wall -Wstrict-prototypes" + WFLAGS="-Wall -Wstrict-prototypes -Wpointer-arith" case "$host_cpu" in tile*) diff --git a/erts/emulator/beam/dist.c b/erts/emulator/beam/dist.c index dc331c7fb0..9aaead668e 100644 --- a/erts/emulator/beam/dist.c +++ b/erts/emulator/beam/dist.c @@ -3244,7 +3244,7 @@ erts_dsig_send(ErtsDSigSendContext *ctx) } ASSERT(fragments < 2 - || (get_int64(ctx->obuf->eiov->iov[1].iov_base + 10) + || (get_int64(&((char*)ctx->obuf->eiov->iov[1].iov_base)[10]) == ctx->fragments)); if (fragments) { diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c index 0396e14ff8..b93630cf31 100644 --- a/erts/emulator/beam/external.c +++ b/erts/emulator/beam/external.c @@ -488,7 +488,7 @@ Sint erts_encode_ext_dist_header_finalize(ErtsDistOutputBuf* ob, ip = &instr_buf[0]; sys_memcpy((void *) ip, (void *) ep, sz); ep += sz; - ASSERT(ep == (byte *) (ob->eiov->iov[1].iov_base + ob->eiov->iov[1].iov_len)); + ASSERT(ep == &((byte *)ob->eiov->iov[1].iov_base)[ob->eiov->iov[1].iov_len]); if (ci > 0) { Uint32 flgs_buf[((ERTS_DIST_HDR_ATOM_CACHE_FLAG_BYTES( ERTS_MAX_INTERNAL_ATOM_CACHE_ENTRIES)-1) @@ -5963,7 +5963,7 @@ Sint transcode_dist_obuf(ErtsDistOutputBuf* ob, bitsize = *ep++; /* write fallback prolog... */ - iov[hopefull_ix].iov_base -= 4; + iov[hopefull_ix].iov_base = &((byte*)iov[hopefull_ix].iov_base)[-4]; ep = (byte *) iov[hopefull_ix].iov_base; *ep++ = SMALL_TUPLE_EXT; @@ -6001,7 +6001,7 @@ Sint transcode_dist_obuf(ErtsDistOutputBuf* ob, ASSERT(1 == iov[hopefull_ix].iov_len); - iov[hopefull_ix].iov_base -= 4; + iov[hopefull_ix].iov_base = &((byte*)iov[hopefull_ix].iov_base)[-4]; ep = (byte *) iov[hopefull_ix].iov_base; new_hopefull_ix = get_int32(ep); ASSERT(new_hopefull_ix == ERTS_NO_HIX @@ -6055,7 +6055,7 @@ Sint transcode_dist_obuf(ErtsDistOutputBuf* ob, if (payload_ix) { ASSERT(0 < payload_ix && payload_ix < eiov->vsize); /* Prepend version magic on payload. */ - iov[payload_ix].iov_base--; + iov[payload_ix].iov_base = &((byte*)iov[payload_ix].iov_base)[-1]; *((byte *) iov[payload_ix].iov_base) = VERSION_MAGIC; iov[payload_ix].iov_len++; eiov->size++; diff --git a/erts/emulator/sys/unix/sys_drivers.c b/erts/emulator/sys/unix/sys_drivers.c index e3f9a8073e..63a9cb71b8 100644 --- a/erts/emulator/sys/unix/sys_drivers.c +++ b/erts/emulator/sys/unix/sys_drivers.c @@ -712,7 +712,7 @@ static ErlDrvData spawn_start(ErlDrvPort port_num, char* name, if (res >= io_vector[i].iov_len) res -= io_vector[i].iov_len; else { - driver_enq(port_num, io_vector[i].iov_base + res, + driver_enq(port_num, &((char*)io_vector[i].iov_base)[res], io_vector[i].iov_len - res); res = 0; } -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor