be more clear about used gcc extensions

This commit is contained in:
hippoz 2023-01-16 00:39:13 +02:00
parent 3f88fe4701
commit f0cef536ff
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED
5 changed files with 25 additions and 21 deletions

View file

@ -1,5 +1,5 @@
CC?=gcc CC?=gcc
CFLAGS+=-Wall -Wextra -Wshadow -std=c99 -ggdb -fsanitize=address CFLAGS+=-Wall -Wextra -Wshadow -pedantic -std=c99 -ggdb -fsanitize=address
jitterbug: util.c wire.c match.c server.c main.c jitterbug: util.c wire.c match.c server.c main.c
$(CC) $(CFLAGS) -o $@ $^ $(CC) $(CFLAGS) -o $@ $^

View file

@ -373,7 +373,7 @@ int bus_unicast_message(bus_t *s, wire_message_t *msg, wire_context_t *ctx, char
.data = signal_reply_data, \ .data = signal_reply_data, \
.data_len = 8192, \ .data_len = 8192, \
}; \ }; \
wire_message_t signal_reply_msg = {}; \ wire_message_t signal_reply_msg = {0}; \
TRYST(wire_compose_signal(&signal_reply_ctx, &signal_reply_msg, (M_sig), (M_member), &signal_body_length)); \ TRYST(wire_compose_signal(&signal_reply_ctx, &signal_reply_msg, (M_sig), (M_member), &signal_body_length)); \
signal_body_start = signal_reply_ctx.byte_cursor; signal_body_start = signal_reply_ctx.byte_cursor;
@ -788,7 +788,7 @@ int bus_client_drain_messages(bus_t *s, int ci, uint8_t *data, uint32_t data_len
return 0; return 0;
} }
#define _client_die(m) ({bus_client_error(s,i,m);continue;}) #define _client_die(m) do { bus_client_error(s,i,m); continue; } while(0)
int bus_turn(bus_t *s) int bus_turn(bus_t *s)
{ {
static const char agree_unix_fd[] = "AGREE_UNIX_FD\r\n"; static const char agree_unix_fd[] = "AGREE_UNIX_FD\r\n";

12
try.h
View file

@ -2,8 +2,12 @@
printf("trace: %s:%d\n", __FILE__, __LINE__); \ printf("trace: %s:%d\n", __FILE__, __LINE__); \
} while(0) \ } while(0) \
#define TRYPTR_NIL(M_expr) ({ void* _result = (void*)(M_expr); if (!_result) { __TRY_TRACE(); return (NULL); } _result; })
#define TRYPTR(M_expr) ({ void* _result = (void*)(M_expr); if (!_result) { __TRY_TRACE(); return (-1); } _result; })
#define TRYST_NIL(M_expr) ({ int _result = (int)(M_expr); if (_result < 0) { __TRY_TRACE(); return (NULL); } _result; }) // NOTE: The macro(s) below make use of a GCC extension called "Statement Exprs", which is nonstandard.
#define TRYST(M_expr) ({ int _result = (int)(M_expr); if (_result < 0) { __TRY_TRACE(); return (-1); } _result; }) // More info: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
#define TRYPTR_NIL(M_expr) __extension__({ void* _result = (void*)(M_expr); if (!_result) { __TRY_TRACE(); return (NULL); } _result; })
#define TRYPTR(M_expr) __extension__({ void* _result = (void*)(M_expr); if (!_result) { __TRY_TRACE(); return (-1); } _result; })
#define TRYST_NIL(M_expr) __extension__({ int _result = (int)(M_expr); if (_result < 0) { __TRY_TRACE(); return (NULL); } _result; })
#define TRYST(M_expr) __extension__({ int _result = (int)(M_expr); if (_result < 0) { __TRY_TRACE(); return (-1); } _result; })

14
wire.c
View file

@ -40,13 +40,13 @@ bool wire_write_align(wire_context_t *c, uint32_t alignment)
} }
// SPEC: https://dbus.freedesktop.org/doc/dbus-specification.html#id-1.4.6 // SPEC: https://dbus.freedesktop.org/doc/dbus-specification.html#id-1.4.6
_WIRE_DEF_BYTE_TYPE(i8, int8_t); _WIRE_DEF_BYTE_TYPE(i8, int8_t)
_WIRE_DEF_BYTE_TYPE(u8, uint8_t); _WIRE_DEF_BYTE_TYPE(u8, uint8_t)
_WIRE_DEF_TYPE(i16, int16_t, 2); _WIRE_DEF_TYPE(i16, int16_t, 2)
_WIRE_DEF_TYPE(u16, uint16_t, 2); _WIRE_DEF_TYPE(u16, uint16_t, 2)
_WIRE_DEF_TYPE(i32, int32_t, 4); _WIRE_DEF_TYPE(i32, int32_t, 4)
_WIRE_DEF_TYPE(u32, uint32_t, 4); _WIRE_DEF_TYPE(u32, uint32_t, 4)
_WIRE_DEF_TYPE(boolean, uint32_t, 4); _WIRE_DEF_TYPE(boolean, uint32_t, 4)
char *wire_get_string_impl(wire_context_t *c, bool as_signature) char *wire_get_string_impl(wire_context_t *c, bool as_signature)
{ {

14
wire.h
View file

@ -112,13 +112,13 @@ bool wire_align(wire_context_t *c, uint32_t alignment);
bool wire_write_align(wire_context_t *c, uint32_t alignment); bool wire_write_align(wire_context_t *c, uint32_t alignment);
// SPEC: https://dbus.freedesktop.org/doc/dbus-specification.html#id-1.4.6 // SPEC: https://dbus.freedesktop.org/doc/dbus-specification.html#id-1.4.6
_WIRE_DECL_BYTE_TYPE(i8, int8_t); _WIRE_DECL_BYTE_TYPE(i8, int8_t)
_WIRE_DECL_BYTE_TYPE(u8, uint8_t); _WIRE_DECL_BYTE_TYPE(u8, uint8_t)
_WIRE_DECL_TYPE(i16, int16_t, 2); _WIRE_DECL_TYPE(i16, int16_t, 2)
_WIRE_DECL_TYPE(u16, uint16_t, 2); _WIRE_DECL_TYPE(u16, uint16_t, 2)
_WIRE_DECL_TYPE(i32, int32_t, 4); _WIRE_DECL_TYPE(i32, int32_t, 4)
_WIRE_DECL_TYPE(u32, uint32_t, 4); _WIRE_DECL_TYPE(u32, uint32_t, 4)
_WIRE_DECL_TYPE(boolean, uint32_t, 4); _WIRE_DECL_TYPE(boolean, uint32_t, 4)
char *wire_get_string_impl(wire_context_t *c, bool as_signature); char *wire_get_string_impl(wire_context_t *c, bool as_signature);