Skip to content

Commit 4eaa2b7

Browse files
author
Leonardo Alminana
committed
log_event_encoder: switched data size type to overcome msvc issue
Signed-off-by: Leonardo Alminana <[email protected]>
1 parent 19a8a30 commit 4eaa2b7

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

include/fluent-bit/flb_log_event_encoder.h

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,36 +75,46 @@
7575

7676
#define FLB_LOG_EVENT_APPEND_UNTIL_TERMINATOR -1
7777

78+
/* Note: all of the size_t casts have been replaced with
79+
* size_t pointer casts because there is an issue
80+
* with msvc where it doesn't honor the type promotion
81+
* when a small constant integer is hard-coded.
82+
*
83+
* This should not be a problem because according to
84+
* the standard a size_t should be as large as the
85+
* native register size just like pointers.
86+
*/
87+
7888
#define FLB_LOG_EVENT_VALUE_LIST_TERMINATOR() \
7989
(int) FLB_LOG_EVENT_APPEND_TERMINATOR_VALUE_TYPE
8090

8191
#define FLB_LOG_EVENT_STRING_LENGTH_VALUE(length) \
8292
(int) FLB_LOG_EVENT_STRING_LENGTH_VALUE_TYPE, \
83-
(size_t) length
93+
(size_t *) length
8494

8595
#define FLB_LOG_EVENT_STRING_BODY_VALUE(buffer, length) \
8696
(int) FLB_LOG_EVENT_STRING_BODY_VALUE_TYPE, \
8797
(char *) buffer, \
88-
(size_t) length
98+
(size_t *) length
8999

90100
#define FLB_LOG_EVENT_BINARY_LENGTH_VALUE(length) \
91101
(int) FLB_LOG_EVENT_BINARY_LENGTH_VALUE_TYPE, \
92-
(size_t) length
102+
(size_t *) length
93103

94104
#define FLB_LOG_EVENT_BINARY_BODY_VALUE(buffer, length) \
95105
(int) FLB_LOG_EVENT_BINARY_BODY_VALUE_TYPE, \
96106
(char *) buffer, \
97-
(size_t) length
107+
(size_t *) length
98108

99109
#define FLB_LOG_EVENT_EXT_LENGTH_VALUE(type_, length) \
100110
(int) FLB_LOG_EVENT_EXT_LENGTH_VALUE_TYPE, \
101111
(int) type_, \
102-
(size_t) length
112+
(size_t *) length
103113

104114
#define FLB_LOG_EVENT_EXT_BODY_VALUE(buffer, length) \
105115
(int) FLB_LOG_EVENT_EXT_BODY_VALUE_TYPE, \
106116
(char *) buffer, \
107-
(size_t) length
117+
(size_t *) length
108118

109119
#define FLB_LOG_EVENT_TIMESTAMP_VALUE(value) \
110120
(int) FLB_LOG_EVENT_TIMESTAMP_VALUE_TYPE, \
@@ -176,7 +186,7 @@
176186
#define FLB_LOG_EVENT_MSGPACK_RAW_VALUE(buffer, length) \
177187
(int) FLB_LOG_EVENT_MSGPACK_RAW_VALUE_TYPE, \
178188
(char *) buffer, \
179-
(size_t) length
189+
(size_t *) length
180190

181191
#define FLB_LOG_EVENT_STRING_VALUE(buffer, length) \
182192
FLB_LOG_EVENT_STRING_LENGTH_VALUE(length), \

0 commit comments

Comments
 (0)