aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-03-03 18:49:12 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-03-03 18:49:24 -0800
commit1e7c3fe70964711918bcf13553ae9fb66ed73a17 (patch)
tree99541c6a121f0868834f1cceb35c36092515cc6c
parent333415f42a8fb837b4867edda7118cd50d59a485 (diff)
A few fixes suggested by Coverity Scan
-rw-r--r--src/builtin.cpp15
-rw-r--r--src/history.cpp6
-rw-r--r--src/postfork.cpp5
-rw-r--r--src/proc.cpp1
-rw-r--r--src/wgetopt.h2
5 files changed, 15 insertions, 14 deletions
diff --git a/src/builtin.cpp b/src/builtin.cpp
index b83bb82a..4597b18e 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<argc; i++)
+ else
{
-
- if (!wcscmp(needle, argv[i]))
+ for (int i=w.woptind+1; i<argc; i++)
{
- if (should_output_index) streams.out.append_format( L"%d\n", i-w.woptind);
- return 0;
+
+ if (!wcscmp(needle, argv[i]))
+ {
+ if (should_output_index) streams.out.append_format( L"%d\n", i-w.woptind);
+ return 0;
+ }
}
}
return 1;
diff --git a/src/history.cpp b/src/history.cpp
index 28be7bc5..1bada96d 100644
--- a/src/history.cpp
+++ b/src/history.cpp
@@ -1690,10 +1690,10 @@ void history_t::populate_from_config_path()
int dst_fd = wopen_cloexec(new_file, O_WRONLY | O_CREAT, 0644);
char buf[BUFSIZ];
- size_t size;
+ ssize_t size;
while ((size = read(src_fd, buf, BUFSIZ)) > 0) {
- ssize_t written = write(dst_fd, buf, size);
- if (written == -1) {
+ ssize_t written = write(dst_fd, buf, static_cast<size_t>(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 43c33d56..40a0bffb 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<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
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 806da0ec..f5c833e2 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 462bc291..ad155870 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)
{
}