From: Jérémie Galarneau Date: Mon, 6 Oct 2014 01:17:01 +0000 (-0400) Subject: Fix: scan-build warnings in CTF Writer/IR tests X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=d50c7132ced3b2fb562235d3f3c8d6f9a15caaf1;p=deliverable%2Fbabeltrace.git Fix: scan-build warnings in CTF Writer/IR tests scan-build reported that strcmp could be called on a NULL string when some tests fail. Signed-off-by: Jérémie Galarneau --- diff --git a/tests/lib/test_ctf_writer.c b/tests/lib/test_ctf_writer.c index 3a0d8c807..227ca5043 100644 --- a/tests/lib/test_ctf_writer.c +++ b/tests/lib/test_ctf_writer.c @@ -906,7 +906,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, "bt_ctf_field_string_get_value correctly handles NULL"); ret_string = bt_ctf_field_string_get_value(a_string_field); ok(ret_string, "bt_ctf_field_string_get_value returns a string"); - ok(!strcmp(ret_string, test_string), + ok(ret_string ? !strcmp(ret_string, test_string) : 0, "bt_ctf_field_string_get_value returns a correct value"); bt_ctf_field_unsigned_integer_set_value(uint_35_field, SEQUENCE_TEST_LENGTH); @@ -1479,7 +1479,7 @@ int main(int argc, char **argv) ok(clock, "Clock created sucessfully"); returned_clock_name = bt_ctf_clock_get_name(clock); ok(returned_clock_name, "bt_ctf_clock_get_name returns a clock name"); - ok(strcmp(returned_clock_name, clock_name) == 0, + ok(returned_clock_name ? !strcmp(returned_clock_name, clock_name) : 0, "Returned clock name is valid"); returned_clock_description = bt_ctf_clock_get_description(clock); @@ -1490,7 +1490,8 @@ int main(int argc, char **argv) returned_clock_description = bt_ctf_clock_get_description(clock); ok(returned_clock_description, "bt_ctf_clock_get_description returns a description."); - ok(strcmp(returned_clock_description, clock_description) == 0, + ok(returned_clock_description ? + !strcmp(returned_clock_description, clock_description) : 0, "Returned clock description is valid"); ok(bt_ctf_clock_get_frequency(clock) == DEFAULT_CLOCK_FREQ,