~fsx/protobluff

92d2dae0a7d156766e3afce262574d1ef00a1d6b — Frank Smit 11 months ago 496280d
Fix part of compiler warnings.
M examples/decoding/example.c => examples/decoding/example.c +2 -0
@@ 44,6 44,8 @@
static pb_error_t
handler_phonenumber(
    const pb_field_descriptor_t *descriptor, const void *value, void *user) {
  (void)user;

  assert(descriptor && value);
  pb_error_t error = PB_ERROR_NONE;
  switch (pb_field_descriptor_tag(descriptor)) {

M examples/encoding/example.c => examples/encoding/example.c +1 -1
@@ 97,4 97,4 @@ main(void) {
  return error
    ? EXIT_FAILURE
    : EXIT_SUCCESS;
}
\ No newline at end of file
}

M examples/messages/example.c => examples/messages/example.c +1 -1
@@ 102,4 102,4 @@ main(void) {
  return error
    ? EXIT_FAILURE
    : EXIT_SUCCESS;
}
\ No newline at end of file
}

M include/protobluff/util/chunk_allocator.h => include/protobluff/util/chunk_allocator.h +1 -1
@@ 34,7 34,7 @@

PB_EXPORT PB_WARN_UNUSED_RESULT
pb_allocator_t
pb_chunk_allocator_create();
pb_chunk_allocator_create(void); // XXX: Why void?

PB_EXPORT PB_WARN_UNUSED_RESULT
pb_allocator_t

M meson.build => meson.build +6 -0
@@ 9,6 9,12 @@ project(
  ],
)

add_global_arguments(
  '-Wall',
  '-Wpedantic',
  language: 'c',
)

cpp = meson.get_compiler('cpp')

libprotobuf = dependency('protobuf')

M src/core/allocator.c => src/core/allocator.c +1 -1
@@ 85,4 85,4 @@ allocator_default = {

/*! Zero-copy fake-allocator */
pb_allocator_t
allocator_zero_copy = {};
allocator_zero_copy = {0};

M src/core/stream.c => src/core/stream.c +3 -0
@@ 63,6 63,7 @@ read_varint(pb_stream_t *stream, pb_type_t type, void *value) {
 */
static pb_error_t
read_64bit(pb_stream_t *stream, pb_type_t type, void *value) {
  (void)type;
  assert(stream && value);
  if (unlikely_(pb_stream_advance(stream, 8)))
    return PB_ERROR_OFFSET;


@@ 81,6 82,7 @@ read_64bit(pb_stream_t *stream, pb_type_t type, void *value) {
 */
static pb_error_t
read_length(pb_stream_t *stream, pb_type_t type, void *value) {
  (void)type;
  assert(stream && value);
  uint32_t length = 0;
  size_t size = pb_varint_unpack_uint32(


@@ 105,6 107,7 @@ read_length(pb_stream_t *stream, pb_type_t type, void *value) {
 */
static pb_error_t
read_32bit(pb_stream_t *stream, pb_type_t type, void *value) {
  (void)type;
  assert(stream && value);
  if (unlikely_(pb_stream_advance(stream, 4)))
    return PB_ERROR_OFFSET;

M src/generator/enum.cc => src/generator/enum.cc +1 -1
@@ 156,7 156,7 @@ namespace protobluff {
      printer->Print(variables_,
        "/* `signature` : descriptor */\n"
        "pb_enum_descriptor_t\n"
        "`enum`_descriptor = {};\n"
        "`enum`_descriptor = {0};\n"
        "\n");
    }
  }

M src/generator/file.cc => src/generator/file.cc +1 -1
@@ 296,7 296,7 @@ namespace protobluff {

    /* Generate guard footer */
    printer->Print(variables_,
      "#endif /* `guard`_PB_H */");
      "#endif /* `guard`_PB_H */\n");
  }

  /*!

M src/generator/generator.cc => src/generator/generator.cc +2 -0
@@ 62,6 62,8 @@ namespace protobluff {
  Generate(
      const FileDescriptor *descriptor, const string &parameter,
      GeneratorContext* generator_context, string *error) const {
    (void)parameter;

    assert(descriptor && generator_context && error);

    /* Construct basename for source and header files */

M src/generator/message.cc => src/generator/message.cc +1 -1
@@ 235,7 235,7 @@ namespace protobluff {
      printer->Print(variables_,
        "/* `signature` : descriptor */\n"
        "pb_descriptor_t\n"
        "`message`_descriptor = {};\n"
        "`message`_descriptor = {0};\n"
        "\n");
    }


M src/message/journal.h => src/message/journal.h +1 -1
@@ 83,7 83,7 @@ pb_journal_align(
PB_INLINE PB_WARN_UNUSED_RESULT
pb_journal_t
pb_journal_create_invalid(void) {
  pb_journal_t journal = {};
  pb_journal_t journal = {0};
  return journal;
}


M src/util/chunk_allocator.c => src/util/chunk_allocator.c +1 -1
@@ 203,7 203,7 @@ allocator_free(void *data, void *block) {
 * \return Chunk allocator
 */
extern pb_allocator_t
pb_chunk_allocator_create() {
pb_chunk_allocator_create(void) {
  return pb_chunk_allocator_create_with_capacity(4096);
}


M tests/core/buffer/test.c => tests/core/buffer/test.c +1 -0
@@ 57,6 57,7 @@ allocator_allocate_fail(void *data, size_t size) {
 */
static void *
allocator_resize_fail(void *data, void *block, size_t size) {
  (void)block;
  assert(!data && size);
  return NULL;
}

M tests/core/decoder/test.c => tests/core/decoder/test.c +16 -16
@@ 70,19 70,19 @@ enum_descriptor = { {
static pb_descriptor_t
descriptor = { {
  (const pb_field_descriptor_t []){
    {  1, "F01", UINT32,  OPTIONAL },
    {  2, "F02", UINT64,  OPTIONAL },
    {  3, "F03", SINT32,  OPTIONAL },
    {  4, "F04", SINT64,  OPTIONAL },
    {  5, "F05", BOOL,    OPTIONAL },
    {  1, "F01", UINT32,  OPTIONAL, NULL, NULL, 0 },
    {  2, "F02", UINT64,  OPTIONAL, NULL, NULL, 0 },
    {  3, "F03", SINT32,  OPTIONAL, NULL, NULL, 0 },
    {  4, "F04", SINT64,  OPTIONAL, NULL, NULL, 0 },
    {  5, "F05", BOOL,    OPTIONAL, NULL, NULL, 0 },
    {  6, "F06", FLOAT,   REPEATED, NULL, NULL, PACKED },
    {  7, "F07", DOUBLE,  OPTIONAL },
    {  8, "F08", STRING,  OPTIONAL },
    {  9, "F09", BYTES,   OPTIONAL },
    { 10, "F10", ENUM,    OPTIONAL, &enum_descriptor },
    { 11, "F11", MESSAGE, OPTIONAL, &descriptor },
    { 12, "F12", MESSAGE, REPEATED, &descriptor }
  }, 12 } };
    {  7, "F07", DOUBLE,  OPTIONAL, NULL, NULL, 0 },
    {  8, "F08", STRING,  OPTIONAL, NULL, NULL, 0 },
    {  9, "F09", BYTES,   OPTIONAL, NULL, NULL, 0 },
    { 10, "F10", ENUM,    OPTIONAL, &enum_descriptor, NULL, 0 },
    { 11, "F11", MESSAGE, OPTIONAL, &descriptor, NULL, 0 },
    { 12, "F12", MESSAGE, REPEATED, &descriptor, NULL, 0 }
  }, 12 }, NULL };

/* ----------------------------------------------------------------------------
 * Tests


@@ 120,7 120,7 @@ START_TEST(test_decode) {
  ck_assert_uint_eq(PB_ERROR_NONE, pb_decoder_error(&decoder));

  /* Decode using the handler */
  pb_tag_t tags[12] = {};
  pb_tag_t tags[12] = {0};
  ck_assert_uint_eq(PB_ERROR_NONE,
    pb_decoder_decode(&decoder, handler, tags));



@@ 148,7 148,7 @@ START_TEST(test_decode_message) {
  ck_assert_uint_eq(PB_ERROR_NONE, pb_decoder_error(&decoder));

  /* Decode using the handler */
  pb_tag_t tags[12] = {};
  pb_tag_t tags[12] = {0};
  ck_assert_uint_eq(PB_ERROR_NONE,
    pb_decoder_decode(&decoder, handler, tags));



@@ 177,7 177,7 @@ START_TEST(test_decode_skip) {
  ck_assert_uint_eq(PB_ERROR_NONE, pb_decoder_error(&decoder));

  /* Decode using the handler */
  pb_tag_t tags[12] = {};
  pb_tag_t tags[12] = {0};
  ck_assert_uint_eq(PB_ERROR_NONE,
    pb_decoder_decode(&decoder, handler, tags));



@@ 206,7 206,7 @@ START_TEST(test_decode_packed) {
  ck_assert_uint_eq(PB_ERROR_NONE, pb_decoder_error(&decoder));

  /* Decode using the handler */
  pb_tag_t tags[12] = {};
  pb_tag_t tags[12] = {0};
  ck_assert_uint_eq(PB_ERROR_NONE,
    pb_decoder_decode(&decoder, handler, tags));


M tests/core/descriptor/test.c => tests/core/descriptor/test.c +25 -25
@@ 49,46 49,46 @@ oneof_descriptor = {
static pb_descriptor_t
descriptor = { {
  (const pb_field_descriptor_t []){
    {  1, "F01", UINT32,  ONEOF, NULL, &oneof_descriptor },
    {  2, "F02", UINT64,  ONEOF, NULL, &oneof_descriptor },
    {  3, "F03", SINT32,  ONEOF, NULL, &oneof_descriptor },
    {  4, "F04", SINT64,  OPTIONAL },
    {  5, "F05", BOOL,    OPTIONAL },
    {  6, "F06", FLOAT,   OPTIONAL },
    {  7, "F07", DOUBLE,  OPTIONAL },
    {  8, "F08", STRING,  OPTIONAL },
    {  9, "F09", BYTES,   OPTIONAL },
    { 10, "F10", UINT32,  OPTIONAL },
    { 11, "F11", MESSAGE, OPTIONAL, &descriptor },
    { 12, "F12", MESSAGE, REPEATED, &descriptor }
  }, 12 } };
    {  1, "F01", UINT32,  ONEOF, NULL, &oneof_descriptor, 0 },
    {  2, "F02", UINT64,  ONEOF, NULL, &oneof_descriptor, 0 },
    {  3, "F03", SINT32,  ONEOF, NULL, &oneof_descriptor, 0 },
    {  4, "F04", SINT64,  OPTIONAL, NULL, NULL, 0 },
    {  5, "F05", BOOL,    OPTIONAL, NULL, NULL, 0 },
    {  6, "F06", FLOAT,   OPTIONAL, NULL, NULL, 0 },
    {  7, "F07", DOUBLE,  OPTIONAL, NULL, NULL, 0 },
    {  8, "F08", STRING,  OPTIONAL, NULL, NULL, 0 },
    {  9, "F09", BYTES,   OPTIONAL, NULL, NULL, 0 },
    { 10, "F10", UINT32,  OPTIONAL, NULL, NULL, 0 },
    { 11, "F11", MESSAGE, OPTIONAL, &descriptor, NULL, 0 },
    { 12, "F12", MESSAGE, REPEATED, &descriptor, NULL, 0 }
  }, 12 }, NULL };

/* Empty descriptor */
static pb_descriptor_t
descriptor_empty = {};
descriptor_empty = {0};

/* Scattered descriptor */
static pb_descriptor_t
descriptor_scattered = { {
  (const pb_field_descriptor_t []){
    {  2, "F02", UINT64,  OPTIONAL },
    {  8, "F08", STRING,  OPTIONAL }
  }, 2 } };
    {  2, "F02", UINT64,  OPTIONAL, NULL, NULL, 0 },
    {  8, "F08", STRING,  OPTIONAL, NULL, NULL, 0 }
  }, 2 }, NULL };

/* Extension descriptor */
static pb_descriptor_t
descriptor_extension = { {
  (const pb_field_descriptor_t []){
    { 20, "F20", UINT32,  OPTIONAL },
    { 21, "F21", UINT64,  OPTIONAL }
  }, 2, } };
    { 20, "F20", UINT32,  OPTIONAL, NULL, NULL, 0 },
    { 21, "F21", UINT64,  OPTIONAL, NULL, NULL, 0 }
  }, 2, }, NULL };

/* Nested extension descriptor */
static pb_descriptor_t
descriptor_extension_nested = { {
  (const pb_field_descriptor_t []){
    { 30, "F30", MESSAGE,  OPTIONAL, &descriptor }
  }, 1, } };
    { 30, "F30", MESSAGE,  OPTIONAL, &descriptor, NULL, 0 }
  }, 1, }, NULL };

/* ------------------------------------------------------------------------- */



@@ 103,7 103,7 @@ enum_descriptor = { {

/* Empty enum descriptor */
static pb_enum_descriptor_t
enum_descriptor_empty = {};
enum_descriptor_empty = {0};

/* Scattered enum descriptor */
static pb_enum_descriptor_t


@@ 121,13 121,13 @@ enum_descriptor_scattered = { {
 * Setup
 */
static void
setup() {}
setup(void) {}

/*!
 * Teardown
 */
static void
teardown() {
teardown(void) {
  pb_descriptor_reset(&descriptor);
  pb_descriptor_reset(&descriptor_extension);
}

M tests/core/encoder/test.c => tests/core/encoder/test.c +15 -14
@@ 61,6 61,7 @@ allocator_allocate_fail(void *data, size_t size) {
 */
static void *
allocator_resize_fail(void *data, void *block, size_t size) {
  (void)block;
  assert(!data && size);
  return NULL;
}


@@ 82,19 83,19 @@ enum_descriptor = { {
static pb_descriptor_t
descriptor = { {
  (const pb_field_descriptor_t []){
    {  1, "F01", UINT32,  OPTIONAL },
    {  2, "F02", UINT64,  OPTIONAL },
    {  3, "F03", SINT32,  OPTIONAL },
    {  4, "F04", SINT64,  OPTIONAL },
    {  5, "F05", BOOL,    OPTIONAL },
    {  6, "F06", FLOAT,   OPTIONAL },
    {  7, "F07", DOUBLE,  OPTIONAL },
    {  8, "F08", STRING,  OPTIONAL },
    {  9, "F09", BYTES,   OPTIONAL },
    { 10, "F10", ENUM,    OPTIONAL, &enum_descriptor },
    { 11, "F11", MESSAGE, OPTIONAL, &descriptor },
    { 12, "F12", MESSAGE, REPEATED, &descriptor }
  }, 12 } };
    {  1, "F01", UINT32,  OPTIONAL, NULL, NULL, 0 },
    {  2, "F02", UINT64,  OPTIONAL, NULL, NULL, 0 },
    {  3, "F03", SINT32,  OPTIONAL, NULL, NULL, 0 },
    {  4, "F04", SINT64,  OPTIONAL, NULL, NULL, 0 },
    {  5, "F05", BOOL,    OPTIONAL, NULL, NULL, 0 },
    {  6, "F06", FLOAT,   OPTIONAL, NULL, NULL, 0 },
    {  7, "F07", DOUBLE,  OPTIONAL, NULL, NULL, 0 },
    {  8, "F08", STRING,  OPTIONAL, NULL, NULL, 0 },
    {  9, "F09", BYTES,   OPTIONAL, NULL, NULL, 0 },
    { 10, "F10", ENUM,    OPTIONAL, &enum_descriptor, NULL, 0 },
    { 11, "F11", MESSAGE, OPTIONAL, &descriptor, NULL, 0 },
    { 12, "F12", MESSAGE, REPEATED, &descriptor, NULL, 0 }
  }, 12 }, NULL };

/* Descriptor with packed fields */
static pb_descriptor_t


@@ 104,7 105,7 @@ descriptor_packed = { {
    {  2, "F02", ENUM,    REPEATED, &enum_descriptor, NULL, PACKED },
    {  3, "F03", FLOAT,   REPEATED, NULL, NULL, PACKED },
    {  4, "F04", DOUBLE,  REPEATED, NULL, NULL, PACKED }
  }, 4 } };
  }, 4 }, NULL };

/* ----------------------------------------------------------------------------
 * Tests

M tests/message/buffer/test.c => tests/message/buffer/test.c +1 -0
@@ 57,6 57,7 @@ allocator_allocate_fail(void *data, size_t size) {
 */
static void *
allocator_resize_fail(void *data, void *block, size_t size) {
  (void)block;
  assert(!data && size);
  return NULL;
}

M tests/message/cursor/test.c => tests/message/cursor/test.c +12 -12
@@ 61,20 61,20 @@ oneof_descriptor = {
static pb_descriptor_t
descriptor = { {
  (const pb_field_descriptor_t []){
    {  1, "F01", UINT32,  REPEATED },
    {  2, "F02", UINT64,  OPTIONAL },
    {  1, "F01", UINT32,  REPEATED, NULL, NULL, 0 },
    {  2, "F02", UINT64,  OPTIONAL, NULL, NULL, 0 },
    {  3, "F03", UINT32,  REPEATED, NULL, NULL, PACKED },
    {  4, "F04", SINT64,  REPEATED },
    {  4, "F04", SINT64,  REPEATED, NULL, NULL, 0 },
    {  5, "F05", FLOAT,   REPEATED, NULL, NULL, PACKED },
    {  6, "F06", FLOAT,   OPTIONAL, NULL, &default_float },
    {  7, "F07", DOUBLE,  REPEATED },
    {  8, "F08", STRING,  REPEATED },
    {  9, "F09", MESSAGE, REPEATED, &descriptor },
    { 10, "F10", MESSAGE, OPTIONAL, &descriptor },
    { 11, "F11", UINT32,  ONEOF, NULL, &oneof_descriptor },
    { 12, "F12", UINT32,  ONEOF, NULL, &oneof_descriptor },
    { 13, "F13", MESSAGE, ONEOF, &descriptor, &oneof_descriptor }
  }, 13 } };
    {  6, "F06", FLOAT,   OPTIONAL, NULL, &default_float, 0 },
    {  7, "F07", DOUBLE,  REPEATED, NULL, NULL, 0 },
    {  8, "F08", STRING,  REPEATED, NULL, NULL, 0 },
    {  9, "F09", MESSAGE, REPEATED, &descriptor, NULL, 0 },
    { 10, "F10", MESSAGE, OPTIONAL, &descriptor, NULL, 0 },
    { 11, "F11", UINT32,  ONEOF, NULL, &oneof_descriptor, 0 },
    { 12, "F12", UINT32,  ONEOF, NULL, &oneof_descriptor, 0 },
    { 13, "F13", MESSAGE, ONEOF, &descriptor, &oneof_descriptor, 0 }
  }, 13 }, NULL };

/* ----------------------------------------------------------------------------
 * Tests

M tests/message/field/test.c => tests/message/field/test.c +15 -15
@@ 90,20 90,20 @@ descriptor_enum = { {
static pb_descriptor_t
descriptor = { {
  (const pb_field_descriptor_t []){
    {  1, "F01", UINT32,  OPTIONAL, NULL, &default_uint32 },
    {  2, "F02", UINT64,  OPTIONAL, NULL, &default_uint64 },
    {  3, "F03", SINT32,  OPTIONAL, NULL, &default_int32 },
    {  4, "F04", SINT64,  OPTIONAL, NULL, &default_int64 },
    {  5, "F05", BOOL,    OPTIONAL, NULL, &default_bool },
    {  6, "F06", FLOAT,   OPTIONAL, NULL, &default_float },
    {  7, "F07", DOUBLE,  OPTIONAL, NULL, &default_double },
    {  8, "F08", STRING,  OPTIONAL, NULL, &default_string },
    {  9, "F09", ENUM,    OPTIONAL, &descriptor_enum, &default_enum },
    { 10, "F10", UINT64,  REPEATED },
    { 11, "F11", STRING,  REPEATED },
    { 12, "F12", MESSAGE, OPTIONAL, &descriptor },
    {  1, "F01", UINT32,  OPTIONAL, NULL, &default_uint32, 0 },
    {  2, "F02", UINT64,  OPTIONAL, NULL, &default_uint64, 0 },
    {  3, "F03", SINT32,  OPTIONAL, NULL, &default_int32, 0 },
    {  4, "F04", SINT64,  OPTIONAL, NULL, &default_int64, 0 },
    {  5, "F05", BOOL,    OPTIONAL, NULL, &default_bool, 0 },
    {  6, "F06", FLOAT,   OPTIONAL, NULL, &default_float, 0 },
    {  7, "F07", DOUBLE,  OPTIONAL, NULL, &default_double, 0 },
    {  8, "F08", STRING,  OPTIONAL, NULL, &default_string, 0 },
    {  9, "F09", ENUM,    OPTIONAL, &descriptor_enum, &default_enum, 0 },
    { 10, "F10", UINT64,  REPEATED, NULL, NULL, 0 },
    { 11, "F11", STRING,  REPEATED, NULL, NULL, 0 },
    { 12, "F12", MESSAGE, OPTIONAL, &descriptor, NULL, 0 },
    { 13, "F11", UINT64,  REPEATED, NULL, NULL, PACKED },
  }, 13 } };
  }, 13 }, NULL };

/* ----------------------------------------------------------------------------
 * Tests


@@ 484,7 484,7 @@ START_TEST(test_create_nested) {
    pb_message_destroy(&(messages[m]));

  /* Create tags */
  pb_tag_t tags[101] = {};
  pb_tag_t tags[101] = {0};
  for (size_t t = 0; t < 100; t++)
    tags[t] = 12;
  tags[100] = 1;


@@ 515,7 515,7 @@ START_TEST(test_create_nested_invalid) {
  ck_assert_uint_eq(PB_ERROR_INVALID, pb_message_error(&message));

  /* Create tags */
  pb_tag_t tags[100] = {};
  pb_tag_t tags[100] = {0};
  for (size_t t = 0; t < 100; t++)
    tags[t] = 1;


M tests/message/journal/test.c => tests/message/journal/test.c +4 -3
@@ 57,6 57,7 @@ allocator_allocate_fail(void *data, size_t size) {
 */
static void *
allocator_resize_fail(void *data, void *block, size_t size) {
  (void)block;
  assert(!data && size);
  return NULL;
}


@@ 641,7 642,7 @@ START_TEST(test_align) {
  }

  /* Perform alignment */
  pb_version_t version = 0; pb_offset_t offset = { 0, 0 };
  pb_version_t version = 0; pb_offset_t offset = { 0, 0, {0} };
  ck_assert_uint_eq(PB_ERROR_NONE,
    pb_journal_align(&journal, &version, &offset));



@@ 684,7 685,7 @@ START_TEST(test_align_move) {
  ck_assert_uint_eq(1, pb_journal_version(&journal));

  /* Perform alignment */
  pb_version_t version = 0; pb_offset_t offset = { 8, 9 };
  pb_version_t version = 0; pb_offset_t offset = { 8, 9, {0} };
  ck_assert_uint_eq(PB_ERROR_NONE,
    pb_journal_align(&journal, &version, &offset));



@@ 1013,7 1014,7 @@ START_TEST(test_align_invalid) {
  ck_assert_uint_eq(PB_ERROR_ALLOC, pb_journal_error(&journal));

  /* Perform alignment */
  pb_version_t version = 0; pb_offset_t offset = { 0, 0 };
  pb_version_t version = 0; pb_offset_t offset = { 0, 0, {0} };
  ck_assert_uint_eq(PB_ERROR_INVALID,
    pb_journal_align(&journal, &version, &offset));


M tests/message/message/test.c => tests/message/message/test.c +19 -19
@@ 91,22 91,22 @@ oneof_descriptor = {
static pb_descriptor_t
descriptor = { {
  (const pb_field_descriptor_t []){
    {  1, "F01", UINT32,  OPTIONAL, NULL, &default_uint32 },
    {  2, "F02", UINT64,  OPTIONAL, NULL, &default_uint64 },
    {  3, "F03", SINT32,  OPTIONAL, NULL, &default_int32 },
    {  4, "F04", SINT64,  OPTIONAL, NULL, &default_int64 },
    {  5, "F05", BOOL,    OPTIONAL, NULL, &default_bool },
    {  6, "F06", FLOAT,   OPTIONAL, NULL, &default_float },
    {  7, "F07", DOUBLE,  OPTIONAL, NULL, &default_double },
    {  8, "F08", STRING,  OPTIONAL, NULL, &default_string },
    {  9, "F09", BYTES,   OPTIONAL },
    { 10, "F10", UINT32,  OPTIONAL },
    { 11, "F11", MESSAGE, OPTIONAL, &descriptor },
    { 12, "F12", MESSAGE, REPEATED, &descriptor },
    { 13, "F13", UINT32,  ONEOF, NULL, &oneof_descriptor },
    { 14, "F14", UINT32,  ONEOF, NULL, &oneof_descriptor },
    { 15, "F15", MESSAGE, ONEOF, &descriptor, &oneof_descriptor }
  }, 15 } };
    {  1, "F01", UINT32,  OPTIONAL, NULL, &default_uint32, 0 },
    {  2, "F02", UINT64,  OPTIONAL, NULL, &default_uint64, 0 },
    {  3, "F03", SINT32,  OPTIONAL, NULL, &default_int32, 0 },
    {  4, "F04", SINT64,  OPTIONAL, NULL, &default_int64, 0 },
    {  5, "F05", BOOL,    OPTIONAL, NULL, &default_bool, 0 },
    {  6, "F06", FLOAT,   OPTIONAL, NULL, &default_float, 0 },
    {  7, "F07", DOUBLE,  OPTIONAL, NULL, &default_double, 0 },
    {  8, "F08", STRING,  OPTIONAL, NULL, &default_string, 0 },
    {  9, "F09", BYTES,   OPTIONAL, NULL, NULL, 0 },
    { 10, "F10", UINT32,  OPTIONAL, NULL, NULL, 0 },
    { 11, "F11", MESSAGE, OPTIONAL, &descriptor, NULL, 0 },
    { 12, "F12", MESSAGE, REPEATED, &descriptor, NULL, 0 },
    { 13, "F13", UINT32,  ONEOF, NULL, &oneof_descriptor, 0 },
    { 14, "F14", UINT32,  ONEOF, NULL, &oneof_descriptor, 0 },
    { 15, "F15", MESSAGE, ONEOF, &descriptor, &oneof_descriptor, 0 }
  }, 15 }, NULL };

/* ----------------------------------------------------------------------------
 * Tests


@@ 654,7 654,7 @@ START_TEST(test_create_nested) {
    pb_message_destroy(&(messages[m]));

  /* Create tags */
  pb_tag_t tags[100] = {};
  pb_tag_t tags[100] = {0};
  for (size_t t = 0; t < 100; t++)
    tags[t] = 11;



@@ 751,7 751,7 @@ START_TEST(test_create_nested_repeated) {
  }

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 12;


@@ 814,7 814,7 @@ START_TEST(test_create_nested_invalid) {
  ck_assert_uint_eq(PB_ERROR_INVALID, pb_message_error(&message));

  /* Create tags */
  pb_tag_t tags[100] = {};
  pb_tag_t tags[100] = {0};
  for (size_t t = 0; t < 100; t++)
    tags[t] = 11;


M tests/message/nested/test.c => tests/message/nested/test.c +39 -39
@@ 52,19 52,19 @@ default_uint64 = 1000000000000000000ULL;
static pb_descriptor_t
descriptor = { {
  (const pb_field_descriptor_t []){
    {  1, "F01", UINT32,  OPTIONAL, NULL, &default_uint32 },
    {  2, "F02", UINT64,  OPTIONAL, NULL, &default_uint64 },
    {  3, "F03", SINT32,  OPTIONAL },
    {  4, "F04", SINT64,  REPEATED },
    {  5, "F05", BOOL,    OPTIONAL },
    {  6, "F06", FLOAT,   OPTIONAL },
    {  7, "F07", DOUBLE,  OPTIONAL },
    {  8, "F08", STRING,  OPTIONAL },
    {  9, "F09", BYTES,   OPTIONAL },
    {  1, "F01", UINT32,  OPTIONAL, NULL, &default_uint32, 0 },
    {  2, "F02", UINT64,  OPTIONAL, NULL, &default_uint64, 0 },
    {  3, "F03", SINT32,  OPTIONAL, NULL, NULL, 0 },
    {  4, "F04", SINT64,  REPEATED, NULL, NULL, 0 },
    {  5, "F05", BOOL,    OPTIONAL, NULL, NULL, 0 },
    {  6, "F06", FLOAT,   OPTIONAL, NULL, NULL, 0 },
    {  7, "F07", DOUBLE,  OPTIONAL, NULL, NULL, 0 },
    {  8, "F08", STRING,  OPTIONAL, NULL, NULL, 0 },
    {  9, "F09", BYTES,   OPTIONAL, NULL, NULL, 0 },
    { 10, "F10", UINT32,  REPEATED, NULL, NULL, PACKED },
    { 11, "F11", MESSAGE, OPTIONAL, &descriptor },
    { 12, "F12", MESSAGE, REPEATED, &descriptor }
  }, 12 } };
    { 11, "F11", MESSAGE, OPTIONAL, &descriptor, NULL, 0 },
    { 12, "F12", MESSAGE, REPEATED, &descriptor, NULL, 0 }
  }, 12 }, NULL };

/* ----------------------------------------------------------------------------
 * Tests


@@ 86,7 86,7 @@ START_TEST(test_has) {
  }

  /* Iterate over submessages */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 100; t++) {
    tags[t] = 11; tags[t + 1] = 2;



@@ 116,7 116,7 @@ START_TEST(test_has_empty) {
  pb_message_t message = pb_message_create(&descriptor, &journal);

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 2;


@@ 149,7 149,7 @@ START_TEST(test_has_repeated) {
  }

  /* Iterate over submessages */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 100; t++) {
    tags[t] = 11; tags[t + 1] = 4;



@@ 192,7 192,7 @@ START_TEST(test_has_unaligned) {
    pb_message_put(&(messages[0]), 1, &value));

  /* Iterate over submessages */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 100; t++) {
    tags[t] = 11; tags[t + 1] = 2;



@@ 225,7 225,7 @@ START_TEST(test_has_invalid) {
  ck_assert_uint_eq(PB_ERROR_INVALID, pb_message_error(&message));

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 2;


@@ 253,7 253,7 @@ START_TEST(test_match) {
  }

  /* Iterate over submessages */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 100; t++) {
    tags[t] = 11; tags[t + 1] = 2;



@@ 280,7 280,7 @@ START_TEST(test_match_empty) {
  pb_message_t message = pb_message_create(&descriptor, &journal);

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 2;


@@ 314,7 314,7 @@ START_TEST(test_match_repeated) {
  }

  /* Iterate over submessages */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 100; t++) {
    tags[t] = 11; tags[t + 1] = 4;



@@ 358,7 358,7 @@ START_TEST(test_match_unaligned) {
    pb_message_put(&(messages[0]), 1, &value));

  /* Iterate over submessages */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 100; t++) {
    tags[t] = 11; tags[t + 1] = 2;



@@ 388,7 388,7 @@ START_TEST(test_match_invalid) {
  ck_assert_uint_eq(PB_ERROR_INVALID, pb_message_error(&message));

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 2;


@@ 417,7 417,7 @@ START_TEST(test_get) {
  }

  /* Iterate over submessages */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 100; t++) {
    tags[t] = 11; tags[t + 1] = 2;



@@ 450,7 450,7 @@ START_TEST(test_get_default) {
    messages[m] = pb_message_create_within(&(messages[m - 1]), 11);

  /* Create tags */
  pb_tag_t tags[101] = {};
  pb_tag_t tags[101] = {0};
  for (size_t t = 0; t < 100; t++)
    tags[t] = 11;
  tags[100] = 2;


@@ 487,7 487,7 @@ START_TEST(test_get_absent) {
  }

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 10;


@@ 529,7 529,7 @@ START_TEST(test_get_unaligned) {
    pb_message_put(&(messages[0]), 1, &value));

  /* Iterate over submessages */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 100; t++) {
    tags[t] = 11; tags[t + 1] = 2;



@@ 561,7 561,7 @@ START_TEST(test_get_invalid) {
  ck_assert_uint_eq(PB_ERROR_INVALID, pb_message_error(&message));

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 2;


@@ 584,7 584,7 @@ START_TEST(test_put) {
  pb_message_t message = pb_message_create(&descriptor, &journal);

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 2;


@@ 617,7 617,7 @@ START_TEST(test_put_existing) {
  pb_message_t message = pb_message_create(&descriptor, &journal);

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 2;


@@ 655,7 655,7 @@ START_TEST(test_put_packed) {
  pb_message_t message = pb_message_create(&descriptor, &journal);

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 10;


@@ 696,7 696,7 @@ START_TEST(test_put_message) {
  pb_message_t message2 = pb_message_create(&descriptor, &journal2);

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 1;


@@ 732,7 732,7 @@ START_TEST(test_put_unaligned) {
  pb_message_t message = pb_message_create(&descriptor, &journal);

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 2;


@@ 768,7 768,7 @@ START_TEST(test_put_invalid) {
  pb_message_t message = pb_message_create_invalid();

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 2;


@@ 790,7 790,7 @@ START_TEST(test_erase) {
  pb_message_t message = pb_message_create(&descriptor, &journal);

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 3;


@@ 833,7 833,7 @@ START_TEST(test_erase_empty) {
  pb_message_t message = pb_message_create(&descriptor, &journal);

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 3;


@@ 866,7 866,7 @@ START_TEST(test_erase_packed) {
  pb_message_t message = pb_message_create(&descriptor, &journal);

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 10;


@@ 909,7 909,7 @@ START_TEST(test_erase_message) {
  pb_message_t message2 = pb_message_create(&descriptor, &journal2);

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 1;


@@ 945,7 945,7 @@ START_TEST(test_erase_unaligned) {
  pb_message_t message = pb_message_create(&descriptor, &journal);

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 3;


@@ 995,7 995,7 @@ START_TEST(test_erase_invalid) {
  ck_assert_uint_eq(PB_ERROR_INVALID, pb_message_error(&message));

  /* Create tags */
  pb_tag_t tags[102] = {};
  pb_tag_t tags[102] = {0};
  for (size_t t = 0; t < 101; t++)
    tags[t] = 11;
  tags[101] = 2;

M tests/message/oneof/test.c => tests/message/oneof/test.c +5 -5
@@ 52,11 52,11 @@ oneof_descriptor = {
static pb_descriptor_t
descriptor = { {
  (const pb_field_descriptor_t []){
    {  1, "F01", UINT32,  OPTIONAL },
    {  2, "F02", UINT32,  ONEOF, NULL, &oneof_descriptor },
    {  3, "F03", UINT32,  ONEOF, NULL, &oneof_descriptor },
    {  4, "F04", MESSAGE, ONEOF, &descriptor, &oneof_descriptor }
  }, 4 } };
    {  1, "F01", UINT32,  OPTIONAL, NULL, NULL, 9 },
    {  2, "F02", UINT32,  ONEOF, NULL, &oneof_descriptor, 0 },
    {  3, "F03", UINT32,  ONEOF, NULL, &oneof_descriptor, 0 },
    {  4, "F04", MESSAGE, ONEOF, &descriptor, &oneof_descriptor, 0 }
  }, 4 }, NULL };

/* ----------------------------------------------------------------------------
 * Tests

M tests/message/part/test.c => tests/message/part/test.c +14 -13
@@ 48,6 48,7 @@
 */
static void *
allocator_resize_fail(void *data, void *block, size_t size) {
  (void)block;
  assert(!data && size);
  return NULL;
}


@@ 72,19 73,19 @@ oneof_descriptor = {
static pb_descriptor_t
descriptor = { {
  (const pb_field_descriptor_t []){
    {  1, "F01", UINT32,  OPTIONAL },
    {  2, "F02", UINT64,  OPTIONAL },
    {  3, "F03", SINT32,  ONEOF, NULL, &oneof_descriptor },
    {  4, "F04", SINT64,  ONEOF, NULL, &oneof_descriptor },
    {  5, "F05", BOOL,    OPTIONAL },
    {  6, "F06", FLOAT,   ONEOF, NULL, &oneof_descriptor },
    {  7, "F07", DOUBLE,  OPTIONAL },
    {  8, "F08", STRING,  OPTIONAL },
    {  9, "F09", UINT32,  REPEATED },
    { 10, "F10", UINT64,  REPEATED },
    { 11, "F11", STRING,  REPEATED },
    { 12, "F12", MESSAGE, ONEOF, &descriptor, &oneof_descriptor }
  }, 12 } };
    {  1, "F01", UINT32,  OPTIONAL, NULL, NULL, 0 },
    {  2, "F02", UINT64,  OPTIONAL, NULL, NULL, 0 },
    {  3, "F03", SINT32,  ONEOF, NULL, &oneof_descriptor, 0 },
    {  4, "F04", SINT64,  ONEOF, NULL, &oneof_descriptor, 0 },
    {  5, "F05", BOOL,    OPTIONAL, NULL, NULL, 0 },
    {  6, "F06", FLOAT,   ONEOF, NULL, &oneof_descriptor, 0 },
    {  7, "F07", DOUBLE,  OPTIONAL, NULL, NULL, 0 },
    {  8, "F08", STRING,  OPTIONAL, NULL, NULL, 0 },
    {  9, "F09", UINT32,  REPEATED, NULL, NULL, 0 },
    { 10, "F10", UINT64,  REPEATED, NULL, NULL, 0 },
    { 11, "F11", STRING,  REPEATED, NULL, NULL, 0 },
    { 12, "F12", MESSAGE, ONEOF, &descriptor, &oneof_descriptor, 0 }
  }, 12 }, NULL };

/* ----------------------------------------------------------------------------
 * Tests

M tests/util/descriptor/test.c => tests/util/descriptor/test.c +25 -25
@@ 37,46 37,46 @@
static pb_descriptor_t
descriptor = { {
  (const pb_field_descriptor_t []){
    {  1, "F01", UINT32,  OPTIONAL },
    {  2, "F02", UINT64,  OPTIONAL },
    {  3, "F03", SINT32,  OPTIONAL },
    {  4, "F04", SINT64,  OPTIONAL },
    {  5, "F05", BOOL,    OPTIONAL },
    {  6, "F06", FLOAT,   OPTIONAL },
    {  7, "F07", DOUBLE,  OPTIONAL },
    {  8, "F08", STRING,  OPTIONAL },
    {  9, "F09", BYTES,   OPTIONAL },
    { 10, "F10", UINT32,  OPTIONAL },
    { 11, "F11", MESSAGE, OPTIONAL, &descriptor },
    { 12, "F12", MESSAGE, REPEATED, &descriptor }
  }, 12 } };
    {  1, "F01", UINT32,  OPTIONAL, NULL, NULL, 0 },
    {  2, "F02", UINT64,  OPTIONAL, NULL, NULL, 0 },
    {  3, "F03", SINT32,  OPTIONAL, NULL, NULL, 0 },
    {  4, "F04", SINT64,  OPTIONAL, NULL, NULL, 0 },
    {  5, "F05", BOOL,    OPTIONAL, NULL, NULL, 0 },
    {  6, "F06", FLOAT,   OPTIONAL, NULL, NULL, 0 },
    {  7, "F07", DOUBLE,  OPTIONAL, NULL, NULL, 0 },
    {  8, "F08", STRING,  OPTIONAL, NULL, NULL, 0 },
    {  9, "F09", BYTES,   OPTIONAL, NULL, NULL, 0 },
    { 10, "F10", UINT32,  OPTIONAL, NULL, NULL, 0 },
    { 11, "F11", MESSAGE, OPTIONAL, &descriptor, NULL, 0 },
    { 12, "F12", MESSAGE, REPEATED, &descriptor, NULL, 0 }
  }, 12 }, NULL };

/* Empty descriptor */
static pb_descriptor_t
descriptor_empty = {};
descriptor_empty = {0};

/* Scattered descriptor */
static pb_descriptor_t
descriptor_scattered = { {
  (const pb_field_descriptor_t []){
    {  2, "F02", UINT64,  OPTIONAL },
    {  8, "F08", STRING,  OPTIONAL }
  }, 2 } };
    {  2, "F02", UINT64,  OPTIONAL, NULL, NULL, 0 },
    {  8, "F08", STRING,  OPTIONAL, NULL, NULL, 0 }
  }, 2 }, NULL };

/* Extension descriptor */
static pb_descriptor_t
descriptor_extension = { {
  (const pb_field_descriptor_t []){
    { 20, "F20", UINT32,  OPTIONAL },
    { 21, "F21", UINT64,  OPTIONAL }
  }, 2, } };
    { 20, "F20", UINT32,  OPTIONAL, NULL, NULL, 0 },
    { 21, "F21", UINT64,  OPTIONAL, NULL, NULL, 0 }
  }, 2, }, NULL };

/* Nested extension descriptor */
static pb_descriptor_t
descriptor_extension_nested = { {
  (const pb_field_descriptor_t []){
    { 30, "F30", MESSAGE, OPTIONAL, &descriptor }
  }, 1, } };
    { 30, "F30", MESSAGE, OPTIONAL, &descriptor, NULL, 0 }
  }, 1, }, NULL };

/* ------------------------------------------------------------------------- */



@@ 91,7 91,7 @@ enum_descriptor = { {

/* Empty enum descriptor */
static pb_enum_descriptor_t
enum_descriptor_empty = {};
enum_descriptor_empty = {0};

/* Scattered enum descriptor */
static pb_enum_descriptor_t


@@ 109,13 109,13 @@ enum_descriptor_scattered = { {
 * Setup
 */
static void
setup() {}
setup(void) {}

/*!
 * Teardown
 */
static void
teardown() {
teardown(void) {
  pb_descriptor_reset(&descriptor);
  pb_descriptor_reset(&descriptor_extension);
}

M tests/util/validator/test.c => tests/util/validator/test.c +11 -11
@@ 40,30 40,30 @@
static pb_descriptor_t
descriptor = { {
  (const pb_field_descriptor_t []){
    {  1, "F01", UINT32,  REQUIRED },
    {  2, "F02", UINT64,  REQUIRED },
    {  3, "F03", MESSAGE, OPTIONAL, &descriptor },
    {  4, "F04", MESSAGE, REPEATED, &descriptor }
  }, 4 } };
    {  1, "F01", UINT32,  REQUIRED, NULL, NULL, 0 },
    {  2, "F02", UINT64,  REQUIRED, NULL, NULL, 0 },
    {  3, "F03", MESSAGE, OPTIONAL, &descriptor, NULL, 0 },
    {  4, "F04", MESSAGE, REPEATED, &descriptor, NULL, 0 }
  }, 4 }, NULL };

/* Empty descriptor */
static pb_descriptor_t
descriptor_empty = {};
descriptor_empty = {0};

/* Extension descriptor */
static pb_descriptor_t
descriptor_extension = { {
  (const pb_field_descriptor_t []){
    { 20, "F20", UINT32,  OPTIONAL },
    { 21, "F21", UINT64,  OPTIONAL }
  }, 2, } };
    { 20, "F20", UINT32,  OPTIONAL, NULL, NULL, 0 },
    { 21, "F21", UINT64,  OPTIONAL, NULL, NULL, 0 }
  }, 2, }, NULL };

/* Nested extension descriptor */
static pb_descriptor_t
descriptor_extension_nested = { {
  (const pb_field_descriptor_t []){
    { 30, "F30", MESSAGE, OPTIONAL, &descriptor }
  }, 1, } };
    { 30, "F30", MESSAGE, OPTIONAL, &descriptor, NULL, 0 }
  }, 1, }, NULL };

/* ----------------------------------------------------------------------------
 * Tests