Skip to content

Commit

Permalink
refactor: introduce a function aborts the execution when a file error…
Browse files Browse the repository at this point in the history
… if found

exit(1) is removed as suggested by @b4n.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Feb 25, 2015
1 parent b68ed3c commit 3da98c1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ extern const char *tagFileName (void)
* Pseudo tag support
*/

static void abort_if_ferror(FILE *const fp)
{
if (ferror (fp))
error (FATAL | PERROR, "cannot write tag file");
}

static void rememberMaxLengths (const size_t nameLength, const size_t lineLength)
{
if (nameLength > TagFile.max.tag)
Expand Down Expand Up @@ -835,8 +841,7 @@ extern void makeTagEntry (const tagEntryInfo *const tag)
else
length = writeCtagsEntry (tag);

if (ferror (TagFile.fp))
error (FATAL | PERROR, "cannot write tag file");
abort_if_ferror (TagFile.fp);

++TagFile.numTags.added;
rememberMaxLengths (strlen (tag->name), (size_t) length);
Expand Down

0 comments on commit 3da98c1

Please sign in to comment.