Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very minor improvements in C source code #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions src/check_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used srunner_tap_fname that is not defined before.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was already defined in src/check_log.h which is included in the beginning of src/check_log.c.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make this a separate commit, instead of combining multiple unrelated improvements in one commit.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
/* check if tap log filename have been set explicitly */
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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:
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/check_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <stdlib.h>
#include <fcntl.h>
#include <stdio.h>
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || \
(defined(__APPLE__) && defined(__MACH__)))
#include <unistd.h>
#endif

#include "check_error.h"
#include "check.h"
Expand Down
8 changes: 4 additions & 4 deletions tests/check_check_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
}
Expand Down