Fixed bugs that lint caught.

pull/13171/head
Joshua Haberman 16 years ago
parent 268bb50e80
commit 6e67cb48ef
  1. 4
      pbstream.c
  2. 26
      pbstruct.h

@ -20,7 +20,7 @@
#endif
#define CHECK(func) do { \
pbstream_wire_type_t status = func; \
pbstream_status_t status = func; \
if(status != PBSTREAM_STATUS_OK) return status; \
} while (0)
@ -235,7 +235,7 @@ pbstream_status_t parse_tag(uint8_t **buf, struct pbstream_tag *tag)
{
uint32_t tag_int;
CHECK(get_v_uint32_t(buf, &tag_int));
tag->wire_type = tag_int & 0x07;
tag->wire_type = (pbstream_wire_type_t)(tag_int & 0x07);
tag->field_number = tag_int >> 3;
return PBSTREAM_STATUS_OK;
}

@ -71,30 +71,30 @@ struct pbstruct* pbstruct_new(struct pbstruct_definition *definition);
/* Deletes any sub-structs also. */
struct pbstruct* pbstruct_delete(struct pbstruct_definition *definition);
bool pbstruct_is_set(struct pbstruct *s, struct pbstruct_field *f) {
inline bool pbstruct_is_set(struct pbstruct *s, struct pbstruct_field *f) {
return s->data[f->isset_byte_offset] & f->isset_byte_mask;
}
/* These do no existence checks or type checks. */
#define DEFINE_GETTERS(ctype, name) \
ctype pbstruct_get_ ## name(struct pbstruct *s, struct pbstruct_field *f) { \
inline ctype pbstruct_get_ ## name(struct pbstruct *s, struct pbstruct_field *f) { \
/* TODO: make sure the compiler knows this is an aligned access. */ \
return *(ctype*)(s->data + f->byte_offset); \
} \
ctype *pbstruct_get_ ## name ## _array(struct pbstruct *s, \
inline ctype *pbstruct_get_ ## name ## _array(struct pbstruct *s, \
struct pbstruct_field *f) { \
/* TODO: make sure the compiler knows this is an aligned access. */ \
return *(ctype**)(s->data + f->byte_offset); \
}
DEFINE_GETTERS(double, double);
DEFINE_GETTERS(float, float);
DEFINE_GETTERS(int32_t, int32);
DEFINE_GETTERS(int64_t, int64);
DEFINE_GETTERS(uint32_t, uint32);
DEFINE_GETTERS(uint64_t, uint64);
DEFINE_GETTERS(bool, bool);
DEFINE_GETTERS(struct pbstruct_delimited*, bytes);
DEFINE_GETTERS(struct pbstruct_delimited*, string);
DEFINE_GETTERS(struct pbstruct*, substruct);
DEFINE_GETTERS(double, double)
DEFINE_GETTERS(float, float)
DEFINE_GETTERS(int32_t, int32)
DEFINE_GETTERS(int64_t, int64)
DEFINE_GETTERS(uint32_t, uint32)
DEFINE_GETTERS(uint64_t, uint64)
DEFINE_GETTERS(bool, bool)
DEFINE_GETTERS(struct pbstruct_delimited*, bytes)
DEFINE_GETTERS(struct pbstruct_delimited*, string)
DEFINE_GETTERS(struct pbstruct*, substruct)

Loading…
Cancel
Save