From cedd6b675f6663baffc194238bbe30fff2bb9d67 Mon Sep 17 00:00:00 2001 From: Deniz Evrenci Date: Thu, 9 May 2019 21:05:13 +0900 Subject: [PATCH 1/3] [C] Suppress maybe-uninitialized warnings in tests. --- sbe-tool/src/test/c/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbe-tool/src/test/c/CMakeLists.txt b/sbe-tool/src/test/c/CMakeLists.txt index d5d2a85b53..47f0aba0db 100644 --- a/sbe-tool/src/test/c/CMakeLists.txt +++ b/sbe-tool/src/test/c/CMakeLists.txt @@ -22,7 +22,7 @@ function(sbe_test name) ) target_compile_options("C${name}" PRIVATE $<$:-Werror>) target_compile_options("C${name}" PRIVATE $<$:-Werror>) - target_compile_options("C${name}" PRIVATE $<$:-Werror>) + target_compile_options("C${name}" PRIVATE $<$:-Werror -Wno-maybe-uninitialized>) target_link_libraries("C${name}" ${GTEST_LIBS} ${CMAKE_THREAD_LIBS_INIT}) add_test(NAME C${name} COMMAND C${name} WORKING_DIRECTORY ${C_CODEC_TARGET_DIR}) add_dependencies(C${name} gtest) From fca6783f7da4b855207920b07926bb67a6bf8219 Mon Sep 17 00:00:00 2001 From: Deniz Evrenci Date: Wed, 10 Apr 2019 16:05:49 +0900 Subject: [PATCH 2/3] [C] Add blank line after length check block. --- .../java/uk/co/real_logic/sbe/generation/c/CGenerator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/c/CGenerator.java b/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/c/CGenerator.java index 0219f89034..1d8fe1584d 100755 --- a/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/c/CGenerator.java +++ b/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/c/CGenerator.java @@ -1595,7 +1595,8 @@ private CharSequence generateArrayProperty( " {\n" + " errno = E105;\n" + " return NULL;\n" + - " }\n" + + " }\n\n" + + "%5$s\n" + " return codec;\n" + "}\n", From d779017287071ff1e2d29bb2829665297066e8d8 Mon Sep 17 00:00:00 2001 From: Deniz Evrenci Date: Sat, 4 May 2019 15:05:04 +0900 Subject: [PATCH 3/3] [C] Remove the dimension member from the codec classes. --- .../sbe/generation/c/CGenerator.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/c/CGenerator.java b/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/c/CGenerator.java index 1d8fe1584d..8107b6e8e4 100755 --- a/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/c/CGenerator.java +++ b/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/c/CGenerator.java @@ -217,10 +217,8 @@ private static void generateGroupStruct( final List tokens, final int index) { - final String dimensionsStructName = formatScopedName(scope, tokens.get(index + 1).name()); - sb.append(String.format("\n" + - "struct %1$s\n" + + "struct %s\n" + "{\n" + " char *buffer;\n" + " uint64_t buffer_length;\n" + @@ -230,9 +228,8 @@ private static void generateGroupStruct( " uint64_t index;\n" + " uint64_t offset;\n" + " uint64_t acting_version;\n" + - " struct %2$s dimensions;\n" + "};\n", - groupName, dimensionsStructName)); + groupName)); } private static void generateGroupHeaderFunctions( @@ -265,12 +262,13 @@ private static void generateGroupHeaderFunctions( "{\n" + " codec->buffer = buffer;\n" + " codec->buffer_length = buffer_length;\n" + - " if (!%2$s_wrap(&codec->dimensions, codec->buffer, *pos, acting_version, buffer_length))\n" + + " struct %2$s dimensions;\n" + + " if (!%2$s_wrap(&dimensions, codec->buffer, *pos, acting_version, buffer_length))\n" + " {\n" + " return NULL;\n" + " }\n" + - " codec->block_length = %2$s_blockLength(&codec->dimensions);\n" + - " codec->count = %2$s_numInGroup(&codec->dimensions);\n" + + " codec->block_length = %2$s_blockLength(&dimensions);\n" + + " codec->count = %2$s_numInGroup(&dimensions);\n" + " codec->index = -1;\n" + " codec->acting_version = acting_version;\n" + " codec->position_ptr = pos;\n" + @@ -305,12 +303,13 @@ private static void generateGroupHeaderFunctions( "#endif\n" + " codec->buffer = buffer;\n" + " codec->buffer_length = buffer_length;\n" + - " if (!%5$s_wrap(&codec->dimensions, codec->buffer, *pos, acting_version, buffer_length))\n" + + " struct %5$s dimensions;\n" + + " if (!%5$s_wrap(&dimensions, codec->buffer, *pos, acting_version, buffer_length))\n" + " {\n" + " return NULL;\n" + " }\n" + - " %5$s_set_blockLength(&codec->dimensions, (%2$s)%3$d);\n" + - " %5$s_set_numInGroup(&codec->dimensions, (%4$s)count);\n" + + " %5$s_set_blockLength(&dimensions, (%2$s)%3$d);\n" + + " %5$s_set_numInGroup(&dimensions, (%4$s)count);\n" + " codec->index = -1;\n" + " codec->count = count;\n" + " codec->block_length = %3$d;\n" +