Skip to content

Commit

Permalink
Exclude some error lines from cover
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos committed Aug 17, 2024
1 parent e833089 commit 10a7a8d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/xxd.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,15 @@ exit_with_usage(void)
exit(1);
}

// LCOV_EXCL_START
static void
perror_exit(int ret)
{
fprintf(stderr, "%s: ", pname);
perror(NULL);
exit(ret);
}
// LCOV_EXCL_STOP

static void
error_exit(int ret, char* msg)
Expand All @@ -272,7 +274,7 @@ fgetc_or_die(FILE* fpi)

if(c == EOF && ferror(fpi))
{
perror_exit(2);
perror_exit(2); // LCOV_EXCL_LINE
}

return c;
Expand All @@ -283,7 +285,7 @@ fputc_or_die(int c, FILE* fpo)
{
if(fputc(c, fpo) == EOF)
{
perror_exit(3);
perror_exit(3); // LCOV_EXCL_LINE
}
}

Expand All @@ -292,7 +294,7 @@ fputs_or_die(const char* s, FILE* fpo)
{
if(fputs(s, fpo) == EOF)
{
perror_exit(3);
perror_exit(3); // LCOV_EXCL_LINE
}
}

Expand All @@ -304,12 +306,12 @@ fclose_or_die(FILE* fpi, FILE* fpo)
{
if(fclose(fpo) != 0)
{
perror_exit(3);
perror_exit(3); // LCOV_EXCL_LINE
}

if(fclose(fpi) != 0)
{
perror_exit(2);
perror_exit(2); // LCOV_EXCL_LINE
}
}

Expand Down Expand Up @@ -416,7 +418,7 @@ huntype(
{
if(fflush(fpo) != 0)
{
perror_exit(3);
perror_exit(3); // LCOV_EXCL_LINE
}

#ifdef TRY_SEEK
Expand Down Expand Up @@ -481,7 +483,7 @@ huntype(

if(fflush(fpo) != 0)
{
perror_exit(3);
perror_exit(3); // LCOV_EXCL_LINE
}

#ifdef TRY_SEEK
Expand Down Expand Up @@ -972,7 +974,7 @@ main(int argc, char* argv[])
{
if(fgetc_or_die(fp) == EOF)
{
error_exit(4, "Sorry, cannot seek.");
error_exit(4, "Sorry, cannot seek."); // LCOV_EXCL_LINE
}
}
}
Expand Down

0 comments on commit 10a7a8d

Please sign in to comment.