From 1e7c3fe70964711918bcf13553ae9fb66ed73a17 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Thu, 3 Mar 2016 18:49:12 -0800 Subject: [PATCH] A few fixes suggested by Coverity Scan --- src/builtin.cpp | 15 ++++++++------- src/history.cpp | 6 +++--- src/postfork.cpp | 5 ++--- src/proc.cpp | 1 + src/wgetopt.h | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index b83bb82a6..4597b18e8 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -3305,15 +3305,16 @@ 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]); } - - - for (int i=w.woptind+1; i 0) { - ssize_t written = write(dst_fd, buf, size); - if (written == -1) { + ssize_t written = write(dst_fd, buf, static_cast(size)); + if (written < 0) { /* This message does not have high enough priority to be shown by default. diff --git a/src/postfork.cpp b/src/postfork.cpp index 43c33d56b..40a0bffb1 100644 --- a/src/postfork.cpp +++ b/src/postfork.cpp @@ -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++) { const io_data_t *io = io_chain.at(idx).get(); - int tmp; if (io->io_mode == IO_FD && io->fd == static_cast(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 CAST_INIT(const io_file_t *, io_file, io); - if ((tmp=open(io_file->filename_cstr, - io_file->flags, OPEN_MASK))==-1) + int tmp = open(io_file->filename_cstr, io_file->flags, OPEN_MASK); + if (tmp < 0) { if ((io_file->flags & O_EXCL) && (errno ==EEXIST)) diff --git a/src/proc.cpp b/src/proc.cpp index 806da0ec6..f5c833e2a 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -453,6 +453,7 @@ static void handle_child_status(pid_t pid, int status) } process_t::process_t() : + type(), // gets set later internal_block_node(NODE_OFFSET_INVALID), pid(0), pipe_write_fd(0), diff --git a/src/wgetopt.h b/src/wgetopt.h index 462bc2912..ad1558703 100644 --- a/src/wgetopt.h +++ b/src/wgetopt.h @@ -143,7 +143,7 @@ public: 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) { }