summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2c44f5b)
Compiling on x86-32 shows the following warnings for filter (with gcc
4.3 and 4.4):
././ust_tests_hello.h:28: note: initialized from here
././ust_tests_hello.h:28: error: dereferencing pointer ‘__stack_data.18’ does break strict-aliasing rules
Fix it by using memcpy when copying to the temporary "stack" array used
to send arguments to the filter.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
#undef _ctf_integer_ext
#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _written) \
#undef _ctf_integer_ext
#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _written) \
- if (lttng_is_signed_type(_type)) \
- *(int64_t *) __stack_data = (int64_t) (_type) (_src); \
- else \
- *(uint64_t *) __stack_data = (uint64_t) (_type) (_src); \
+ if (lttng_is_signed_type(_type)) { \
+ int64_t __ctf_tmp_int64 = (int64_t) (_type) (_src); \
+ memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
+ } else { \
+ uint64_t __ctf_tmp_uint64 = (uint64_t) (_type) (_src); \
+ memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
+ } \
__stack_data += sizeof(int64_t);
#undef _ctf_float
#define _ctf_float(_type, _item, _src, _written) \
__stack_data += sizeof(int64_t);
#undef _ctf_float
#define _ctf_float(_type, _item, _src, _written) \
- *(double *) __stack_data = (double) (_type) (_src); \
- __stack_data += sizeof(double);
+ { \
+ double __ctf_tmp_double = (double) (_type) (_src); \
+ memcpy(__stack_data, &__ctf_tmp_double, sizeof(double)); \
+ __stack_data += sizeof(double); \
+ }
#undef _ctf_array_encoded
#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _written) \
#undef _ctf_array_encoded
#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _written) \
- *(unsigned long *) __stack_data = (unsigned long) (_length); \
- __stack_data += sizeof(unsigned long); \
- *(const void **) __stack_data = (_src); \
- __stack_data += sizeof(void *);
+ { \
+ unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
+ memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
+ __stack_data += sizeof(unsigned long); \
+ memcpy(__stack_data, (_src), sizeof(void **)); \
+ __stack_data += sizeof(void **); \
+ }
#undef _ctf_sequence_encoded
#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
_src_length, _encoding, _written) \
#undef _ctf_sequence_encoded
#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
_src_length, _encoding, _written) \
- *(unsigned long *) __stack_data = (unsigned long) (_src_length); \
- __stack_data += sizeof(unsigned long); \
- *(const void **) __stack_data = (_src); \
- __stack_data += sizeof(void *);
+ { \
+ unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
+ memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
+ __stack_data += sizeof(unsigned long); \
+ memcpy(__stack_data, (_src), sizeof(void **)); \
+ __stack_data += sizeof(void **); \
+ }
#undef _ctf_string
#define _ctf_string(_item, _src, _written) \
#undef _ctf_string
#define _ctf_string(_item, _src, _written) \
- *(const void **) __stack_data = (_src); \
- __stack_data += sizeof(void *);
+ { \
+ memcpy(__stack_data, (_src), sizeof(void **)); \
+ __stack_data += sizeof(void *); \
+ }
#undef TP_ARGS
#define TP_ARGS(...) __VA_ARGS__
#undef TP_ARGS
#define TP_ARGS(...) __VA_ARGS__