From 18d968e794c44eb52132743d84de12bdd4719d28 Mon Sep 17 00:00:00 2001 From: "Nicola Spanti (RyDroid)" Date: Sat, 4 Mar 2017 12:13:11 +0100 Subject: [PATCH] Very minor improvements in C source code --- src/check.c | 1 - src/check_log.c | 18 +++++++++--------- src/check_msg.c | 4 ++++ tests/check_check_master.c | 8 ++++---- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/check.c b/src/check.c index 7e4427ce..a9481f82 100644 --- a/src/check.c +++ b/src/check.c @@ -215,7 +215,6 @@ static void tcase_free(TCase * tc) unsigned int tcase_matching_tag(TCase *tc, List *check_for) { - if (NULL == check_for) { return 0; diff --git a/src/check_log.c b/src/check_log.c index 2af83210..70c3dca3 100644 --- a/src/check_log.c +++ b/src/check_log.c @@ -94,11 +94,6 @@ void srunner_set_tap(SRunner * sr, const char *fname) sr->tap_fname = fname; } -int srunner_has_tap(SRunner * sr) -{ - return srunner_tap_fname(sr) != NULL; -} - const char *srunner_tap_fname(SRunner * sr) { /* check if tap log filename have been set explicitly */ @@ -110,6 +105,11 @@ const char *srunner_tap_fname(SRunner * sr) return getenv("CK_TAP_LOG_FILE_NAME"); } +int srunner_has_tap(SRunner * sr) +{ + return srunner_tap_fname(sr) != NULL; +} + void srunner_register_lfun(SRunner * sr, FILE * lfile, int close, LFun lfun, enum print_output printmode) { @@ -344,7 +344,7 @@ void tap_lfun(SRunner * sr CK_ATTRIBUTE_UNUSED, FILE * file, { TestResult *tr; - static int num_tests_run = 0; + static unsigned int num_tests_run = 0; switch (evt) { @@ -354,7 +354,7 @@ void tap_lfun(SRunner * sr CK_ATTRIBUTE_UNUSED, FILE * file, break; case CLENDLOG_SR: /* Output the test plan as the last line */ - fprintf(file, "1..%d\n", num_tests_run); + fprintf(file, "1..%u\n", num_tests_run); fflush(file); break; case CLSTART_SR: @@ -371,7 +371,7 @@ void tap_lfun(SRunner * sr CK_ATTRIBUTE_UNUSED, FILE * file, /* Print the test result to the tap file */ num_tests_run += 1; tr = (TestResult *)obj; - fprintf(file, "%s %d - %s:%s:%s: %s\n", + fprintf(file, "%s %u - %s:%s:%s: %s\n", tr->rtype == CK_PASS ? "ok" : "not ok", num_tests_run, tr->file, tr->tcname, tr->tname, tr->msg); fflush(file); @@ -404,7 +404,7 @@ void subunit_lfun(SRunner * sr, FILE * file, enum print_output printmode, case CLEND_SR: if(printmode > CK_SILENT) { - fprintf(file, "\n"); + putc('\n', file); srunner_fprint(file, sr, printmode); } break; diff --git a/src/check_msg.c b/src/check_msg.c index 9483654b..6a666431 100644 --- a/src/check_msg.c +++ b/src/check_msg.c @@ -24,6 +24,10 @@ #include #include #include +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || \ + (defined(__APPLE__) && defined(__MACH__))) +#include +#endif #include "check_error.h" #include "check.h" diff --git a/tests/check_check_master.c b/tests/check_check_master.c index a78a274b..81eef9ff 100644 --- a/tests/check_check_master.c +++ b/tests/check_check_master.c @@ -909,13 +909,13 @@ char* get_next_test_name(FILE * file) ssize_t written; written = getline(&line, &length, file); - /** + /* * getline() will leave a \n at the end of the line, * remove it if it is present. */ if(written > 0 && line[written-1] == '\n') { - line[written-1] = '\0'; + line[written-1] = '\0'; } return line; @@ -949,7 +949,7 @@ void record_failure_line_num(int linenum) * If the master suite runs and does not find line numbers it will * fail as expected. */ - fprintf(stderr, "Line number file not setup, not reporting test failure line: %s", string); + fprintf(stderr, "Line number file not setup, not reporting test failure line: %s", string); return; } @@ -996,7 +996,7 @@ int get_next_failure_line_num(FILE * file) if(value <= 0 || *end != '\0') { fprintf(stderr, "%s:%d: Failed to convert next failure line number, found '%s'\n", - __FILE__, __LINE__, line); + __FILE__, __LINE__, line); exit(1); } }