A few fixes suggested by Coverity Scan

This commit is contained in:
ridiculousfish 2016-03-03 18:49:12 -08:00
parent 333415f42a
commit 1e7c3fe709
5 changed files with 15 additions and 14 deletions

View File

@ -3305,8 +3305,8 @@ static int builtin_contains(parser_t &parser, io_streams_t &streams, wchar_t **
{ {
streams.err.append_format(_(L"%ls: Key not specified\n"), argv[0]); streams.err.append_format(_(L"%ls: Key not specified\n"), argv[0]);
} }
else
{
for (int i=w.woptind+1; i<argc; i++) for (int i=w.woptind+1; i<argc; i++)
{ {
@ -3316,6 +3316,7 @@ static int builtin_contains(parser_t &parser, io_streams_t &streams, wchar_t **
return 0; return 0;
} }
} }
}
return 1; return 1;
} }

View File

@ -1690,10 +1690,10 @@ void history_t::populate_from_config_path()
int dst_fd = wopen_cloexec(new_file, O_WRONLY | O_CREAT, 0644); int dst_fd = wopen_cloexec(new_file, O_WRONLY | O_CREAT, 0644);
char buf[BUFSIZ]; char buf[BUFSIZ];
size_t size; ssize_t size;
while ((size = read(src_fd, buf, BUFSIZ)) > 0) { while ((size = read(src_fd, buf, BUFSIZ)) > 0) {
ssize_t written = write(dst_fd, buf, size); ssize_t written = write(dst_fd, buf, static_cast<size_t>(size));
if (written == -1) { if (written < 0) {
/* /*
This message does not have high enough priority to This message does not have high enough priority to
be shown by default. be shown by default.

View File

@ -138,7 +138,6 @@ static int handle_child_io(const io_chain_t &io_chain)
for (size_t idx = 0; idx < io_chain.size(); idx++) for (size_t idx = 0; idx < io_chain.size(); idx++)
{ {
const io_data_t *io = io_chain.at(idx).get(); const io_data_t *io = io_chain.at(idx).get();
int tmp;
if (io->io_mode == IO_FD && io->fd == static_cast<const io_fd_t*>(io)->old_fd) if (io->io_mode == IO_FD && io->fd == static_cast<const io_fd_t*>(io)->old_fd)
{ {
@ -162,8 +161,8 @@ static int handle_child_io(const io_chain_t &io_chain)
{ {
// Here we definitely do not want to set CLO_EXEC because our child needs access // Here we definitely do not want to set CLO_EXEC because our child needs access
CAST_INIT(const io_file_t *, io_file, io); CAST_INIT(const io_file_t *, io_file, io);
if ((tmp=open(io_file->filename_cstr, int tmp = open(io_file->filename_cstr, io_file->flags, OPEN_MASK);
io_file->flags, OPEN_MASK))==-1) if (tmp < 0)
{ {
if ((io_file->flags & O_EXCL) && if ((io_file->flags & O_EXCL) &&
(errno ==EEXIST)) (errno ==EEXIST))

View File

@ -453,6 +453,7 @@ static void handle_child_status(pid_t pid, int status)
} }
process_t::process_t() : process_t::process_t() :
type(), // gets set later
internal_block_node(NODE_OFFSET_INVALID), internal_block_node(NODE_OFFSET_INVALID),
pid(0), pid(0),
pipe_write_fd(0), pipe_write_fd(0),

View File

@ -143,7 +143,7 @@ public:
int last_nonopt; int last_nonopt;
wgetopter_t() : woptarg(NULL), woptind(0), nextchar(0), wopterr(0), woptopt('?'), first_nonopt(0), last_nonopt(0) wgetopter_t() : woptarg(NULL), woptind(0), nextchar(0), wopterr(0), woptopt('?'), ordering(), first_nonopt(0), last_nonopt(0)
{ {
} }