talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit e745553712a30022d6d34602b4279604df0ce945
parent d71e99303d0b82fde93cd90300487d1b3a567e95
Author: Colin Leroy <colin@colino.net>
Date:   Sun,  7 Oct 2018 20:41:20 +0200

Make safe_fclose static now that it can be

Diffstat:
Msrc/common/file-utils.c | 28++++++++++++++--------------
Msrc/common/file-utils.h | 4+---
2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/common/file-utils.c b/src/common/file-utils.c @@ -34,8 +34,7 @@ gboolean prefs_common_get_flush_metadata(void); gboolean prefs_common_get_use_shred(void); -/* FIXME make static once every file I/O is done using claws_* wrappers */ -int safe_fclose(FILE *fp) +static int safe_fclose(FILE *fp) { int r; START_TIMING(""); @@ -53,6 +52,18 @@ int safe_fclose(FILE *fp) return r; } +/* Unlock, then safe-close a file pointer + * Safe close is done using fflush + fsync + * if the according preference says so. + */ +int claws_safe_fclose(FILE *fp) +{ +#if HAVE_FGETS_UNLOCKED + funlockfile(fp); +#endif + return safe_fclose(fp); +} + #if HAVE_FGETS_UNLOCKED /* Open a file and locks it once @@ -84,16 +95,7 @@ int claws_fclose(FILE *fp) funlockfile(fp); return fclose(fp); } - -/* Unlock, then safe-close a file pointer - * Safe close is done using fflush + fsync - * if the according preference says so. - */ -int claws_safe_fclose(FILE *fp) -{ - funlockfile(fp); - return safe_fclose(fp); -} +#endif #ifdef G_OS_WIN32 #define WEXITSTATUS(x) (x) @@ -875,5 +877,3 @@ FILE *str_open_as_stream(const gchar *str) rewind(fp); return fp; } - -#endif diff --git a/src/common/file-utils.h b/src/common/file-utils.h @@ -42,7 +42,6 @@ FILE *claws_fopen (const char *file, FILE *claws_fdopen (int fd, const char *mode); int claws_fclose (FILE *fp); -int claws_safe_fclose (FILE *fp); #else @@ -57,10 +56,9 @@ int claws_safe_fclose (FILE *fp); #define claws_fopen g_fopen #define claws_fdopen fdopen #define claws_fclose fclose -#define claws_safe_fclose safe_fclose #endif -int safe_fclose (FILE *fp); +int claws_safe_fclose (FILE *fp); int claws_unlink (const char *filename); gint file_strip_crs (const gchar *file);