summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configd/src/apps/sentinel/command-connection.cpp5
-rw-r--r--configd/src/apps/sentinel/service.cpp4
-rw-r--r--document/src/tests/documenttestcase.cpp38
-rw-r--r--document/src/tests/documentupdatetestcase.cpp9
-rw-r--r--document/src/tests/fieldpathupdatetestcase.cpp9
-rw-r--r--documentapi/src/tests/messages/testbase.cpp8
-rw-r--r--fastos/src/vespa/fastos/unix_ipc.cpp12
-rw-r--r--vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.cpp4
-rw-r--r--vespalog/src/vespa/log/control-file.cpp16
9 files changed, 76 insertions, 29 deletions
diff --git a/configd/src/apps/sentinel/command-connection.cpp b/configd/src/apps/sentinel/command-connection.cpp
index 9b35d801ecb..4bba9c62be9 100644
--- a/configd/src/apps/sentinel/command-connection.cpp
+++ b/configd/src/apps/sentinel/command-connection.cpp
@@ -50,7 +50,10 @@ CommandConnection::printf(const char *fmt, ...)
int ret = vsnprintf(buf, sizeof buf, fmt, args);
va_end(args);
- write(_fd, buf, strlen(buf));
+ size_t len = strlen(buf);
+ if (write(_fd, buf, strlen(buf) != len)) {
+ perror("CommandConnection::printf failed");
+ }
return ret;
}
diff --git a/configd/src/apps/sentinel/service.cpp b/configd/src/apps/sentinel/service.cpp
index 9a1f3dc9c82..49944043259 100644
--- a/configd/src/apps/sentinel/service.cpp
+++ b/configd/src/apps/sentinel/service.cpp
@@ -337,7 +337,7 @@ Service::runChild(int pipes[2])
char buf[200];
snprintf(buf, sizeof buf, "open /dev/null for fd 0: got %d "
"(%s)", fd, strerror(errno));
- write(pipes[1], buf, strlen(buf));
+ (void) write(pipes[1], buf, strlen(buf));
_exit(EXIT_FAILURE);
}
fcntl(0, F_SETFD, 0); // Don't close on exec
@@ -347,7 +347,7 @@ Service::runChild(int pipes[2])
char buf[200];
snprintf(buf, sizeof buf, "exec error: %s for /bin/sh -c '%s'",
strerror(errno), _config->command.c_str());
- write(pipes[1], buf, strlen(buf));
+ (void) write(pipes[1], buf, strlen(buf));
_exit(EXIT_FAILURE);
}
diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp
index 475cf64128e..6ea15c6a581 100644
--- a/document/src/tests/documenttestcase.cpp
+++ b/document/src/tests/documenttestcase.cpp
@@ -597,8 +597,9 @@ void DocumentTest::testReadSerializedFile()
size_t len = lseek(fd,0,SEEK_END);
ByteBuffer buf(len);
lseek(fd,0,SEEK_SET);
- read(fd, buf.getBuffer(), len);
-
+ if (read(fd, buf.getBuffer(), len) != len) {
+ throw vespalib::Exception("read failed");
+ }
close(fd);
Document doc(repo, buf);
@@ -630,8 +631,9 @@ void DocumentTest::testReadSerializedFileCompressed()
int len = lseek(fd,0,SEEK_END);
ByteBuffer buf(len);
lseek(fd,0,SEEK_SET);
- read(fd, buf.getBuffer(), len);
-
+ if (read(fd, buf.getBuffer(), len) != len) {
+ throw vespalib::Exception("read failed");
+ }
close(fd);
Document doc(repo, buf);
@@ -782,7 +784,9 @@ void DocumentTest::testReadSerializedAllVersions()
int len = lseek(fd,0,SEEK_END);
ByteBuffer buf(len);
lseek(fd,0,SEEK_SET);
- read(fd, buf.getBuffer(), len);
+ if (read(fd, buf.getBuffer(), len) != len) {
+ throw vespalib::Exception("read failed");
+ }
close(fd);
Document doc(repo, buf);
@@ -905,21 +909,27 @@ void DocumentTest::testGenerateSerializedFile()
#define SERIALIZED_DIR "../../test/document/"
int fd = open(SERIALIZED_DIR "/serializecpp.dat",
O_WRONLY | O_TRUNC | O_CREAT, 0644);
- write(fd, buf->getBuffer(), buf->getPos());
+ if (write(fd, buf->getBuffer(), buf->getPos()) != buf->getPos()) {
+ throw vespalib::Exception("write failed");
+ }
close(fd);
ByteBuffer hBuf(getSerializedSizeHeader(doc));
doc.serializeHeader(hBuf);
fd = open(SERIALIZED_DIR "/serializecppsplit_header.dat",
O_WRONLY | O_TRUNC | O_CREAT, 0644);
- write(fd, hBuf.getBuffer(), hBuf.getPos());
+ if (write(fd, hBuf.getBuffer(), hBuf.getPos()) != hBuf.getPos()) {
+ throw vespalib::Exception("write failed");
+ }
close(fd);
ByteBuffer bBuf(getSerializedSizeBody(doc));
doc.serializeBody(bBuf);
fd = open(SERIALIZED_DIR "/serializecppsplit_body.dat",
O_WRONLY | O_TRUNC | O_CREAT, 0644);
- write(fd, bBuf.getBuffer(), bBuf.getPos());
+ if (write(fd, bBuf.getBuffer(), bBuf.getPos()) != bBuf.getPos()) {
+ throw vespalib::Exception("write failed");
+ }
close(fd);
@@ -933,7 +943,9 @@ void DocumentTest::testGenerateSerializedFile()
fd = open(SERIALIZED_DIR "/serializecpp-lz4-level9.dat",
O_WRONLY | O_TRUNC | O_CREAT, 0644);
- write(fd, lz4buf.getBufferAtPos(), lz4buf.getRemaining());
+ if (write(fd, lz4buf.getBufferAtPos(), lz4buf.getRemaining()) != lz4buf.getRemaining()) {
+ throw vespalib::Exception("write failed");
+ }
close(fd);
}
void DocumentTest::testGetURIFromSerialized()
@@ -1300,7 +1312,9 @@ DocumentTest::testUnknownEntries()
int len = lseek(fd,0,SEEK_END);
ByteBuffer buf(len);
lseek(fd,0,SEEK_SET);
- read(fd, buf.getBuffer(), len);
+ if (read(fd, buf.getBuffer(), len) != len) {
+ throw vespalib::Exception("read failed");
+ }
close(fd);
DocumenttypesConfigBuilderHelper builder;
@@ -1347,7 +1361,9 @@ void DocumentTest::testAnnotationDeserialization()
int len = lseek(fd,0,SEEK_END);
ByteBuffer buf(len);
lseek(fd,0,SEEK_SET);
- read(fd, buf.getBuffer(), len);
+ if (read(fd, buf.getBuffer(), len) != len) {
+ throw vespalib::Exception("read failed");
+ }
close(fd);
Document doc(repo, buf);
diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp
index be619b0f35e..b2358f18937 100644
--- a/document/src/tests/documentupdatetestcase.cpp
+++ b/document/src/tests/documentupdatetestcase.cpp
@@ -556,8 +556,9 @@ void DocumentUpdateTest::testReadSerializedFile()
int len = lseek(fd,0,SEEK_END);
ByteBuffer buf(len);
lseek(fd,0,SEEK_SET);
- read(fd, buf.getBuffer(), len);
-
+ if (read(fd, buf.getBuffer(), len) != len) {
+ throw vespalib::Exception("read failed");
+ }
close(fd);
DocumentUpdate::UP updp(DocumentUpdate::create42(repo, buf));
@@ -648,7 +649,9 @@ void DocumentUpdateTest::testGenerateSerializedFile()
int fd = open("data/serializeupdatecpp.dat",
O_WRONLY | O_TRUNC | O_CREAT, 0644);
- write(fd, buf->getBuffer(), buf->getPos());
+ if (write(fd, buf->getBuffer(), buf->getPos()) != buf->getPos()) {
+ throw vespalib::Exception("read failed");
+ }
close(fd);
}
diff --git a/document/src/tests/fieldpathupdatetestcase.cpp b/document/src/tests/fieldpathupdatetestcase.cpp
index ec999d0dfe9..e261a7798bf 100644
--- a/document/src/tests/fieldpathupdatetestcase.cpp
+++ b/document/src/tests/fieldpathupdatetestcase.cpp
@@ -1278,8 +1278,9 @@ FieldPathUpdateTestCase::testReadSerializedFile()
int len = lseek(fd,0,SEEK_END);
ByteBuffer buf(len);
lseek(fd,0,SEEK_SET);
- read(fd, buf.getBuffer(), len);
-
+ if (read(fd, buf.getBuffer(), len) != len) {
+ throw vespalib::Exception("read failed");
+ }
close(fd);
DocumentUpdate::UP updp(DocumentUpdate::createHEAD(repo, buf));
@@ -1303,7 +1304,9 @@ FieldPathUpdateTestCase::testGenerateSerializedFile()
int fd = open("data/serialize-fieldpathupdate-cpp.dat",
O_WRONLY | O_TRUNC | O_CREAT, 0644);
- write(fd, buf->getBuffer(), buf->getPos());
+ if (write(fd, buf->getBuffer(), buf->getPos()) != buf->getPos()) {
+ throw vespalib::Exception("write failed");
+ }
close(fd);
}
diff --git a/documentapi/src/tests/messages/testbase.cpp b/documentapi/src/tests/messages/testbase.cpp
index a6aeefd883f..6819624fd13 100644
--- a/documentapi/src/tests/messages/testbase.cpp
+++ b/documentapi/src/tests/messages/testbase.cpp
@@ -174,7 +174,9 @@ TestBase::writeFile(const string &filename, const mbus::Blob& blob) const
if (file == -1) {
return false;
}
- write(file, blob.data(), blob.size());
+ if (write(file, blob.data(), blob.size()) != blob.size()) {
+ throw vespalib::Exception("write failed");
+ }
close(file);
return true;
}
@@ -187,7 +189,9 @@ TestBase::readFile(const string &filename) const
mbus::Blob blob(len);
if (file != -1) {
lseek(file, 0, SEEK_SET);
- read(file, blob.data(), len);
+ if (read(file, blob.data(), len) != len) {
+ throw vespalib::Exception("read failed");
+ }
close(file);
}
diff --git a/fastos/src/vespa/fastos/unix_ipc.cpp b/fastos/src/vespa/fastos/unix_ipc.cpp
index 98833661a38..f4ee9a8779f 100644
--- a/fastos/src/vespa/fastos/unix_ipc.cpp
+++ b/fastos/src/vespa/fastos/unix_ipc.cpp
@@ -554,7 +554,10 @@ Run(FastOS_ThreadInterface *thisThread, void *arg)
// Did someone want to wake us up from the poll() call?
if (woken) {
char dummy;
- read(_wakeupPipe[0], &dummy, 1);
+ ssize_t nbrfp = read(_wakeupPipe[0], &dummy, 1);
+ if (nbrfp != 1) {
+ perror("FastOS_UNIX_IPCHelper wakeupPipe read failed");
+ }
}
}
free(fds);
@@ -597,8 +600,11 @@ SendMessage (FastOS_UNIX_Process *xproc, const void *buffer,
void FastOS_UNIX_IPCHelper::NotifyProcessListChange ()
{
- char dummy = static_cast<char>(1);
- write(_wakeupPipe[1], &dummy, 1);
+ char dummy = 'x';
+ ssize_t nbwtp = write(_wakeupPipe[1], &dummy, 1);
+ if (nbwtp != 1) {
+ perror("FastOS_UNIX_IPCHelper: write to wakeupPipe failed");
+ }
}
void FastOS_UNIX_IPCHelper::Exit ()
diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.cpp b/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.cpp
index d93a1032ca3..f0a56c4fd0c 100644
--- a/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.cpp
+++ b/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.cpp
@@ -19,7 +19,9 @@ namespace {
std::string configRoot = "dirconfig.tmp";
int getFirstDirNumber() {
- system(("rm -rf " + configRoot).c_str());
+ if (system(("rm -rf " + configRoot).c_str()) != 0) {
+ throw vespalib::Exception("system(rm -rf "+configRoot+" failed");
+ }
return 0;
}
}
diff --git a/vespalog/src/vespa/log/control-file.cpp b/vespalog/src/vespa/log/control-file.cpp
index 3b9fe2834a9..32f5a850ccd 100644
--- a/vespalog/src/vespa/log/control-file.cpp
+++ b/vespalog/src/vespa/log/control-file.cpp
@@ -58,10 +58,15 @@ ControlFile::ensureHeader()
int len = read(fd, &buf, wantsLen);
if (len != wantsLen || memcmp(fileHeader, buf, wantsLen) != 0) {
if (len) {
- ftruncate(fd, 0);
+ if (ftruncate(fd, 0) != 0) {
+ perror("log::ControlFile ftruncate failed");
+ }
}
lseek(fd, 0, SEEK_SET);
- write(fd, fileHeader, strlen(fileHeader));
+ ssize_t nbw = write(fd, fileHeader, wantsLen);
+ if (nbw != wantsLen) {
+ perror("log::ControlFile write(A) failed");
+ }
char spaces[_maxPrefix + 1];
memset(spaces, ' ', sizeof spaces);
@@ -69,7 +74,12 @@ ControlFile::ensureHeader()
char buf2[sizeof(spaces) + 100];
snprintf(buf2, sizeof buf2, "Prefix: \n%s\n", spaces);
- write(fd, buf2, strlen(buf2));
+ wantsLen = strlen(buf2);
+ nbw = write(fd, buf2, wantsLen);
+ if (nbw != wantsLen) {
+ perror("log::ControlFile write(B) failed");
+ }
+
}
}