summaryrefslogtreecommitdiff
path: root/debian/patches/12_fix_compiler_warnings.diff
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/12_fix_compiler_warnings.diff')
-rw-r--r--debian/patches/12_fix_compiler_warnings.diff1083
1 files changed, 0 insertions, 1083 deletions
diff --git a/debian/patches/12_fix_compiler_warnings.diff b/debian/patches/12_fix_compiler_warnings.diff
deleted file mode 100644
index dbcf8b5..0000000
--- a/debian/patches/12_fix_compiler_warnings.diff
+++ /dev/null
@@ -1,1083 +0,0 @@
-Remove compiler warnings so SWORD will compile with -Wall -Werror
---- a/src/mgr/filemgr.cpp
-+++ b/src/mgr/filemgr.cpp
-@@ -409,7 +409,7 @@
-
-
- int FileMgr::copyFile(const char *sourceFile, const char *targetFile) {
-- int sfd, dfd, len;
-+ int sfd, dfd, len;
- char buf[4096];
-
- if ((sfd = ::open(sourceFile, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH)) < 1)
---- a/src/utilfuns/zlib/untgz.c
-+++ b/src/utilfuns/zlib/untgz.c
-@@ -262,7 +262,7 @@
- int remaining = 0;
- FILE *outfile = NULL;
- char fname[BLOCKSIZE];
-- time_t tartime;
-+ time_t tartime = 0;
-
- while (1) {
- len = gzread(in, &buffer, BLOCKSIZE);
---- a/tests/testblocks.cpp
-+++ b/tests/testblocks.cpp
-@@ -34,14 +34,18 @@
- void addEntry(EntriesBlock *eb) {
- string input;
- string body;
-- char line[1024];
-+ char line[1024], *c;
- std::cout << "\nEnter new Entry's text. '.' on an empty line to finish:\n";
- do {
- std::cout << "> ";
-- fgets(line, 1000, stdin);
-- input = line;
-- if (input.compare("."))
-- body.append(input);
-+ c = fgets(line, 1000, stdin);
-+ if (c == NULL) {
-+ std::cerr << "ERROR: fgets failed during addEntry\n";
-+ } else {
-+ input = line;
-+ if (input.compare("."))
-+ body.append(input);
-+ }
- }
- while (input.compare("."));
- std::cout << "Adding new entry. Index is: " << eb->addEntry(body.c_str()) << "\n\n";
-@@ -77,29 +81,33 @@
-
- EntriesBlock *eb = new EntriesBlock();
- string input;
-- char line[1024];
-+ char line[1024], *c;
-
- std::cout << "Initial entry count should be 0: " << eb->getCount() << "\n";
-
- do {
- std::cout << "[" << eb->getCount() << "] > ";
-- fgets(line, 1000, stdin);
-- input = line;
-- if (input.length() > 0) {
-- switch (input[0]) {
-- case 'a': addEntry(eb); break;
-- case 'p': printEntry(eb, atoi(input.c_str()+1)); break;
-- case 'r': removeEntry(eb, atoi(input.c_str()+1)); break;
-- case 's': printSize(eb); break;
-- case 'q': break;
-- case '?':
-- default:
-- std::cout << "\n a - add a new entry\n";
-- std::cout << " p <entry_index> - print entry\n";
-- std::cout << " r <entry_index> - remove entry\n";
-- std::cout << " s - print size of raw data\n";
-- std::cout << " q - quit\n\n";
-- break;
-+ c = fgets(line, 1000, stdin);
-+ if (c == NULL) {
-+ std::cerr << "ERROR: fgets failed in main\n";
-+ } else {
-+ input = line;
-+ if (input.length() > 0) {
-+ switch (input[0]) {
-+ case 'a': addEntry(eb); break;
-+ case 'p': printEntry(eb, atoi(input.c_str()+1)); break;
-+ case 'r': removeEntry(eb, atoi(input.c_str()+1)); break;
-+ case 's': printSize(eb); break;
-+ case 'q': break;
-+ case '?':
-+ default:
-+ std::cout << "\n a - add a new entry\n";
-+ std::cout << " p <entry_index> - print entry\n";
-+ std::cout << " r <entry_index> - remove entry\n";
-+ std::cout << " s - print size of raw data\n";
-+ std::cout << " q - quit\n\n";
-+ break;
-+ }
- }
- }
- }
---- a/utilities/stepdump.cpp
-+++ b/utilities/stepdump.cpp
-@@ -163,33 +163,56 @@
-
-
- void readVersion(int fd, Version *versionRecord) {
-+ int r;
-
- cout << "\n\nReading Version Record (" << 16/*sizeof(struct Version)*/ << " bytes)\n\n";
- // DO NOT USE BECAUSE OF RECORD BYTE ALIGNMENT PROBLEMS
- // read(fd, &versionRecord, sizeof(struct Version));
-
- cout << "Version Record Information\n";
-- read(fd, &(versionRecord->versionRecordSize), 2);
-+ r = read(fd, &(versionRecord->versionRecordSize), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVersion");
- cout << "\tversionRecordSize: " << versionRecord->versionRecordSize << "\n";
-- read(fd, &(versionRecord->publisherID), 2);
-+ r = read(fd, &(versionRecord->publisherID), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVersion");
- cout << "\tpublisherID: " << versionRecord->publisherID << "\n";
-- read(fd, &(versionRecord->bookID), 2);
-+ r = read(fd, &(versionRecord->bookID), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVersion");
- cout << "\tbookID: " << versionRecord->bookID << "\n";
-- read(fd, &(versionRecord->setID), 2);
-+ r = read(fd, &(versionRecord->setID), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVersion");
- cout << "\tsetID: " << versionRecord->setID << "\n";
-- read(fd, &(versionRecord->conversionProgramVerMajor), 1);
-+ r = read(fd, &(versionRecord->conversionProgramVerMajor), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readVersion");
- cout << "\tconversionProgramVerMajor: " << (int)versionRecord->conversionProgramVerMajor << "\n";
-- read(fd, &(versionRecord->conversionProgramVerMinor), 1);
-+ r = read(fd, &(versionRecord->conversionProgramVerMinor), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readVersion");
- cout << "\tconversionProgramVerMinor: " << (int)versionRecord->conversionProgramVerMinor << "\n";
-- read(fd, &(versionRecord->leastCompatSTEPVerMajor), 1);
-+ r = read(fd, &(versionRecord->leastCompatSTEPVerMajor), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readVersion");
- cout << "\tleastCompatSTEPVerMajor: " << (int)versionRecord->leastCompatSTEPVerMajor << "\n";
-- read(fd, &(versionRecord->leastCompatSTEPVerMinor), 1);
-+ r = read(fd, &(versionRecord->leastCompatSTEPVerMinor), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readVersion");
- cout << "\tleastCompatSTEPVerMinor: " << (int)versionRecord->leastCompatSTEPVerMinor << "\n";
-- read(fd, &(versionRecord->encryptionType), 1);
-+ r = read(fd, &(versionRecord->encryptionType), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readVersion");
- cout << "\tencryptionType: " << (int)versionRecord->encryptionType << "\n";
-- read(fd, &(versionRecord->editionID), 1);
-+ r = read(fd, &(versionRecord->editionID), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readVersion");
- cout << "\teditionID: " << (int)versionRecord->editionID << "\n";
-- read(fd, &(versionRecord->modifiedBy), 2);
-+ r = read(fd, &(versionRecord->modifiedBy), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVersion");
- cout << "\tmodifiedBy: " << versionRecord->modifiedBy << "\n";
-
- int skip = versionRecord->versionRecordSize - 16/*sizeof(struct Version*/;
-@@ -197,33 +220,49 @@
- if (skip) {
- cout << "\nSkipping " << skip << " unknown bytes.\n";
- char *skipbuf = new char[skip];
-- read(fd, skipbuf, skip);
-+ r = read(fd, skipbuf, skip);
-+ if (r != skip)
-+ perror("ERROR: read failed in readVersion");
- delete [] skipbuf;
- }
- }
-
-
- void readViewableHeader(int fd, ViewableHeader *viewableHeaderRecord) {
--
-+ int r;
- cout << "\n\nReading Viewable Header Record (" << 16/*sizeof(struct ViewableHeader)*/ << " bytes)\n\n";
-
- // DO NOT USE BECAUSE OF RECORD BYTE ALIGNMENT PROBLEMS
- // read(fd, &viewableHeaderRecord, sizeof(struct ViewableHeader));
-
- cout << "Viewable Header Record Information\n";
-- read(fd, &(viewableHeaderRecord->viewableHeaderRecordSize), 2);
-+ r = read(fd, &(viewableHeaderRecord->viewableHeaderRecordSize), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readViewableHeader");
- cout << "\tviewableHeaderRecordSize: " << viewableHeaderRecord->viewableHeaderRecordSize << "\n";
-- read(fd, &(viewableHeaderRecord->viewableBlocksCount), 4);
-+ r = read(fd, &(viewableHeaderRecord->viewableBlocksCount), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readViewableHeader");
- cout << "\tviewableBlocksCount: " << viewableHeaderRecord->viewableBlocksCount << "\n";
-- read(fd, &(viewableHeaderRecord->glossBlocksCount), 4);
-+ r = read(fd, &(viewableHeaderRecord->glossBlocksCount), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readViewableHeader");
- cout << "\tglossBlocksCount: " << viewableHeaderRecord->glossBlocksCount << "\n";
-- read(fd, &(viewableHeaderRecord->compressionType), 1);
-+ r = read(fd, &(viewableHeaderRecord->compressionType), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readViewableHeader");
- cout << "\tcompressionType: " << (int)viewableHeaderRecord->compressionType << "(0 - none; 1 - LZSS)\n";
-- read(fd, &(viewableHeaderRecord->reserved1), 1);
-+ r = read(fd, &(viewableHeaderRecord->reserved1), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readViewableHeader");
- cout << "\treserved1: " << (int)viewableHeaderRecord->reserved1 << "\n";
-- read(fd, &(viewableHeaderRecord->blockEntriesSize), 2);
-+ r = read(fd, &(viewableHeaderRecord->blockEntriesSize), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readViewableHeader");
- cout << "\tblockEntriesSize: " << viewableHeaderRecord->blockEntriesSize << "\n";
-- read(fd, &(viewableHeaderRecord->reserved2), 2);
-+ r = read(fd, &(viewableHeaderRecord->reserved2), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readViewableHeader");
- cout << "\treserved2: " << viewableHeaderRecord->reserved2 << "\n";
-
- int skip = viewableHeaderRecord->viewableHeaderRecordSize - 16/*sizeof(struct ViewableHeader)*/;
-@@ -231,18 +270,23 @@
- if (skip) {
- cout << "\nSkipping " << skip << " unknown bytes.\n";
- char *skipbuf = new char[skip];
-- read(fd, skipbuf, skip);
-+ r = read(fd, skipbuf, skip);
-+ if (r != skip)
-+ perror("ERROR: read failed in readViewableHeader");
- delete [] skipbuf;
- }
- }
-
-
- void readViewableBlockText(int fd, ViewableBlock *vb, char **buf) {
-+ int r;
- unsigned long size = vb->size;
-
- *buf = new char [ ((vb->size > vb->uncompressedSize) ? vb->size : vb->uncompressedSize) + 1 ];
- lseek(fd, vb->offset, SEEK_SET);
-- read(fd, *buf, vb->size);
-+ r = read(fd, *buf, vb->size);
-+ if (r != vb->size)
-+ perror("ERROR: read failed in readViewableBlocktext");
-
- compress->zBuf(&size, *buf);
- strcpy(*buf, compress->Buf());
-@@ -252,30 +296,41 @@
-
-
- void readViewableBlock(int fd, ViewableBlock *vb) {
--
-+ int r;
- cout << "\n\nReading Viewable Block (" << 12/*sizeof(struct ViewableHeader)*/ << " bytes)\n\n";
-
- // DO NOT USE BECAUSE OF RECORD BYTE ALIGNMENT PROBLEMS
- // read(fd, &vb, sizeof(struct ViewableBlock));
-
- cout << "Viewable Block Information\n";
-- read(fd, &(vb->offset), 4);
-+ r = read(fd, &(vb->offset), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readViewableBlock");
- cout << "\toffset: " << vb->offset << "\n";
-- read(fd, &(vb->uncompressedSize), 4);
-+ r = read(fd, &(vb->uncompressedSize), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readViewableBlock");
- cout << "\tuncompressedSize: " << vb->uncompressedSize << "\n";
-- read(fd, &(vb->size), 4);
-+ r = read(fd, &(vb->size), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readViewableBlock");
- cout << "\tsize: " << vb->size << "\n";
- }
-
-
- void readHeaderControlWordAreaText(int fd, char **buf) {
-+ int r;
- long headerControlWordAreaSize;
-- read(fd, &headerControlWordAreaSize, 4);
-+ r = read(fd, &headerControlWordAreaSize, 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readHeaderControlWordAreaText");
- cout << "Reading Header Control Word Area (" << headerControlWordAreaSize << " bytes)\n\n";
-
- *buf = new char [headerControlWordAreaSize + 1];
-
-- read(fd, *buf, headerControlWordAreaSize);
-+ r = read(fd, *buf, headerControlWordAreaSize);
-+ if (r != headerControlWordAreaSize)
-+ perror("ERROR: read failed in readHeaderControlWordAreaText");
- (*buf)[headerControlWordAreaSize] = 0;
-
- cout << "headerControlWordArea:\n" << *buf << "\n";
---- a/utilities/treeidxutil.cpp
-+++ b/utilities/treeidxutil.cpp
-@@ -58,27 +58,33 @@
-
-
- void setLocalName(TreeKeyIdx *treeKey) {
-- char buf[1023];
-+ char buf[1023], *c;
- std::cout << "Enter New Node Name: ";
-- fgets(buf, 1000, stdin);
-+ c = fgets(buf, 1000, stdin);
-+ if (c == NULL)
-+ std::cerr << "ERROR: fgets failed in setLocalName\n";
- treeKey->setLocalName(buf);
- treeKey->save();
- }
-
-
- void assurePath(TreeKeyIdx *treeKey) {
-- char buf[1023];
-+ char buf[1023], *c;
- std::cout << "Enter path: ";
-- fgets(buf, 1000, stdin);
-+ c = fgets(buf, 1000, stdin);
-+ if (c == NULL)
-+ std::cerr << "ERROR: fgets failed in assurePath\n";
- treeKey->assureKeyPath(buf);
- }
-
-
- void appendSibbling(TreeKeyIdx *treeKey) {
- if (treeKey->getOffset()) {
-- char buf[1023];
-+ char buf[1023], *c;
- std::cout << "Enter New Sibbling Name: ";
-- fgets(buf, 1000, stdin);
-+ c = fgets(buf, 1000, stdin);
-+ if (c == NULL)
-+ std::cerr << "ERROR: fgets failed in appendSibbling\n";
- treeKey->append();
- treeKey->setLocalName(buf);
- treeKey->save();
-@@ -88,9 +94,11 @@
-
-
- void appendChild(TreeKeyIdx *treeKey) {
-- char buf[1023];
-+ char buf[1023], *c;
- std::cout << "Enter New Child Name: ";
-- fgets(buf, 1000, stdin);
-+ c = fgets(buf, 1000, stdin);
-+ if (c == NULL)
-+ std::cerr << "ERROR: fgets failed in appendChild\n";
- treeKey->appendChild();
- treeKey->setLocalName(buf);
- treeKey->save();
-@@ -123,11 +131,13 @@
- TreeKeyIdx root = *treeKey;
-
- std::string input;
-- char line[1024];
-+ char line[1024], *c;
-
- do {
- std::cout << "[" << treeKey->getText() << "] > ";
-- fgets(line, 1000, stdin);
-+ c = fgets(line, 1000, stdin);
-+ if (c == NULL)
-+ std::cerr << "ERROR: fgets failed in main\n";
- input = line;
- if (input.length() > 0) {
- switch (input[0]) {
---- a/utilities/gbfidx.cpp
-+++ b/utilities/gbfidx.cpp
-@@ -55,7 +55,7 @@
- int main(int argc, char **argv)
- {
- long pos, offset;
-- int num1, num2, rangemax;
-+ int num1, num2, rangemax, w;
- char startflag = 0;
- short size;
-
-@@ -67,18 +67,30 @@
- num1 = key1.getChapter();
- num2 = key1.getVerse();
- pos = 0;
-- write(bfp, &pos, 4); /* Book offset for testament intros */
-+ w = write(bfp, &pos, 4); /* Book offset for testament intros */
-+ if (w != 4)
-+ perror("ERROR: write failed in main");
- pos = 4;
-- write(cfp, &pos, 4); /* Chapter offset for testament intro */
-+ w = write(cfp, &pos, 4); /* Chapter offset for testament intro */
-+ if (w != 4)
-+ perror("ERROR: write failed in main");
-
-
- /* Right now just zero out intros until parsing correctly */
- pos = 0;
- size = 0;
-- write(vfp, &pos, 4); /* Module intro */
-- write(vfp, &size, 2);
-- write(vfp, &pos, 4); /* Testament intro */
-- write(vfp, &size, 2);
-+ w = write(vfp, &pos, 4); /* Module intro */
-+ if (w != 4)
-+ perror("ERROR: write failed in main");
-+ w = write(vfp, &size, 2);
-+ if (w != 2)
-+ perror("ERROR: write failed in main");
-+ w = write(vfp, &pos, 4); /* Testament intro */
-+ if (w != 4)
-+ perror("ERROR: write failed in main");
-+ w = write(vfp, &size, 2);
-+ if (w != 2)
-+ perror("ERROR: write failed in main");
-
- while(!findbreak(fp, &offset, &num1, &num2, &rangemax, &size)) {
- if (!startflag) {
-@@ -122,6 +134,7 @@
-
- void writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size)
- {
-+ int w;
- long pos;
- short tmp;
-
-@@ -129,26 +142,48 @@
- if (key1.getVerse() == 1) { // new chapter
- if (key1.getChapter() == 1) { // new book
- pos = lseek(cfp, 0, SEEK_CUR);
-- write(bfp, &pos, 4);
-+ w = write(bfp, &pos, 4);
-+ if (w != 2)
-+ perror("ERROR: write failed in writeidx");
- pos = lseek(vfp, 0, SEEK_CUR); /* Book intro (cps) */
-- write(cfp, &pos, 4);
-- write(vfp, &chapoffset, 4); /* Book intro (vss) set to same as chap for now(it should be chap 1 which usually contains the book into anyway)*/
-- write(vfp, &chapsize, 2);
-+ w = write(cfp, &pos, 4);
-+ if (w != 2)
-+ perror("ERROR: write failed in writeidx");
-+ w = write(vfp, &chapoffset, 4); /* Book intro (vss) set to same as chap for now(it should be chap 1 which usually contains the book into anyway)*/
-+ if (w != 2)
-+ perror("ERROR: write failed in writeidx");
-+ w = write(vfp, &chapsize, 2);
-+ if (w != 2)
-+ perror("ERROR: write failed in writeidx");
- }
- pos = lseek(vfp, 0, SEEK_CUR);
-- write(cfp, &pos, 4);
-- write(vfp, &chapoffset, 4); /* Chapter intro */
-- write(vfp, &chapsize, 2);
-+ w = write(cfp, &pos, 4);
-+ if (w != 4)
-+ perror("ERROR: write failed in writeidx");
-+ w = write(vfp, &chapoffset, 4); /* Chapter intro */
-+ if (w != 4)
-+ perror("ERROR: write failed in writeidx");
-+ w = write(vfp, &chapsize, 2);
-+ if (w != 2)
-+ perror("ERROR: write failed in writeidx");
- }
- if (key1 >= key2) {
-- write(vfp, &offset, 4);
-- write(vfp, &size, 2);
-+ w = write(vfp, &offset, 4);
-+ if (w != 4)
-+ perror("ERROR: write failed in writeidx");
-+ w = write(vfp, &size, 2);
-+ if (w != 2)
-+ perror("ERROR: write failed in writeidx");
- }
- else {
- pos = 0;
- tmp = 0;
-- write(vfp, &pos, 4);
-- write(vfp, &tmp, 2);
-+ w = write(vfp, &pos, 4);
-+ if (w != 4)
-+ perror("ERROR: write failed in writeidx");
-+ w = write(vfp, &tmp, 2);
-+ if (w != 2)
-+ perror("ERROR: write failed in writeidx");
- }
- }
- }
---- a/utilities/genbookutil.cpp
-+++ b/utilities/genbookutil.cpp
-@@ -58,9 +58,11 @@
-
-
- void setLocalName(TreeKeyIdx *treeKey) {
-- char buf[1023];
-+ char buf[1023], *c;
- std::cout << "Enter New Node Name: ";
-- fgets(buf, 1000, stdin);
-+ c = fgets(buf, 1000, stdin);
-+ if (c == NULL)
-+ std::cerr << "ERROR: fgets failed in setLocalName\n";
- SWBuf name = buf;
- treeKey->setLocalName(name.trim());
- treeKey->save();
-@@ -68,18 +70,22 @@
-
-
- void gotoPath(TreeKeyIdx *treeKey) {
-- char buf[1023];
-+ char buf[1023], *c;
- std::cout << "Enter Path: ";
-- fgets(buf, 1000, stdin);
-+ c = fgets(buf, 1000, stdin);
-+ if (c == NULL)
-+ std::cerr << "ERROR: fgets failed in gotoPath\n";
- SWBuf path = buf;
- (*treeKey) = path.trim();
- }
-
-
- void assurePath(TreeKeyIdx *treeKey) {
-- char buf[1023];
-+ char buf[1023], *c;
- std::cout << "Enter Path: ";
-- fgets(buf, 1000, stdin);
-+ c = fgets(buf, 1000, stdin);
-+ if (c == NULL)
-+ std::cerr << "ERROR: fgets failed in assurePath\n";
- SWBuf path = buf;
- treeKey->assureKeyPath(path.trim());
- }
-@@ -96,10 +102,12 @@
- SWBuf body;
- TreeKeyIdx *treeKey = (TreeKeyIdx *)(SWKey *)(*book);
- if (treeKey->getOffset()) {
-- char buf[1023];
-+ char buf[1023], *c;
- std::cout << "Enter New Entry Text ('.' on a line by itself to end): \n";
- do {
-- fgets(buf, 1000, stdin);
-+ c = fgets(buf, 1000, stdin);
-+ if (c == NULL)
-+ std::cerr << "ERROR: fgets failed in setEntryText\n";
- SWBuf text = buf;
- text.trim();
- if ((text[0] == '.') && (text[1] == 0))
-@@ -116,9 +124,11 @@
-
- void appendSibbling(TreeKeyIdx *treeKey) {
- if (treeKey->getOffset()) {
-- char buf[1023];
-+ char buf[1023], *c;
- std::cout << "Enter New Sibbling Name: ";
-- fgets(buf, 1000, stdin);
-+ c = fgets(buf, 1000, stdin);
-+ if (c == NULL)
-+ std::cerr << "ERROR: fgets failed in appendSibbling\n";
- SWBuf name = buf;
- treeKey->append();
- treeKey->setLocalName(name.trim());
-@@ -129,9 +139,11 @@
-
-
- void appendChild(TreeKeyIdx *treeKey) {
-- char buf[1023];
-+ char buf[1023], *c;
- std::cout << "Enter New Child Name: ";
-- fgets(buf, 1000, stdin);
-+ c = fgets(buf, 1000, stdin);
-+ if (c == NULL)
-+ std::cerr << "ERROR: fgets failed in appendChild\n";
- SWBuf name = buf;
- treeKey->appendChild();
- treeKey->setLocalName(name.trim());
-@@ -173,11 +185,13 @@
- treeKey = (TreeKeyIdx *)(SWKey *)(*book);
-
- SWBuf input;
-- char line[1024];
-+ char line[1024], *c;
-
- do {
- std::cout << "[" << treeKey->getText() << "] > ";
-- fgets(line, 1000, stdin);
-+ c = fgets(line, 1000, stdin);
-+ if (c == NULL)
-+ std::cerr << "ERROR: fgets failed in main\n";
- input = line;
- input.trim();
- if (input.length() > 0) {
---- a/utilities/vpl2mod.cpp
-+++ b/utilities/vpl2mod.cpp
-@@ -76,14 +76,18 @@
- break;
- }
-
-- int size = (lseek(fd, 0, SEEK_CUR) - index) - 1;
-+ int r, size = (lseek(fd, 0, SEEK_CUR) - index) - 1;
-
- *buf = new char [ size + 1 ];
-
- if (size > 0) {
- lseek(fd, index, SEEK_SET);
-- read(fd, *buf, size);
-- read(fd, &ch, 1); //pop terminating char
-+ r = read(fd, *buf, size);
-+ if (r != size)
-+ std::cerr <<"ERROR: short read in readline\n";
-+ r = read(fd, &ch, 1); //pop terminating char
-+ if (r != size)
-+ std::cerr <<"ERROR: short read of terminating char in readline\n";
- (*buf)[size] = 0;
-
- // clean up any trailing junk on buf
---- a/utilities/installmgr.cpp
-+++ b/utilities/installmgr.cpp
-@@ -74,8 +74,10 @@
- cout << "then type yes at the prompt\n\n";
- cout << "enable? [no] ";
-
-- char prompt[10];
-- fgets(prompt, 9, stdin);
-+ char prompt[10], *c;
-+ c = fgets(prompt, 9, stdin);
-+ if (c == NULL)
-+ std::cerr <<"ERROR: fgets failed in isUserDisclaimerConfirmed\n";
- confirmed = (!strcmp(prompt, "yes\n"));
- cout << "\n";
- }
---- a/utilities/step2vpl.cpp
-+++ b/utilities/step2vpl.cpp
-@@ -228,93 +228,169 @@
-
-
- void readVersion(int fd, Version *versionRecord) {
-+ int r;
-
-- read(fd, &(versionRecord->versionRecordSize), 2);
-- read(fd, &(versionRecord->publisherID), 2);
-- read(fd, &(versionRecord->bookID), 2);
-- read(fd, &(versionRecord->setID), 2);
-- read(fd, &(versionRecord->conversionProgramVerMajor), 1);
-- read(fd, &(versionRecord->conversionProgramVerMinor), 1);
-- read(fd, &(versionRecord->leastCompatSTEPVerMajor), 1);
-- read(fd, &(versionRecord->leastCompatSTEPVerMinor), 1);
-- read(fd, &(versionRecord->encryptionType), 1);
-- read(fd, &(versionRecord->editionID), 1);
-- read(fd, &(versionRecord->modifiedBy), 2);
-+ r = read(fd, &(versionRecord->versionRecordSize), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVersion");
-+
-+ r = read(fd, &(versionRecord->publisherID), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVersion");
-+ r = read(fd, &(versionRecord->bookID), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVersion");
-+ r = read(fd, &(versionRecord->setID), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVersion");
-+ r = read(fd, &(versionRecord->conversionProgramVerMajor), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readVersion");
-+ r = read(fd, &(versionRecord->conversionProgramVerMinor), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readVersion");
-+ r = read(fd, &(versionRecord->leastCompatSTEPVerMajor), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readVersion");
-+ r = read(fd, &(versionRecord->leastCompatSTEPVerMinor), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readVersion");
-+ r = read(fd, &(versionRecord->encryptionType), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readVersion");
-+ r = read(fd, &(versionRecord->editionID), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readVersion");
-+ r = read(fd, &(versionRecord->modifiedBy), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVersion");
-
- int skip = versionRecord->versionRecordSize - 16/*sizeof(struct Version*/;
-
- if (skip) {
- char *skipbuf = new char[skip];
-- read(fd, skipbuf, skip);
-+ r = read(fd, skipbuf, skip);
-+ if (r != skip)
-+ perror("ERROR: read failed in readVersion");
- delete [] skipbuf;
- }
- }
-
-
- void readSectionsHeader(int fd, SectionsHeader *sectionsHeaderRecord) {
-+ int r;
-
-- read(fd, &(sectionsHeaderRecord->sectionsHeaderRecordSize), 2);
-- read(fd, &(sectionsHeaderRecord->levelEntriesCount), 4);
-- read(fd, &(sectionsHeaderRecord->glossEntriesCount), 4);
-- read(fd, &(sectionsHeaderRecord->levelEntriesSize), 2);
-- read(fd, &(sectionsHeaderRecord->reserved), 4);
-+ r = read(fd, &(sectionsHeaderRecord->sectionsHeaderRecordSize), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readSectionsHeader");
-+ r = read(fd, &(sectionsHeaderRecord->levelEntriesCount), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readSectionsHeader");
-+ r = read(fd, &(sectionsHeaderRecord->glossEntriesCount), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readSectionsHeader");
-+ r = read(fd, &(sectionsHeaderRecord->levelEntriesSize), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readSectionsHeader");
-+ r = read(fd, &(sectionsHeaderRecord->reserved), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readSectionsHeader");
-
- int skip = sectionsHeaderRecord->sectionsHeaderRecordSize - 16/*sizeof(struct ViewableHeader)*/;
-
- if (skip) {
- char *skipbuf = new char[skip];
-- read(fd, skipbuf, skip);
-+ r = read(fd, skipbuf, skip);
-+ if (r != skip)
-+ perror("ERROR: read failed in readSectionsHeader");
- delete [] skipbuf;
- }
- }
-
-
- void readViewableHeader(int fd, ViewableHeader *viewableHeaderRecord) {
-+ int r;
-
-- read(fd, &(viewableHeaderRecord->viewableHeaderRecordSize), 2);
-- read(fd, &(viewableHeaderRecord->viewableBlocksCount), 4);
-- read(fd, &(viewableHeaderRecord->glossBlocksCount), 4);
-- read(fd, &(viewableHeaderRecord->compressionType), 1);
-- read(fd, &(viewableHeaderRecord->reserved1), 1);
-- read(fd, &(viewableHeaderRecord->blockEntriesSize), 2);
-- read(fd, &(viewableHeaderRecord->reserved2), 2);
-+ r = read(fd, &(viewableHeaderRecord->viewableHeaderRecordSize), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readViewableHeader");
-+ r = read(fd, &(viewableHeaderRecord->viewableBlocksCount), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readViewableHeader");
-+ r = read(fd, &(viewableHeaderRecord->glossBlocksCount), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readViewableHeader");
-+ r = read(fd, &(viewableHeaderRecord->compressionType), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readViewableHeader");
-+ r = read(fd, &(viewableHeaderRecord->reserved1), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readViewableHeader");
-+ r = read(fd, &(viewableHeaderRecord->blockEntriesSize), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readViewableHeader");
-+ r = read(fd, &(viewableHeaderRecord->reserved2), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readViewableHeader");
-
- int skip = viewableHeaderRecord->viewableHeaderRecordSize - 16/*sizeof(struct ViewableHeader)*/;
-
- if (skip) {
- char *skipbuf = new char[skip];
-- read(fd, skipbuf, skip);
-+ r = read(fd, skipbuf, skip);
-+ if (r != skip)
-+ perror("ERROR: read failed in readViewableHeader");
- delete [] skipbuf;
- }
- }
-
-
- void readVSyncHeader(int fd, VSyncHeader *vSyncHeaderRecord) {
-+ int r;
-
-- read(fd, &(vSyncHeaderRecord->vSyncHeaderRecordSize), 2);
-- read(fd, &(vSyncHeaderRecord->startBookNumber), 2);
-- read(fd, &(vSyncHeaderRecord->endBookNumber), 2);
-- read(fd, &(vSyncHeaderRecord->bookPointerEntriesSize), 2);
-- read(fd, &(vSyncHeaderRecord->syncPointEntriesSize), 2);
-- read(fd, &(vSyncHeaderRecord->reserved1_1), 4);
-- read(fd, &(vSyncHeaderRecord->reserved1_2), 2);
-+ r = read(fd, &(vSyncHeaderRecord->vSyncHeaderRecordSize), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVSyncHeader");
-+ r = read(fd, &(vSyncHeaderRecord->startBookNumber), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVSyncHeader");
-+ r = read(fd, &(vSyncHeaderRecord->endBookNumber), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVSyncHeader");
-+ r = read(fd, &(vSyncHeaderRecord->bookPointerEntriesSize), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVSyncHeader");
-+ r = read(fd, &(vSyncHeaderRecord->syncPointEntriesSize), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVSyncHeader");
-+ r = read(fd, &(vSyncHeaderRecord->reserved1_1), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readVSyncHeader");
-+ r = read(fd, &(vSyncHeaderRecord->reserved1_2), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVSyncHeader");
-
- int skip = vSyncHeaderRecord->vSyncHeaderRecordSize - 16/*sizeof(VSyncHeader)*/;
-
- if (skip) {
- char *skipbuf = new char[skip];
-- read(fd, skipbuf, skip);
-+ r = read(fd, skipbuf, skip);
-+ if (r != skip)
-+ perror("ERROR: read failed in readVSyncHeader");
- delete [] skipbuf;
- }
- }
-
-
- void readViewableBlockText(int fd, ViewableBlock *vb, char **buf) {
-+ int r;
- unsigned long size = vb->size;
-
- *buf = new char [ ((vb->size > vb->uncompressedSize) ? vb->size : vb->uncompressedSize) + 1 ];
- lseek(fd, vb->offset, SEEK_SET);
-- read(fd, *buf, vb->size);
-+ r = read(fd, *buf, vb->size);
-+ if (r != vb->size)
-+ perror("ERROR: read failed in readViewableBlockText");
-
- compress->zBuf(&size, *buf);
- strcpy(*buf, compress->Buf());
-@@ -322,35 +398,53 @@
-
-
- void readViewableBlock(int fd, ViewableBlock *vb) {
-+ int r;
-
-- read(fd, &(vb->offset), 4);
-- read(fd, &(vb->uncompressedSize), 4);
-- read(fd, &(vb->size), 4);
-+ r = read(fd, &(vb->offset), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readViewableBlock");
-+ r = read(fd, &(vb->uncompressedSize), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readViewableBlock");
-+ r = read(fd, &(vb->size), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readViewableBlock");
- }
-
-
- void readHeaderControlWordAreaText(int fd, char **buf) {
-+ int r;
- long headerControlWordAreaSize;
-- read(fd, &headerControlWordAreaSize, 4);
-+ r = read(fd, &headerControlWordAreaSize, 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readHeaderControlWordAreaText");
-
- *buf = new char [headerControlWordAreaSize + 1];
-
-- read(fd, *buf, headerControlWordAreaSize);
-+ r = read(fd, *buf, headerControlWordAreaSize);
-+ if (r != headerControlWordAreaSize)
-+ perror("ERROR: read failed in readHeaderControlWordAreaText");
- (*buf)[headerControlWordAreaSize] = 0;
-
- }
-
- void readVSyncBooksInfo(int fd, VSyncHeader *vSyncHeaderRecord, VSyncBooksInfo **vSyncBooksInfo) {
-
-+ int r;
- int bookCount = vSyncHeaderRecord->endBookNumber - vSyncHeaderRecord->startBookNumber;
- *vSyncBooksInfo = new VSyncBooksInfo[bookCount];
- for (int i = 0; i <= bookCount; i++) {
-- read(fd, &(*vSyncBooksInfo)[i].offset, 4);
-- read(fd, &(*vSyncBooksInfo)[i].count, 2);
-+ r = read(fd, &(*vSyncBooksInfo)[i].offset, 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readVSyncBooksInfo");
-+ r = read(fd, &(*vSyncBooksInfo)[i].count, 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readVSyncBooksInfo");
- }
- }
-
- void displayBook(int fdbook, int fdviewable, int fdvsync, int fdsections, VSyncBooksInfo *vSyncBooksInfo) {
-+ int r;
- VSyncPoint vSyncPoint;
-
- lseek(fdvsync, vSyncBooksInfo->offset, SEEK_SET);
-@@ -361,9 +455,15 @@
- char *sectionName;
- char *verseText;
-
-- read(fdvsync, &(vSyncPoint.chapter), 2);
-- read(fdvsync, &(vSyncPoint.verse), 2);
-- read(fdvsync, &(vSyncPoint.offset), 4);
-+ r = read(fdvsync, &(vSyncPoint.chapter), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in displayBook");
-+ r = read(fdvsync, &(vSyncPoint.verse), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in displayBook");
-+ r = read(fdvsync, &(vSyncPoint.offset), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in displayBook");
- vSyncPoint.offset = SECTIONSLEVELSTART + (vSyncPoint.offset * SECTIONSLEVELSIZE);
- lseek(fdsections, vSyncPoint.offset, SEEK_SET);
- readSectionLevelInfo(fdsections, &sectionLevelInfo);
-@@ -418,26 +518,50 @@
-
-
- void readSectionName(int fd, SectionLevelInfo *sli, char **name) {
-+ int r;
- short size;
- lseek(fd, sli->nameOffset, SEEK_SET);
-- read(fd, &size, 2);
-+ r = read(fd, &size, 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readSectionName");
- *name = new char [ size + 1 ];
-- read(fd, *name, size);
-+ r = read(fd, *name, size);
-+ if (r != size)
-+ perror("ERROR: read failed in readSectionName");
- (*name)[size] = 0;
- }
-
- void readSectionLevelInfo(int fd, SectionLevelInfo *sli) {
-+ int r;
-
-- read(fd, &(sli->parentOffset), 4);
-- read(fd, &(sli->previousOffset), 4);
-- read(fd, &(sli->nextOffset), 4);
-- read(fd, &(sli->viewableOffset), 4);
-+ r = read(fd, &(sli->parentOffset), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readSectionLevelInfo");
-+ r = read(fd, &(sli->previousOffset), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readSectionLevelInfo");
-+ r = read(fd, &(sli->nextOffset), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readSectionLevelInfo");
-+ r = read(fd, &(sli->viewableOffset), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readSectionLevelInfo");
- sli->viewableOffset = VIEWABLEBLOCKSTART + (VIEWABLEBLOCKSIZE * sli->viewableOffset);
-- read(fd, &(sli->startLevel), 2);
-- read(fd, &(sli->level), 1);
-- read(fd, &(sli->nameOffset), 4);
-- read(fd, &(sli->outSync_1), 4);
-- read(fd, &(sli->outSync_2), 2);
-+ r = read(fd, &(sli->startLevel), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readSectionLevelInfo");
-+ r = read(fd, &(sli->level), 1);
-+ if (r != 1)
-+ perror("ERROR: read failed in readSectionLevelInfo");
-+ r = read(fd, &(sli->nameOffset), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readSectionLevelInfo");
-+ r = read(fd, &(sli->outSync_1), 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in readSectionLevelInfo");
-+ r = read(fd, &(sli->outSync_2), 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in readSectionLevelInfo");
- }
-
- void cleanBuf(char *buf) {
---- a/utilities/cipherraw.cpp
-+++ b/utilities/cipherraw.cpp
-@@ -53,7 +53,7 @@
- SWCipher *zobj;
- VerseKey key;
- RawVerse *rawdrv;
-- int ofd[2], oxfd[2];
-+ int ofd[2], oxfd[2], w;
- long tmpoff = 0, offset, loffset = 0, lzoffset = 0;
- unsigned short size, lsize = 0, lzsize;
- char *tmpbuf;
-@@ -79,10 +79,18 @@
- delete [] tmpbuf;
-
- printf("\n");
-- write(oxfd[0], &lzoffset, 4);
-- write(oxfd[0], &lzsize, 2);
-- write(oxfd[1], &lzoffset, 4);
-- write(oxfd[1], &lzsize, 2);
-+ w = write(oxfd[0], &lzoffset, 4);
-+ if (w < 0)
-+ perror("ERROR: write failed in main");
-+ w = write(oxfd[0], &lzsize, 2);
-+ if (w < 0)
-+ perror("ERROR: write failed in main");
-+ w = write(oxfd[1], &lzoffset, 4);
-+ if (w < 0)
-+ perror("ERROR: write failed in main");
-+ w = write(oxfd[1], &lzsize, 2);
-+ if (w < 0)
-+ perror("ERROR: write failed in main");
-
- key.setAutoNormalize(false);
- key.setIntros(true);
-@@ -94,8 +102,10 @@
- printf("using previous offset,size %d\n", size);
- offset = lseek(oxfd[key.getTestament() - 1], 0, SEEK_CUR);
- printf("%ld %ld %d \n", offset, lzoffset, lzsize);
-- write(oxfd[key.getTestament() - 1], &lzoffset, 4);
-- write(oxfd[key.getTestament() - 1], &lzsize, 2);
-+ if (write(oxfd[key.getTestament() - 1], &lzoffset, 4) < 0)
-+ perror("ERROR: write failed in main");
-+ if (write(oxfd[key.getTestament() - 1], &lzsize, 2) < 0)
-+ perror("ERROR: write failed in main");
- }
- else {
- lsize = size;
-@@ -112,13 +122,17 @@
- offset = lseek(ofd[key.getTestament() - 1], 0, SEEK_CUR);
- tmpoff = lseek(oxfd[key.getTestament() - 1], 0, SEEK_CUR);
- printf("%s: (%ld) NEW offset: %ld; size: %d\n", (const char *)key, tmpoff, offset, size);
-- write(oxfd[key.getTestament() - 1], &offset, 4);
-+ if (write(oxfd[key.getTestament() - 1], &offset, 4) < 0)
-+ perror("ERROR: write failed in main");
- unsigned long ulSize = size;
-- if (size)
-- write(ofd[key.getTestament() - 1], zobj->cipherBuf(&ulSize), size);
-+ if (size) {
-+ if (write(ofd[key.getTestament() - 1], zobj->cipherBuf(&ulSize), size) < 0)
-+ perror("ERROR: write failed in main");
-+ }
- size = (unsigned int)ulSize;
- lzoffset = offset;
-- write(oxfd[key.getTestament() - 1], &size, 2);
-+ if (write(oxfd[key.getTestament() - 1], &size, 2) < 0)
-+ perror("ERROR: write failed in main");
- lzsize = size;
- }
- }
---- a/utilities/lexdump.c
-+++ b/utilities/lexdump.c
-@@ -45,7 +45,7 @@
-
- int main(int argc, char **argv) {
- char *tmpbuf;
-- int idxfd, datfd;
-+ int idxfd, datfd, r;
- long offset;
- unsigned int size;
- char datbuf[255];
-@@ -64,11 +64,17 @@
-
- offset = atoi(argv[2]) * 6;
- lseek(idxfd, offset, SEEK_SET);
-- read(idxfd, &offset, 4);
-- read(idxfd, &size, 2);
-+ r = read(idxfd, &offset, 4);
-+ if (r != 4)
-+ perror("ERROR: read failed in main");
-+ r = read(idxfd, &size, 2);
-+ if (r != 2)
-+ perror("ERROR: read failed in main");
- printf("offset: %ld; size: %d\n", offset, size);
- lseek(datfd, offset, SEEK_SET);
-- read(datfd, datbuf, 40);
-+ r = read(datfd, datbuf, 40);
-+ if (r != 40)
-+ perror("ERROR: read failed in main");
- datbuf[40] = 0;
- printf("%s\n", datbuf);
- close(datfd);