From: Frederic Marchal Date: Thu, 2 Apr 2015 19:12:31 +0000 (+0200) Subject: Don't check a write error in the trailer X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=342bd72377c035d48ee44c97d9cebcfe5ec529f9;p=thirdparty%2Fsarg.git Don't check a write error in the trailer Other fputs are not checked and any write error is caught more reliably when the file is closed. --- diff --git a/authfail.c b/authfail.c index a7dc5a5..8f256f8 100644 --- a/authfail.c +++ b/authfail.c @@ -271,8 +271,7 @@ void authfail_report(void) show_ignored_auth(fp_ou,count-AuthfailReportLimit); fputs("\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); diff --git a/dansguardian_report.c b/dansguardian_report.c index 74cf8d3..57e0329 100644 --- a/dansguardian_report.c +++ b/dansguardian_report.c @@ -165,8 +165,7 @@ void dansguardian_report(void) show_ignored_dansguardian(fp_ou,count-DansGuardianReportLimit); fputs("\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); diff --git a/denied.c b/denied.c index 188d6ff..98d9b1c 100644 --- a/denied.c +++ b/denied.c @@ -269,8 +269,7 @@ void gen_denied_report(void) show_ignored_denied(fp_ou,count-DeniedReportLimit); fputs("\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); diff --git a/download.c b/download.c index 2dd8f13..1f2cdf8 100644 --- a/download.c +++ b/download.c @@ -300,8 +300,7 @@ void download_report(void) longline_destroy(&line); fputs("\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); diff --git a/grepday.c b/grepday.c index 8c55165..4d1321e 100644 --- a/grepday.c +++ b/grepday.c @@ -762,8 +762,7 @@ void greport_day(const struct userinfostruct *uinfo) } fputs("\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 5601bf2..9f2371d 100644 --- a/html.c +++ b/html.c @@ -631,8 +631,7 @@ void htmlrel(void) fputs("",fp_ou); fputs("\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); diff --git a/include/defs.h b/include/defs.h index 1d3dd06..2ac5ae7 100644 --- a/include/defs.h +++ b/include/defs.h @@ -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 5e6e2a9..9acb8a5 100644 --- 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("\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("\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("\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\n",fixnum(media,1)); } fputs("\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)); diff --git a/redirector.c b/redirector.c index e0f696c..f6379d1 100644 --- a/redirector.c +++ b/redirector.c @@ -577,8 +577,7 @@ void redirector_report(void) } fputs("\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); diff --git a/repday.c b/repday.c index 65a43c9..cb80880 100644 --- 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); diff --git a/siteuser.c b/siteuser.c index 3dde6e3..5b0e681 100644 --- a/siteuser.c +++ b/siteuser.c @@ -189,8 +189,7 @@ void siteuser(void) } fputs("\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); diff --git a/topsites.c b/topsites.c index aca6601..664e25d 100644 --- a/topsites.c +++ b/topsites.c @@ -320,8 +320,7 @@ void topsites(void) longline_destroy(&line); fputs("\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); diff --git a/topuser.c b/topuser.c index 8ac55bd..59fb9a8 100644 --- a/topuser.c +++ b/topuser.c @@ -496,8 +496,7 @@ void topuser(void) } fputs("\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); diff --git a/useragent.c b/useragent.c index c100f84..ea9cf2a 100644 --- a/useragent.c +++ b/useragent.c @@ -328,8 +328,7 @@ void useragent(void) fclose(fp_in); fputs("\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 71c6f3f..fc9fece 100644 --- a/util.c +++ b/util.c @@ -1974,11 +1974,10 @@ void close_html_header(FILE *fp_ou) fputs("\n",fp_ou); } -int write_html_trailer(FILE *fp_ou) +void write_html_trailer(FILE *fp_ou) { show_info(fp_ou); - if (fputs("\n\n",fp_ou)==EOF) return(-1); - return(0); + fputs("\n\n",fp_ou); } void output_html_string(FILE *fp_ou,const char *str,int maxlen)