From aaccb1bc5e85c3f9bb4e1f0891002703699f8854 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sat, 23 Nov 2019 12:19:15 -0500 Subject: [PATCH] [multiple] address coverity warnings --- src/lemon.c | 8 ++++---- src/mod_compress.c | 8 -------- src/mod_ssi.c | 4 ++-- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/lemon.c b/src/lemon.c index ad86cee2..77d7ad47 100644 --- a/src/lemon.c +++ b/src/lemon.c @@ -2215,7 +2215,7 @@ to follow the previous rule."); case WAITING_FOR_DESTRUCTOR_SYMBOL: if( !isalpha(x[0]) ){ ErrorMsg(psp->filename,psp->tokenlineno, - "Symbol name missing after %destructor keyword"); + "Symbol name missing after %%destructor keyword"); psp->errorcnt++; psp->state = RESYNC_AFTER_DECL_ERROR; }else{ @@ -2228,7 +2228,7 @@ to follow the previous rule."); case WAITING_FOR_DATATYPE_SYMBOL: if( !isalpha(x[0]) ){ ErrorMsg(psp->filename,psp->tokenlineno, - "Symbol name missing after %destructor keyword"); + "Symbol name missing after %%destructor keyword"); psp->errorcnt++; psp->state = RESYNC_AFTER_DECL_ERROR; }else{ @@ -2343,14 +2343,14 @@ struct lemon *gp; rewind(fp); filebuf = (char *)malloc( filesize+1 ); if( filebuf==0 ){ - ErrorMsg(ps.filename,0,"Can't allocate %d of memory to hold this file.", + ErrorMsg(ps.filename,0,"Can't allocate %zu of memory to hold this file.", filesize+1); fclose(fp); gp->errorcnt++; return; } if( fread(filebuf,1,filesize,fp)!=filesize ){ - ErrorMsg(ps.filename,0,"Can't read in all %d bytes of this file.", + ErrorMsg(ps.filename,0,"Can't read in all %zu bytes of this file.", filesize); free(filebuf); fclose(fp); diff --git a/src/mod_compress.c b/src/mod_compress.c index 4bdfa30a..656796f2 100644 --- a/src/mod_compress.c +++ b/src/mod_compress.c @@ -563,7 +563,6 @@ static int deflate_file_to_file(server *srv, connection *con, plugin_data *p, in munmap(start, sce->st.st_size); close(ofd); - close(ifd); /* Remove the incomplete cache file, so that later hits aren't served from it */ if (-1 == unlink(p->ofn->ptr)) { @@ -578,7 +577,6 @@ static int deflate_file_to_file(server *srv, connection *con, plugin_data *p, in log_error_write(srv, __FILE__, __LINE__, "sbss", "reading", fn, "failed", strerror(errno)); close(ofd); - close(ifd); free(start); /* Remove the incomplete cache file, so that later hits aren't served from it */ @@ -627,8 +625,6 @@ static int deflate_file_to_file(server *srv, connection *con, plugin_data *p, in #endif free(start); - close(ifd); - if (0 != close(ofd) || ret != 0) { if (0 == ret) { log_error_write(srv, __FILE__, __LINE__, "sbss", "writing cachefile", p->ofn, "failed:", strerror(errno)); @@ -689,7 +685,6 @@ static int deflate_file_to_buffer(server *srv, connection *con, plugin_data *p, fn, ifd); munmap(start, sce->st.st_size); - close(ifd); return -1; } } else @@ -697,7 +692,6 @@ static int deflate_file_to_buffer(server *srv, connection *con, plugin_data *p, if (NULL == (start = malloc(sce->st.st_size)) || sce->st.st_size != read(ifd, start, sce->st.st_size)) { log_error_write(srv, __FILE__, __LINE__, "sbss", "reading", fn, "failed", strerror(errno)); - close(ifd); free(start); return -1; } @@ -731,8 +725,6 @@ static int deflate_file_to_buffer(server *srv, connection *con, plugin_data *p, #endif free(start); - close(ifd); - if (ret != 0) return -1; mod_compress_note_ratio(srv, con, sce->st.st_size, diff --git a/src/mod_ssi.c b/src/mod_ssi.c index 00ac727a..1493dfa1 100644 --- a/src/mod_ssi.c +++ b/src/mod_ssi.c @@ -590,7 +590,7 @@ static int process_ssi_stmt(server *srv, connection *con, handler_ctx *p, const } int fd = stat_cache_open_rdonly_fstat(p->stat_fn, &stb, con->conf.follow_symlink); - if (fd > 0) { + if (fd >= 0) { time_t t = stb.st_mtime; switch (ssicmd) { @@ -676,7 +676,7 @@ static int process_ssi_stmt(server *srv, connection *con, handler_ctx *p, const break; } - if (fd > 0) close(fd); + if (fd >= 0) close(fd); } else { log_error_write(srv, __FILE__, __LINE__, "sbs", "ssi: stating failed ",