]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Don't check a write error in the trailer
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Thu, 2 Apr 2015 19:12:31 +0000 (21:12 +0200)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Thu, 2 Apr 2015 19:12:31 +0000 (21:12 +0200)
Other fputs are not checked and any write error is caught more reliably
when the file is closed.

15 files changed:
authfail.c
dansguardian_report.c
denied.c
download.c
grepday.c
html.c
include/defs.h
index.c
redirector.c
repday.c
siteuser.c
topsites.c
topuser.c
useragent.c
util.c

index a7dc5a57a5255c960ba9686812a1c1567ea4a4d5..8f256f847ae83de8a653fbc2e7e6593f4bda54d5 100644 (file)
@@ -271,8 +271,7 @@ void authfail_report(void)
                show_ignored_auth(fp_ou,count-AuthfailReportLimit);
 
        fputs("</table></div>\n",fp_ou);
-       if (write_html_trailer(fp_ou)<0)
-               debuga(_("Write error in file %s\n"),report);
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
index 74cf8d36cf21fbd5494d18d811eb03f3da66b271..57e032998468f49802fcc1ce6962f6a458a33e6f 100644 (file)
@@ -165,8 +165,7 @@ void dansguardian_report(void)
                show_ignored_dansguardian(fp_ou,count-DansGuardianReportLimit);
 
        fputs("</table></div>\n",fp_ou);
-       if (write_html_trailer(fp_ou)<0)
-               debuga(_("Write error in file %s\n"),report);
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
index 188d6ffd98783d30fd401724a89c2e546b395498..98d9b1ca474d4559fac7cede2ee6d66e46971269 100644 (file)
--- a/denied.c
+++ b/denied.c
@@ -269,8 +269,7 @@ void gen_denied_report(void)
                show_ignored_denied(fp_ou,count-DeniedReportLimit);
 
        fputs("</table></div>\n",fp_ou);
-       if (write_html_trailer(fp_ou)<0)
-               debuga(_("Write error in file %s\n"),report);
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
index 2dd8f1335c064ac524ca8065981ed9eb1f11b3a1..1f2cdf83a8cc635b2d4a2ad2495a5dd6786940ce 100644 (file)
@@ -300,8 +300,7 @@ void download_report(void)
        longline_destroy(&line);
 
        fputs("</table></div>\n",fp_ou);
-       if (write_html_trailer(fp_ou)<0)
-               debuga(_("Write error in file %s\n"),report);
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
index 8c5516504ee863d8c2e0c91b43064f18069a3bf0..4d1321e5631606a7b0dafb64de174aa4eef61b7b 100644 (file)
--- a/grepday.c
+++ b/grepday.c
@@ -762,8 +762,7 @@ void greport_day(const struct userinfostruct *uinfo)
        }
        fputs("</table>\n",fp_ou);
 
-       if (write_html_trailer(fp_ou)<0)
-               debuga(_("Write error in file %s\n"),wdirname);
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF)
                debuga(_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
 #endif //HAVE_GD
diff --git a/html.c b/html.c
index 5601bf2a048aaf0ab3f0f74ef98cb9916b2e3870..9f2371d3ce54202d740fba3efa2aebb29b493f1f 100644 (file)
--- a/html.c
+++ b/html.c
@@ -631,8 +631,7 @@ void htmlrel(void)
                        fputs("</tfoot>",fp_ou);
 
                fputs("</table></div>\n",fp_ou);
-               if (write_html_trailer(fp_ou)<0)
-                       debuga(_("Write error in file %s\n"),arqou);
+               write_html_trailer(fp_ou);
                if (fclose(fp_ou)==EOF) {
                        debuga(_("Write error in \"%s\": %s\n"),arqou,strerror(errno));
                        exit(EXIT_FAILURE);
index 1d3dd061df2bba3c30aadbc9dacb9eeee50ca530..2ac5ae79ed64d13b15e7749642b8a541659c61f4 100644 (file)
@@ -370,7 +370,7 @@ void write_logo_image(FILE *fp_ou);
 void write_html_head(FILE *fp_ou, int depth, const char *page_title,int javascript);
 void write_html_header(FILE *fp_ou, int depth, const char *title,int javascript);
 void close_html_header(FILE *fp_ou);
-__attribute__((warn_unused_result)) int write_html_trailer(FILE *fp_ou);
+void write_html_trailer(FILE *fp_ou);
 void output_html_string(FILE *fp_ou,const char *str,int maxlen);
 void output_html_url(FILE *fp_ou,const char *url);
 void output_html_link(FILE *fp_ou,const char *url,int maxlen);
diff --git a/index.c b/index.c
index 5e6e2a976a8b2e42cef5c92f2f74d7562360f10c..9acb8a598a9ce4f50bda8d5d258fe99d4efea593 100644 (file)
--- a/index.c
+++ b/index.c
@@ -342,8 +342,7 @@ static long long int make_date_index_day(char *monthdir,int monthdir_size,int or
        }
        fputs("</table></div>\n",fp_ou);
        monthdir[monthdir_len-1]='\0';
-       if (write_html_trailer(fp_ou)<0)
-               debuga(_("Write error in the index %s/%s\n"),monthdir,INDEX_HTML_FILE);
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in %s/%s: %s\n"),monthdir,INDEX_HTML_FILE,strerror(errno));
                exit(EXIT_FAILURE);
@@ -512,9 +511,7 @@ static long long int make_date_index_month(char *yeardir,int yeardir_size,int or
        }
        fputs("</table></div>\n",fp_ou);
        yeardir[yeardir_len-1]='\0';
-       if (write_html_trailer(fp_ou)<0) {
-               debuga(_("Write error in the index %s/%s\n"),yeardir,INDEX_HTML_FILE);
-       }
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in %s/%s: %s\n"),yeardir,INDEX_HTML_FILE,strerror(errno));
                exit(EXIT_FAILURE);
@@ -633,8 +630,7 @@ static void make_date_index(void)
        }
 
        fputs("</table></div>\n",fp_ou);
-       if (write_html_trailer(fp_ou)<0)
-               debuga(_("Write error in the index %s\n"),yearindex);
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),yearindex,strerror(errno));
                exit(EXIT_FAILURE);
@@ -799,8 +795,7 @@ static void make_file_index(void)
                fprintf(fp_ou,">%s</td></tr>\n",fixnum(media,1));
        }
        fputs("</table></div>\n",fp_ou);
-       if (write_html_trailer(fp_ou)<0)
-               debuga(_("Write error in the index %s\n"),wdir);
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF)
                debuga(_("Failed to close the index file %s - %s\n"),wdir,strerror(errno));
 
index e0f696c6de287a0675548638cd29a095b91cb556..f6379d19896fc3000986e32a50c69518f3e8d71d 100644 (file)
@@ -577,8 +577,7 @@ void redirector_report(void)
        }
 
        fputs("</div>\n",fp_ou);
-       if (write_html_trailer(fp_ou)<0)
-               debuga(_("Write error in file %s\n"),report);
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
index 65a43c985cf8a4ba91985e89e5230a141c1fcf09..cb8088028ee4df9425a89fcce38431d17fc413f4 100644 (file)
--- a/repday.c
+++ b/repday.c
@@ -243,8 +243,7 @@ void report_day(const struct userinfostruct *uinfo)
 #endif
        }
 
-       if (write_html_trailer(fp_ou)<0)
-               debuga(_("Write error in file %s\n"),arqout);
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),arqout,strerror(errno));
                exit(EXIT_FAILURE);
index 3dde6e3c436a655d4a5b1c1e4abe5d3fda12f4aa..5b0e681cc51382cdb712414cddb4901291289d88 100644 (file)
@@ -189,8 +189,7 @@ void siteuser(void)
        }
 
        fputs("</table></div>\n",fp_ou);
-       if (write_html_trailer(fp_ou)<0)
-               debuga(_("Write error in file %s\n"),report);
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
index aca660114f5b0493aa2825b1159001787bee7e69..664e25daeeefaff6a5b8090f955d1e521a6b9a7d 100644 (file)
@@ -320,8 +320,7 @@ void topsites(void)
        longline_destroy(&line);
 
        fputs("</table></div>\n",fp_ou);
-       if (write_html_trailer(fp_ou)<0)
-               debuga(_("Write error in file %s\n"),report);
+       write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
index 8ac55bdc06439c54bd7e0305a9ee3018aee2adb5..59fb9a84d50127d9f7c01be2aa9834b9b179c981 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -496,8 +496,7 @@ void topuser(void)
        }
 
        fputs("</table></div>\n",fp_top3);
-       if (write_html_trailer(fp_top3)<0)
-               debuga(_("Write error in top user list %s\n"),top3);
+       write_html_trailer(fp_top3);
        if (fclose(fp_top3)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),top3,strerror(errno));
                exit(EXIT_FAILURE);
index c100f843035524f7fdc0c6da189c219c3f2db233..ea9cf2af025f39c2b0721734e8a6341376c9b979 100644 (file)
@@ -328,8 +328,7 @@ void useragent(void)
        fclose(fp_in);
 
        fputs("</table></div>\n",fp_ht);
-       if (write_html_trailer(fp_ht)<0)
-               debuga(_("Write error in file %s\n"),hfile);
+       write_html_trailer(fp_ht);
        if (fclose(fp_ht)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),hfile,strerror(errno));
                exit(EXIT_FAILURE);
diff --git a/util.c b/util.c
index 71c6f3f24e8356e8fb5bca96ee2352d3db0d7e41..fc9fece92b5114680035db40602ffaadb7e0cd33 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1974,11 +1974,10 @@ void close_html_header(FILE *fp_ou)
        fputs("</table></div>\n",fp_ou);
 }
 
-int write_html_trailer(FILE *fp_ou)
+void write_html_trailer(FILE *fp_ou)
 {
        show_info(fp_ou);
-       if (fputs("</body>\n</html>\n",fp_ou)==EOF) return(-1);
-       return(0);
+       fputs("</body>\n</html>\n",fp_ou);
 }
 
 void output_html_string(FILE *fp_ou,const char *str,int maxlen)