From d2d069b86218d89051bcc218930043b65e9aeb26 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 15 Mar 2026 00:03:45 +0100 Subject: Log close() errors --- FICS/playerdb.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'FICS') diff --git a/FICS/playerdb.c b/FICS/playerdb.c index 8b3cb0d..dd3851b 100644 --- a/FICS/playerdb.c +++ b/FICS/playerdb.c @@ -1400,7 +1400,10 @@ player_save(int p) return -1; } else if ((fp = fdopen(fd, "w")) == NULL) { warn("%s: Problem opening file %s for write", __func__, fname); - close(fd); + + if (close(fd) != 0) + warn("%s: error closing file descriptor", __func__); + return -1; } @@ -1694,7 +1697,10 @@ write_p_inout(int inout, int p, const char *file, int maxlines) return; } else if ((fp = fdopen(fd, "a")) == NULL) { warn("%s: fdopen", __func__); - close(fd); + + if (close(fd) != 0) + warn("%s: error closing file descriptor", __func__); + return; } @@ -2726,7 +2732,8 @@ player_add_message(int top, int fromp, char *message) if ((fd = open(fname, g_open_flags[OPFL_APPEND], g_open_modes)) < 0) return -1; else if ((fp = fdopen(fd, "a")) == NULL) { - close(fd); + if (close(fd) != 0) + warn("%s: error closing file descriptor", __func__); return -1; } @@ -2908,7 +2915,8 @@ WriteMsgFile(int p, textlist *Head) if ((fd = open(fName, g_open_flags[OPFL_WRITE], g_open_modes)) < 0) return 0; else if ((fp = fdopen(fd, "w")) == NULL) { - close(fd); + if (close(fd) != 0) + warn("%s: error closing file descriptor", __func__); return 0; } -- cgit v1.2.3