[multiple] address coverity warnings

This commit is contained in:
Glenn Strauss 2019-11-23 12:19:15 -05:00
parent f4a5a09d96
commit aaccb1bc5e
3 changed files with 6 additions and 14 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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 ",