commit e081081c15798b59ab99774b62cf5c0e0ba646d7
parent 77fbf067cdd6e8028704c2085314ed186e50de66
Author: Ricardo Mones <mones@claws-mail.org>
Date: Fri, 14 Sep 2012 14:30:53 +0000
2012-09-14 [mones] 3.8.1cvs59
* src/common/log.c
Check file operation results (and remove and
unused var warning)
Diffstat:
4 files changed, 52 insertions(+), 34 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,9 @@
+2012-09-14 [mones] 3.8.1cvs59
+
+ * src/common/log.c
+ Check file operation results (and remove and
+ unused var warning)
+
2012-09-14 [colin] 3.8.1cvs58
* src/gtk/inputdialog.c
diff --git a/PATCHSETS b/PATCHSETS
@@ -4433,3 +4433,4 @@
( cvs diff -u -r 1.115.2.256 -r 1.115.2.257 src/main.c; ) > 3.8.1cvs56.patchset
( cvs diff -u -r 1.25.2.75 -r 1.25.2.76 src/stock_pixmap.c; ) > 3.8.1cvs57.patchset
( cvs diff -u -r 1.2.2.47 -r 1.2.2.48 src/gtk/inputdialog.c; ) > 3.8.1cvs58.patchset
+( cvs diff -u -r 1.6.2.24 -r 1.6.2.25 src/common/log.c; ) > 3.8.1cvs59.patchset
diff --git a/configure.ac b/configure.ac
@@ -12,7 +12,7 @@ MINOR_VERSION=8
MICRO_VERSION=1
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=58
+EXTRA_VERSION=59
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
diff --git a/src/common/log.c b/src/common/log.c
@@ -36,6 +36,19 @@
#include "log.h"
#include "hooks.h"
+#define FWRITE(_b,_s,_n,_f) if (fwrite(_b,_s,_n,_f) != _n) { \
+ g_message("log fwrite failed!\n"); \
+ return; \
+ }
+#define FPUTS(_b,_f) if (fputs(_b,_f) == EOF) { \
+ g_message("log fputs failed!\n"); \
+ return; \
+ }
+#define FFLUSH(_f) if (fflush(_f) != 0) { \
+ g_message("log fflush failed!\n"); \
+ return; \
+ }
+
static FILE *log_fp[LOG_INSTANCE_MAX] = {
NULL,
NULL
@@ -189,10 +202,9 @@ void log_print(LogInstance instance, const gchar *format, ...)
g_timeout_add(0, invoke_hook_cb, logtext);
if (log_fp[instance] && prefs_common_enable_log_standard()) {
- int r;
- r = fputs(buf, log_fp[instance]);
+ FPUTS(buf, log_fp[instance])
log_size[instance] += strlen(buf);
- r = fflush(log_fp[instance]);
+ FFLUSH(log_fp[instance])
rotate_log(instance);
}
}
@@ -221,13 +233,12 @@ void log_message(LogInstance instance, const gchar *format, ...)
g_timeout_add(0, invoke_hook_cb, logtext);
if (log_fp[instance] && prefs_common_enable_log_standard()) {
- int r;
- r = fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
- r = fputs("* message: ", log_fp[instance]);
+ FWRITE(buf, 1, LOG_TIME_LEN, log_fp[instance])
+ FPUTS("* message: ", log_fp[instance])
log_size[instance] += strlen("* message: ");
- r = fputs(buf + LOG_TIME_LEN, log_fp[instance]);
+ FPUTS(buf + LOG_TIME_LEN, log_fp[instance])
log_size[instance] += strlen(buf);
- r = fflush(log_fp[instance]);
+ FFLUSH(log_fp[instance])
rotate_log(instance);
}
}
@@ -256,13 +267,12 @@ void log_warning(LogInstance instance, const gchar *format, ...)
g_timeout_add(0, invoke_hook_cb, logtext);
if (log_fp[instance] && prefs_common_enable_log_warning()) {
- int r;
- r = fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
- r = fputs("** warning: ", log_fp[instance]);
+ FWRITE(buf, 1, LOG_TIME_LEN, log_fp[instance])
+ FPUTS("** warning: ", log_fp[instance])
log_size[instance] += strlen("** warning: ");
- r = fputs(buf + LOG_TIME_LEN, log_fp[instance]);
+ FPUTS(buf + LOG_TIME_LEN, log_fp[instance])
log_size[instance] += strlen(buf);
- r = fflush(log_fp[instance]);
+ FFLUSH(log_fp[instance])
rotate_log(instance);
}
}
@@ -291,13 +301,12 @@ void log_error(LogInstance instance, const gchar *format, ...)
g_timeout_add(0, invoke_hook_cb, logtext);
if (log_fp[instance] && prefs_common_enable_log_error()) {
- int r;
- r = fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
- r = fputs("*** error: ", log_fp[instance]);
+ FWRITE(buf, 1, LOG_TIME_LEN, log_fp[instance])
+ FPUTS("*** error: ", log_fp[instance])
log_size[instance] += strlen("*** error: ");
- r = fputs(buf + LOG_TIME_LEN, log_fp[instance]);
+ FPUTS(buf + LOG_TIME_LEN, log_fp[instance])
log_size[instance] += strlen(buf);
- r = fflush(log_fp[instance]);
+ FFLUSH(log_fp[instance])
rotate_log(instance);
}
}
@@ -326,13 +335,12 @@ void log_status_ok(LogInstance instance, const gchar *format, ...)
g_timeout_add(0, invoke_hook_cb, logtext);
if (log_fp[instance] && prefs_common_enable_log_status()) {
- int r;
- r = fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
- r = fputs("* OK: ", log_fp[instance]);
+ FWRITE(buf, 1, LOG_TIME_LEN, log_fp[instance])
+ FPUTS("* OK: ", log_fp[instance])
log_size[instance] += strlen("* OK: ");
- r = fputs(buf + LOG_TIME_LEN, log_fp[instance]);
+ FPUTS(buf + LOG_TIME_LEN, log_fp[instance])
log_size[instance] += strlen(buf);
- r = fflush(log_fp[instance]);
+ FFLUSH(log_fp[instance])
rotate_log(instance);
}
}
@@ -361,13 +369,12 @@ void log_status_nok(LogInstance instance, const gchar *format, ...)
g_timeout_add(0, invoke_hook_cb, logtext);
if (log_fp[instance] && prefs_common_enable_log_status()) {
- int r;
- r = fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
- r = fputs("* NOT OK: ", log_fp[instance]);
+ FWRITE(buf, 1, LOG_TIME_LEN, log_fp[instance])
+ FPUTS("* NOT OK: ", log_fp[instance])
log_size[instance] += strlen("* NOT OK: ");
- r = fputs(buf + LOG_TIME_LEN, log_fp[instance]);
+ FPUTS(buf + LOG_TIME_LEN, log_fp[instance])
log_size[instance] += strlen(buf);
- r = fflush(log_fp[instance]);
+ FFLUSH(log_fp[instance])
rotate_log(instance);
}
}
@@ -396,13 +403,17 @@ void log_status_skip(LogInstance instance, const gchar *format, ...)
g_timeout_add(0, invoke_hook_cb, logtext);
if (log_fp[instance] && prefs_common_enable_log_status()) {
- int r;
- r = fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
- r = fputs("* SKIPPED: ", log_fp[instance]);
+ FWRITE(buf, 1, LOG_TIME_LEN, log_fp[instance])
+ FPUTS("* SKIPPED: ", log_fp[instance])
log_size[instance] += strlen("* SKIPPED: ");
- r = fputs(buf + LOG_TIME_LEN, log_fp[instance]);
+ FPUTS(buf + LOG_TIME_LEN, log_fp[instance])
log_size[instance] += strlen(buf);
- r = fflush(log_fp[instance]);
+ FFLUSH(log_fp[instance])
rotate_log(instance);
}
}
+
+#undef FWRITE
+#undef FPUTS
+#undef FFLUSH
+