From 88ac8b1d302847b9e04b727d4829f0d26c86b943 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Fri, 16 Aug 2024 09:03:16 -0700 Subject: [PATCH 1/2] Fix -Wuseless-cast compiler warnings in headers --- include/aws/event-stream/event_stream.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/aws/event-stream/event_stream.h b/include/aws/event-stream/event_stream.h index f948025..2d7f657 100644 --- a/include/aws/event-stream/event_stream.h +++ b/include/aws/event-stream/event_stream.h @@ -65,9 +65,13 @@ struct aws_event_stream_message { struct aws_byte_buf message_buffer; }; -#define AWS_EVENT_STREAM_PRELUDE_LENGTH (uint32_t)(sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t)) - -#define AWS_EVENT_STREAM_TRAILER_LENGTH (uint32_t)(sizeof(uint32_t)) +#if SIZE_MAX == UINT32_MAX +# define AWS_EVENT_STREAM_PRELUDE_LENGTH (sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t)) +# define AWS_EVENT_STREAM_TRAILER_LENGTH (sizeof(uint32_t)) +#else /* cast to uint32_t */ +# define AWS_EVENT_STREAM_PRELUDE_LENGTH (uint32_t)(sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t)) +# define AWS_EVENT_STREAM_TRAILER_LENGTH (uint32_t)(sizeof(uint32_t)) +#endif enum aws_event_stream_header_value_type { AWS_EVENT_STREAM_HEADER_BOOL_TRUE = 0, From 17a7bd37d631a2853638b2d66e6688decb2d448a Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Fri, 16 Aug 2024 09:36:10 -0700 Subject: [PATCH 2/2] simpler --- include/aws/event-stream/event_stream.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/include/aws/event-stream/event_stream.h b/include/aws/event-stream/event_stream.h index 2d7f657..bb5376b 100644 --- a/include/aws/event-stream/event_stream.h +++ b/include/aws/event-stream/event_stream.h @@ -65,13 +65,11 @@ struct aws_event_stream_message { struct aws_byte_buf message_buffer; }; -#if SIZE_MAX == UINT32_MAX -# define AWS_EVENT_STREAM_PRELUDE_LENGTH (sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t)) -# define AWS_EVENT_STREAM_TRAILER_LENGTH (sizeof(uint32_t)) -#else /* cast to uint32_t */ -# define AWS_EVENT_STREAM_PRELUDE_LENGTH (uint32_t)(sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t)) -# define AWS_EVENT_STREAM_TRAILER_LENGTH (uint32_t)(sizeof(uint32_t)) -#endif +/* Prelude (12-bytes) = Total Byte Length (4-bytes) + Headers Byte Length (4-bytes) + Prelude CRC (4-bytes) */ +#define AWS_EVENT_STREAM_PRELUDE_LENGTH (uint32_t)(12) + +/* Trailer (4-bytes) = Message CRC (4-bytes) */ +#define AWS_EVENT_STREAM_TRAILER_LENGTH (uint32_t)(4) enum aws_event_stream_header_value_type { AWS_EVENT_STREAM_HEADER_BOOL_TRUE = 0,