diff --git a/config/elf-dynstr-gc.c b/config/elf-dynstr-gc.c index f9a8008bd3a9..a140a22318bb 100644 --- a/config/elf-dynstr-gc.c +++ b/config/elf-dynstr-gc.c @@ -1234,10 +1234,10 @@ main(int argc, char *argv[]) munmap(mapping, size); - ftruncate(fd, size - hole_len); + int result = ftruncate(fd, size - hole_len); close(fd); - return 0; + return result == -1 ? 1 : 0; } diff --git a/dom/plugins/test/testplugin/nptest.cpp b/dom/plugins/test/testplugin/nptest.cpp index e0698a81c36d..24611c685f14 100644 --- a/dom/plugins/test/testplugin/nptest.cpp +++ b/dom/plugins/test/testplugin/nptest.cpp @@ -1354,12 +1354,12 @@ NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname) FILE *file = fopen(fname, "rb"); if (file) { - fseek(file, 0, SEEK_END); + ssize_t unused = fseek(file, 0, SEEK_END); size = ftell(file); instanceData->fileBuf = malloc((int32_t)size + 1); char* buf = reinterpret_cast(instanceData->fileBuf); - fseek(file, 0, SEEK_SET); - fread(instanceData->fileBuf, 1, size, file); + unused = fseek(file, 0, SEEK_SET); + unused = fread(instanceData->fileBuf, 1, size, file); fclose(file); buf[size] = '\0'; instanceData->fileBufSize = (int32_t)size; diff --git a/memory/jemalloc/jemalloc.c b/memory/jemalloc/jemalloc.c index 6a0b4d233ce8..da86e0a9f897 100644 --- a/memory/jemalloc/jemalloc.c +++ b/memory/jemalloc/jemalloc.c @@ -1527,10 +1527,11 @@ wrtmessage(const char *p1, const char *p2, const char *p3, const char *p4) #if defined(MOZ_MEMORY) && !defined(MOZ_MEMORY_WINDOWS) #define _write write #endif - _write(STDERR_FILENO, p1, (unsigned int) strlen(p1)); - _write(STDERR_FILENO, p2, (unsigned int) strlen(p2)); - _write(STDERR_FILENO, p3, (unsigned int) strlen(p3)); - _write(STDERR_FILENO, p4, (unsigned int) strlen(p4)); + int res; + res = _write(STDERR_FILENO, p1, (unsigned int) strlen(p1)); + res = _write(STDERR_FILENO, p2, (unsigned int) strlen(p2)); + res = _write(STDERR_FILENO, p3, (unsigned int) strlen(p3)); + res = _write(STDERR_FILENO, p4, (unsigned int) strlen(p4)); } #define _malloc_message malloc_message diff --git a/modules/libmar/tool/mar.c b/modules/libmar/tool/mar.c index ce83178a1ddc..c34ef69a2c10 100644 --- a/modules/libmar/tool/mar.c +++ b/modules/libmar/tool/mar.c @@ -126,7 +126,9 @@ int main(int argc, char **argv) { break; /* -C workingdirectory */ } else if (argv[1][0] == '-' && argv[1][1] == 'C') { - chdir(argv[2]); + int res = chdir(argv[2]); + if (res == -1) + return -1; argv += 2; argc -= 2; } diff --git a/netwerk/test/TestProtocols.cpp b/netwerk/test/TestProtocols.cpp index 6dd817101036..97fba3581ea1 100644 --- a/netwerk/test/TestProtocols.cpp +++ b/netwerk/test/TestProtocols.cpp @@ -88,6 +88,10 @@ #include "prlog.h" #include "prtime.h" +#include "mozilla/unused.h" + +using mozilla::unused; + namespace TestProtocols { #if defined(PR_LOGGING) @@ -338,7 +342,7 @@ TestAuthPrompt::PromptUsernameAndPassword(const PRUnichar *dialogTitle, int n; printf("Enter username: "); - fgets(buf, sizeof(buf), stdin); + unused << fgets(buf, sizeof(buf), stdin); n = strlen(buf); buf[n-1] = '\0'; // trim trailing newline *user = NS_StringCloneData(NS_ConvertUTF8toUTF16(buf)); @@ -824,7 +828,7 @@ nsresult LoadURLFromConsole() { char buffer[1024]; printf("Enter URL (\"q\" to start): "); - scanf("%s", buffer); + unused << scanf("%s", buffer); if (buffer[0]=='q') gAskUserForInput = false; else diff --git a/testing/mochitest/ssltunnel/ssltunnel.cpp b/testing/mochitest/ssltunnel/ssltunnel.cpp index baa614ada1bb..ec910c7032ce 100644 --- a/testing/mochitest/ssltunnel/ssltunnel.cpp +++ b/testing/mochitest/ssltunnel/ssltunnel.cpp @@ -66,9 +66,11 @@ #include "keyt.h" #include "ssl.h" #include "plhash.h" +#include "mozilla/unused.h" using std::string; using std::vector; +using mozilla::unused; #define IS_DELIM(m, c) ((m)[(c) >> 3] & (1 << ((c) & 7))) #define SET_DELIM(m, c) ((m)[(c) >> 3] |= (1 << ((c) & 7))) @@ -1264,7 +1266,7 @@ int parseConfigFile(const char* filePath) while (!feof(f)) { char c; - fscanf(f, "%c", &c); + unused << fscanf(f, "%c", &c); switch (c) { case '\n': diff --git a/toolkit/xre/glxtest.cpp b/toolkit/xre/glxtest.cpp index 3d228cb8485f..acdd6202e8f1 100644 --- a/toolkit/xre/glxtest.cpp +++ b/toolkit/xre/glxtest.cpp @@ -65,6 +65,10 @@ #include #endif +#include "mozilla/unused.h" + +using mozilla::unused; + namespace mozilla { namespace widget { // the read end of the pipe, which will be used by GfxInfo @@ -90,8 +94,8 @@ static func_ptr_type cast(void *ptr) static void fatal_error(const char *str) { - write(write_end_of_the_pipe, str, strlen(str)); - write(write_end_of_the_pipe, "\n", 1); + unused << write(write_end_of_the_pipe, str, strlen(str)); + unused << write(write_end_of_the_pipe, "\n", 1); exit(EXIT_FAILURE); } @@ -105,7 +109,7 @@ x_error_handler(Display *, XErrorEvent *ev) ev->error_code, ev->request_code, ev->minor_code); - write(write_end_of_the_pipe, buf, length); + unused << write(write_end_of_the_pipe, buf, length); exit(EXIT_FAILURE); return 0; } @@ -253,7 +257,7 @@ static void glxtest() dlclose(libgl); ///// Finally write data to the pipe - write(write_end_of_the_pipe, buf, length); + unused << write(write_end_of_the_pipe, buf, length); } /** \returns true in the child glxtest process, false in the parent process */ diff --git a/widget/gtk2/nsAppShell.cpp b/widget/gtk2/nsAppShell.cpp index dadf22bdfb85..1c371271564f 100644 --- a/widget/gtk2/nsAppShell.cpp +++ b/widget/gtk2/nsAppShell.cpp @@ -46,6 +46,9 @@ #include "prlog.h" #include "prenv.h" #include "mozilla/HangMonitor.h" +#include "mozilla/unused.h" + +using mozilla::unused; #define NOTIFY_TOKEN 0xFA @@ -76,7 +79,7 @@ nsAppShell::EventProcessorCallback(GIOChannel *source, nsAppShell *self = static_cast(data); unsigned char c; - read(self->mPipeFDs[0], &c, 1); + ssize_t ununsed = read(self->mPipeFDs[0], &c, 1); NS_ASSERTION(c == (unsigned char) NOTIFY_TOKEN, "wrong token"); self->NativeEventCallback(); @@ -153,7 +156,7 @@ void nsAppShell::ScheduleNativeEventCallback() { unsigned char buf[] = { NOTIFY_TOKEN }; - write(mPipeFDs[1], buf, 1); + unused << write(mPipeFDs[1], buf, 1); } bool diff --git a/xpcom/base/MapsMemoryReporter.cpp b/xpcom/base/MapsMemoryReporter.cpp index 93d047a0310d..103ec147c0a7 100644 --- a/xpcom/base/MapsMemoryReporter.cpp +++ b/xpcom/base/MapsMemoryReporter.cpp @@ -46,6 +46,9 @@ #include "nsTHashtable.h" #include "nsHashKeys.h" #include +#include "mozilla/unused.h" + +using mozilla::unused; namespace mozilla { namespace MapsMemoryReporter { @@ -339,7 +342,7 @@ MapsReporter::ParseMapping( devMinor, &inode, path); // Eat up any whitespace at the end of this line, including the newline. - fscanf(aFile, " "); + unused << fscanf(aFile, " "); // We might or might not have a path, but the rest of the arguments should be // there. diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index a4b26664c958..c867e1d6d3d0 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -1366,7 +1366,9 @@ public: // Therefore we need to call the APIs directly. GetTempPathA(mozilla::ArrayLength(basename), basename); #else - tmpnam(basename); + char *tmp = tmpnam(basename); + if (!tmp) + return NS_ERROR_FAILURE; char *lastSlash = strrchr(basename, XPCOM_FILE_PATH_SEPARATOR[0]); if (lastSlash) { *lastSlash = '\0'; diff --git a/xpcom/threads/nsThread.cpp b/xpcom/threads/nsThread.cpp index dfeb7f4afa14..902295d21ee0 100644 --- a/xpcom/threads/nsThread.cpp +++ b/xpcom/threads/nsThread.cpp @@ -47,6 +47,7 @@ #include "nsIObserverService.h" #include "mozilla/HangMonitor.h" #include "mozilla/Services.h" +#include "mozilla/unused.h" #define HAVE_UALARM _BSD_SOURCE || (_XOPEN_SOURCE >= 500 || \ _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \ @@ -72,6 +73,7 @@ #endif using namespace mozilla; +using mozilla::unused; #ifdef PR_LOGGING static PRLogModuleInfo *sLog = PR_NewLogModule("nsThread"); @@ -568,7 +570,7 @@ void canary_alarm_handler (int signum) void *array[30]; const char msg[29] = "event took too long to run:\n"; // use write to be safe in the signal handler - write(Canary::sOutputFD, msg, sizeof(msg)); + unused << write(Canary::sOutputFD, msg, sizeof(msg)); backtrace_symbols_fd(array, backtrace(array, 30), Canary::sOutputFD); }