Fix unit tests under Clang build.
cover Fix unit tests under Clang build.
This patch set addresses unit test build warnings and a segmentation fault when ELL is built with the Clang C compiler.
Ossama Othman (2):
unit: Remove unnecessary NULL pointer checks.
unit: Fixed a test-dbus-message seg fault.
unit/test-dbus-message.c | 2 +- unit/test-dhcp.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 unit: Remove unnecessary NULL pointer checks.
Several unnecessary NULL pointer checks existed in unit/test-dhcp.c. The pointers in question were actually arrays visible to the compiler. Remove those NULL pointer checks to address "always true" warnings exhibited by the Clang C compiler.
--- unit/test-dhcp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
unit/test-dhcp.c +3 -3
@@ -177,13 +177,13 @@ static struct dhcp_message *create_message(const struct option_test *test, opt[2 ] =83 ; opt[3 ] =99 ; -if (test->options && test->len) +if (test->len)memcpy (&opt[4 ], test->options, test->len); -if (test->file && test->filelen <=128 ) +if (test->filelen <=128 )memcpy (&message->file, test->file, test->filelen); -if (test->sname && test->snamelen <=64 ) +if (test->snamelen <=64 )memcpy (&message->sname, test->sname, test->snamelen);if (out_len)
Signature · 1 line
2.17.1
PATCH 2/2 unit: Fixed a test-dbus-message seg fault.
In reply to Ossama OthmanThe parse_struct_3() test in unit/test-dbus-message.c exhibited a segmentation fault, flagged as "bad memory permissions" in valgrind, when built with the Clang C compiler. The problem was caused by attempts by the l_dbus_message_get_arguments() function to write to read-only memory since pointers to constant integer array elements were passed as the "out" arguments. Remove the "const" from the integer array declaration to permit writes to the array elements.
--- unit/test-dbus-message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
unit/test-dbus-message.c +1 -1
@@ -1820,7 +1820,7 @@ static void build_struct_2(const void *data)static void parse_struct_3 (const void *data) {struct l_dbus_message *msg =check_message (data); -const int num[32 ] = {0 }; +int num[32 ] = {0 };bool result;int i;
Signature · 1 line
2.17.1
Hi Ossama,
Quoted 11 lines · Ossama Othman
This patch set addresses unit test build warnings and a segmentation fault when ELL is built with the Clang C compiler.
Ossama Othman (2):
unit: Remove unnecessary NULL pointer checks.
unit: Fixed a test-dbus-message seg fault.unit/test-dbus-message.c | 2 +- unit/test-dhcp.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
Both applied, thanks.
Regards,
-Denis