Skip to content
Merged
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
3 changes: 1 addition & 2 deletions src/check_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ int check_list_at_end(List * lp)
{
if(lp->current == -1)
return 1;
else
return (lp->current > lp->last);
return (lp->current > lp->last);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

return lp->current == -1 ? 1 : lp->current > lp->last;

If you want to reduce it even more...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I do not remember to have seen ternary expression in the source code, so it may be intentional as it could be considered less clear. Moreover, it is also not supported by some weird compilers, or less well, especially the ones for embed systems. http://embeddedgurus.com/stack-overflow/2009/02/efficient-c-tips-6-dont-use-the-ternary-operator/

}

void check_list_front(List * lp)
Expand Down
12 changes: 4 additions & 8 deletions src/check_run.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,18 +735,14 @@ enum fork_status srunner_fork_status(SRunner * sr)
#endif
if(strcmp(env, "no") == 0)
return CK_NOFORK;
else
{
#if defined(HAVE_FORK) && HAVE_FORK==1
return CK_FORK;
return CK_FORK;
#else /* HAVE_FORK */
/* Ignoring, as Check is not compiled with fork support. */
return CK_NOFORK;
/* Ignoring, as Check is not compiled with fork support. */
return CK_NOFORK;
#endif /* HAVE_FORK */
}
}
else
return sr->fstat;
return sr->fstat;
}

void srunner_set_fork_status(SRunner * sr, enum fork_status fstat)
Expand Down
25 changes: 10 additions & 15 deletions src/check_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,30 +106,25 @@ char *ck_strdup_printf(const char *fmt, ...)

static const char *tr_type_str(TestResult * tr)
{
const char *str = NULL;

if(tr->ctx == CK_CTX_TEST)
{
if(tr->rtype == CK_PASS)
str = "P";
else if(tr->rtype == CK_FAILURE)
str = "F";
else if(tr->rtype == CK_ERROR)
str = "E";
return "P";
if(tr->rtype == CK_FAILURE)
return "F";
if(tr->rtype == CK_ERROR)
return "E";
return NULL;
}
else
str = "S";

return str;
return "S";
}

static int percent_passed(TestStats * t)
{
if(t->n_failed == 0 && t->n_errors == 0)
return 100;
else if(t->n_checked == 0)
if(t->n_checked == 0)
return 0;
else
return (int)((float)(t->n_checked - (t->n_failed + t->n_errors)) /
(float)t->n_checked * 100);
return (int)((float)(t->n_checked - (t->n_failed + t->n_errors)) /
(float)t->n_checked * 100);
}