Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
0480-erts-Cast-char-constant-to-silience-clang-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0480-erts-Cast-char-constant-to-silience-clang-warning.patch of Package erlang
From 1790e61525b640a1051ad8628e58e89294a264a7 Mon Sep 17 00:00:00 2001 From: Lukas Larsson <lukas@erlang.org> Date: Tue, 3 Nov 2020 08:40:02 +0100 Subject: [PATCH] erts: Cast char constant to silience clang warning --- erts/emulator/beam/packet_parser.c | 9 --- erts/emulator/beam/sys.h | 80 +++++++++++++------------ erts/emulator/drivers/common/inet_drv.c | 9 --- 3 files changed, 43 insertions(+), 55 deletions(-) diff --git a/erts/emulator/beam/packet_parser.c b/erts/emulator/beam/packet_parser.c index 8f24725326..d3f02d55c8 100644 --- a/erts/emulator/beam/packet_parser.c +++ b/erts/emulator/beam/packet_parser.c @@ -39,15 +39,6 @@ # define DEBUGF(X) printf X #endif -#define get_int24(s) ((((unsigned char*) (s))[0] << 16) | \ - (((unsigned char*) (s))[1] << 8) | \ - (((unsigned char*) (s))[2])) - -#define get_little_int32(s) ((((unsigned char*) (s))[3] << 24) | \ - (((unsigned char*) (s))[2] << 16) | \ - (((unsigned char*) (s))[1] << 8) | \ - (((unsigned char*) (s))[0])) - #if !defined(__WIN32__) && !defined(HAVE_STRNCASECMP) #define STRNCASECMP my_strncasecmp diff --git a/erts/emulator/beam/sys.h b/erts/emulator/beam/sys.h index 789c4b0ca9..1ffc7f5028 100644 --- a/erts/emulator/beam/sys.h +++ b/erts/emulator/beam/sys.h @@ -1176,57 +1176,63 @@ ERTS_GLB_INLINE size_t sys_strlen(const char *s) /* Standard set of integer macros .. */ -#define get_int64(s) (((Uint64)(((unsigned char*) (s))[0]) << 56) | \ - (((Uint64)((unsigned char*) (s))[1]) << 48) | \ - (((Uint64)((unsigned char*) (s))[2]) << 40) | \ - (((Uint64)((unsigned char*) (s))[3]) << 32) | \ - (((Uint64)((unsigned char*) (s))[4]) << 24) | \ - (((Uint64)((unsigned char*) (s))[5]) << 16) | \ - (((Uint64)((unsigned char*) (s))[6]) << 8) | \ - (((Uint64)((unsigned char*) (s))[7]))) - -#define put_int64(i, s) do {((char*)(s))[0] = (char)((Sint64)(i) >> 56) & 0xff;\ - ((char*)(s))[1] = (char)((Sint64)(i) >> 48) & 0xff;\ - ((char*)(s))[2] = (char)((Sint64)(i) >> 40) & 0xff;\ - ((char*)(s))[3] = (char)((Sint64)(i) >> 32) & 0xff;\ - ((char*)(s))[4] = (char)((Sint64)(i) >> 24) & 0xff;\ - ((char*)(s))[5] = (char)((Sint64)(i) >> 16) & 0xff;\ - ((char*)(s))[6] = (char)((Sint64)(i) >> 8) & 0xff;\ - ((char*)(s))[7] = (char)((Sint64)(i)) & 0xff;\ +#define get_int64(s) (((Uint64)(((byte*) (s))[0]) << 56) | \ + (((Uint64)((byte*) (s))[1]) << 48) | \ + (((Uint64)((byte*) (s))[2]) << 40) | \ + (((Uint64)((byte*) (s))[3]) << 32) | \ + (((Uint64)((byte*) (s))[4]) << 24) | \ + (((Uint64)((byte*) (s))[5]) << 16) | \ + (((Uint64)((byte*) (s))[6]) << 8) | \ + (((Uint64)((byte*) (s))[7]))) + +#define put_int64(i, s) do {((byte*)(s))[0] = (byte)((Sint64)(i) >> 56) & 0xff;\ + ((byte*)(s))[1] = (byte)((Sint64)(i) >> 48) & 0xff;\ + ((byte*)(s))[2] = (byte)((Sint64)(i) >> 40) & 0xff;\ + ((byte*)(s))[3] = (byte)((Sint64)(i) >> 32) & 0xff;\ + ((byte*)(s))[4] = (byte)((Sint64)(i) >> 24) & 0xff;\ + ((byte*)(s))[5] = (byte)((Sint64)(i) >> 16) & 0xff;\ + ((byte*)(s))[6] = (byte)((Sint64)(i) >> 8) & 0xff;\ + ((byte*)(s))[7] = (byte)((Sint64)(i)) & 0xff;\ } while (0) -#define get_int32(s) ((((unsigned char*) (s))[0] << 24) | \ - (((unsigned char*) (s))[1] << 16) | \ - (((unsigned char*) (s))[2] << 8) | \ - (((unsigned char*) (s))[3])) +#define get_int32(s) ((((byte*) (s))[0] << 24) | \ + (((byte*) (s))[1] << 16) | \ + (((byte*) (s))[2] << 8) | \ + (((byte*) (s))[3])) + +#define get_little_int32(s) ((((byte*) (s))[3] << 24) | \ + (((byte*) (s))[2] << 16) | \ + (((byte*) (s))[1] << 8) | \ + (((byte*) (s))[0])) -#define put_int32(i, s) do {((char*)(s))[0] = (char)((i) >> 24) & 0xff; \ - ((char*)(s))[1] = (char)((i) >> 16) & 0xff; \ - ((char*)(s))[2] = (char)((i) >> 8) & 0xff; \ - ((char*)(s))[3] = (char)(i) & 0xff;} \ +#define put_int32(i, s) do {((byte*)(s))[0] = (byte)((i) >> 24) & 0xff; \ + ((byte*)(s))[1] = (byte)((i) >> 16) & 0xff; \ + ((byte*)(s))[2] = (byte)((i) >> 8) & 0xff; \ + ((byte*)(s))[3] = (byte)(i) & 0xff;} \ while (0) -#define get_int24(s) ((((unsigned char*) (s))[0] << 16) | \ - (((unsigned char*) (s))[1] << 8) | \ - (((unsigned char*) (s))[2])) +#define get_int24(s) ((((byte*) (s))[0] << 16) | \ + (((byte*) (s))[1] << 8) | \ + (((byte*) (s))[2])) + -#define put_int24(i, s) do {((char*)(s))[0] = (char)((i) >> 16) & 0xff; \ - ((char*)(s))[1] = (char)((i) >> 8) & 0xff; \ - ((char*)(s))[2] = (char)(i) & 0xff;} \ +#define put_int24(i, s) do {((byte*)(s))[0] = (byte)((i) >> 16) & 0xff; \ + ((byte*)(s))[1] = (byte)((i) >> 8) & 0xff; \ + ((byte*)(s))[2] = (byte)(i) & 0xff;} \ while (0) -#define get_int16(s) ((((unsigned char*) (s))[0] << 8) | \ - (((unsigned char*) (s))[1])) +#define get_int16(s) ((((byte*) (s))[0] << 8) | \ + (((byte*) (s))[1])) -#define put_int16(i, s) do {((char*)(s))[0] = (char)((i) >> 8) & 0xff; \ - ((char*)(s))[1] = (char)(i) & 0xff;} \ +#define put_int16(i, s) do {((byte*)(s))[0] = (byte)((i) >> 8) & 0xff; \ + ((byte*)(s))[1] = (byte)(i) & 0xff;} \ while (0) -#define get_int8(s) ((((unsigned char*) (s))[0] )) +#define get_int8(s) ((((byte*) (s))[0] )) -#define put_int8(i, s) do {((unsigned char*)(s))[0] = (i) & 0xff;} while (0) +#define put_int8(i, s) do {((byte*)(s))[0] = (i) & 0xff;} while (0) /* * Use DEBUGF as you would use printf, but use double parentheses: -- 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