Commit 1ab4acf9 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk

Fix -Wcast-align warnings when compiled with clang

parent 2976be86
...@@ -878,7 +878,7 @@ static size_t ...@@ -878,7 +878,7 @@ static size_t
repeated_field_pack(const ProtobufCFieldDescriptor *field, repeated_field_pack(const ProtobufCFieldDescriptor *field,
size_t count, const void *member, uint8_t *out) size_t count, const void *member, uint8_t *out)
{ {
char *array = *(char * const *) member; void *array = *(void * const *) member;
unsigned i; unsigned i;
if (field->packed) { if (field->packed) {
...@@ -973,7 +973,7 @@ repeated_field_pack(const ProtobufCFieldDescriptor *field, ...@@ -973,7 +973,7 @@ repeated_field_pack(const ProtobufCFieldDescriptor *field,
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
rv += required_field_pack(field, array, out + rv); rv += required_field_pack(field, array, out + rv);
array += siz; array = (char *)array + siz;
} }
return rv; return rv;
} }
...@@ -2016,7 +2016,7 @@ parse_packed_repeated_member(ScannedMember *scanned_member, ...@@ -2016,7 +2016,7 @@ parse_packed_repeated_member(ScannedMember *scanned_member,
const ProtobufCFieldDescriptor *field = scanned_member->field; const ProtobufCFieldDescriptor *field = scanned_member->field;
size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset); size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset);
size_t siz = sizeof_elt_in_repeated_array(field->type); size_t siz = sizeof_elt_in_repeated_array(field->type);
char *array = *(char **) member + siz * (*p_n); void *array = *(void **) member + siz * (*p_n);
const uint8_t *at = scanned_member->data + scanned_member->length_prefix_len; const uint8_t *at = scanned_member->data + scanned_member->length_prefix_len;
size_t rem = scanned_member->len - scanned_member->length_prefix_len; size_t rem = scanned_member->len - scanned_member->length_prefix_len;
size_t count = 0; size_t count = 0;
...@@ -2649,21 +2649,21 @@ protobuf_c_message_check(const ProtobufCMessage *message) ...@@ -2649,21 +2649,21 @@ protobuf_c_message_check(const ProtobufCMessage *message)
unsigned offset = message->descriptor->fields[f].offset; unsigned offset = message->descriptor->fields[f].offset;
if (label == PROTOBUF_C_LABEL_REQUIRED) { if (label == PROTOBUF_C_LABEL_REQUIRED) {
ProtobufCMessage *sub = *(ProtobufCMessage **) ProtobufCMessage *sub = *(ProtobufCMessage **)
((char *) message + offset); (void *)((char *) message + offset);
if (sub == NULL) if (sub == NULL)
return FALSE; return FALSE;
if (!protobuf_c_message_check(sub)) if (!protobuf_c_message_check(sub))
return FALSE; return FALSE;
} else if (label == PROTOBUF_C_LABEL_OPTIONAL) { } else if (label == PROTOBUF_C_LABEL_OPTIONAL) {
ProtobufCMessage *sub = *(ProtobufCMessage **) ProtobufCMessage *sub = *(ProtobufCMessage **)
((char *) message + offset); (void *)((char *) message + offset);
if (sub != NULL && !protobuf_c_message_check(sub)) if (sub != NULL && !protobuf_c_message_check(sub))
return FALSE; return FALSE;
} else if (label == PROTOBUF_C_LABEL_REPEATED) { } else if (label == PROTOBUF_C_LABEL_REPEATED) {
unsigned n = *(unsigned *) ((char *) message + unsigned n = *(unsigned *)(void *)((char *) message +
message->descriptor->fields[f].quantifier_offset); message->descriptor->fields[f].quantifier_offset);
ProtobufCMessage **subs = *(ProtobufCMessage ***) ProtobufCMessage **subs = *(ProtobufCMessage ***)
((char *) message + offset); (void *)((char *) message + offset);
unsigned i; unsigned i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
if (!protobuf_c_message_check(subs[i])) if (!protobuf_c_message_check(subs[i]))
...@@ -2671,7 +2671,7 @@ protobuf_c_message_check(const ProtobufCMessage *message) ...@@ -2671,7 +2671,7 @@ protobuf_c_message_check(const ProtobufCMessage *message)
} }
} else if (type == PROTOBUF_C_TYPE_STRING) { } else if (type == PROTOBUF_C_TYPE_STRING) {
if (label == PROTOBUF_C_LABEL_REQUIRED) { if (label == PROTOBUF_C_LABEL_REQUIRED) {
char *str = *(char **) ((char *) char *str = *(char **)(void *)((char *)
message + message->descriptor->fields[f].offset); message + message->descriptor->fields[f].offset);
if (str == NULL) if (str == NULL)
return FALSE; return FALSE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment