Bug 1406687 Pass return values from fwrite to Unused to silence the warn-unused-result warning r=njn

MozReview-Commit-ID: 4v6tPF5aMz7

--HG--
extra : rebase_source : fe434db73a8da686391462c12b91648348abcdc9
This commit is contained in:
Tom Ritter 2017-10-09 15:01:48 -05:00
parent fdab21a20a
commit 701ee70a22
7 changed files with 18 additions and 9 deletions

View File

@ -13,6 +13,7 @@
#include "mozilla/Monitor.h" #include "mozilla/Monitor.h"
#include "mozilla/Mutex.h" #include "mozilla/Mutex.h"
#include "mozilla/Sprintf.h" #include "mozilla/Sprintf.h"
#include "mozilla/Unused.h"
#include <algorithm> #include <algorithm>
#include "mozilla/Telemetry.h" #include "mozilla/Telemetry.h"
#include "CubebUtils.h" #include "CubebUtils.h"
@ -279,7 +280,7 @@ OpenDumpFile(uint32_t aChannels, uint32_t aRate)
SetUint16LE(header + CHANNEL_OFFSET, aChannels); SetUint16LE(header + CHANNEL_OFFSET, aChannels);
SetUint32LE(header + SAMPLE_RATE_OFFSET, aRate); SetUint32LE(header + SAMPLE_RATE_OFFSET, aRate);
SetUint16LE(header + BLOCK_ALIGN_OFFSET, aChannels * 2); SetUint16LE(header + BLOCK_ALIGN_OFFSET, aChannels * 2);
fwrite(header, sizeof(header), 1, f); Unused << fwrite(header, sizeof(header), 1, f);
return f; return f;
} }
@ -287,7 +288,7 @@ OpenDumpFile(uint32_t aChannels, uint32_t aRate)
template <typename T> template <typename T>
typename EnableIf<IsSame<T, int16_t>::value, void>::Type typename EnableIf<IsSame<T, int16_t>::value, void>::Type
WriteDumpFileHelper(T* aInput, size_t aSamples, FILE* aFile) { WriteDumpFileHelper(T* aInput, size_t aSamples, FILE* aFile) {
fwrite(aInput, sizeof(T), aSamples, aFile); Unused << fwrite(aInput, sizeof(T), aSamples, aFile);
} }
template <typename T> template <typename T>
@ -299,7 +300,7 @@ WriteDumpFileHelper(T* aInput, size_t aSamples, FILE* aFile) {
for (uint32_t i = 0; i < aSamples; ++i) { for (uint32_t i = 0; i < aSamples; ++i) {
SetUint16LE(output + i*2, int16_t(aInput[i]*32767.0f)); SetUint16LE(output + i*2, int16_t(aInput[i]*32767.0f));
} }
fwrite(output, 2, aSamples, aFile); Unused << fwrite(output, 2, aSamples, aFile);
fflush(aFile); fflush(aFile);
} }

View File

@ -11,6 +11,7 @@
#include "mozilla/IntegerPrintfMacros.h" #include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/Logging.h" #include "mozilla/Logging.h"
#include "mozilla/Sprintf.h" #include "mozilla/Sprintf.h"
#include "mozilla/Unused.h"
extern mozilla::LogModule* GetSourceBufferResourceLog(); extern mozilla::LogModule* GetSourceBufferResourceLog();
@ -171,7 +172,7 @@ ResourceQueue::Dump(const char* aPath)
if (!fp) { if (!fp) {
return; return;
} }
fwrite(item->mData->Elements(), item->mData->Length(), 1, fp); Unused << fwrite(item->mData->Elements(), item->mData->Length(), 1, fp);
fclose(fp); fclose(fp);
} }
} }

View File

@ -25,6 +25,7 @@
#include "mozilla/Maybe.h" #include "mozilla/Maybe.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/UniquePtrExtensions.h" #include "mozilla/UniquePtrExtensions.h"
#include "mozilla/Unused.h"
#include "mozilla/Vector.h" #include "mozilla/Vector.h"
#include "nsComponentManagerUtils.h" #include "nsComponentManagerUtils.h"
#include "nsIClipboardHelper.h" #include "nsIClipboardHelper.h"
@ -1048,7 +1049,7 @@ EncodeSourceSurfaceInternal(SourceSurface* aSurface,
if (aBinaryOrData == gfxUtils::eBinaryEncode) { if (aBinaryOrData == gfxUtils::eBinaryEncode) {
if (aFile) { if (aFile) {
fwrite(imgData.begin(), 1, imgSize, aFile); Unused << fwrite(imgData.begin(), 1, imgSize, aFile);
} }
return NS_OK; return NS_OK;
} }

View File

@ -13,6 +13,7 @@ using namespace std;
#include <MediaConduitInterface.h> #include <MediaConduitInterface.h>
#include <VideoConduit.h> #include <VideoConduit.h>
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "mozilla/Unused.h"
#include "nss.h" #include "nss.h"
#include "runnable_utils.h" #include "runnable_utils.h"
#include "signaling/src/common/EncodingConstraints.h" #include "signaling/src/common/EncodingConstraints.h"
@ -224,7 +225,7 @@ void AudioSendAndReceive::GenerateAndReadSamples()
//Create input file with the music //Create input file with the music
WriteWaveHeader(PLAYOUT_SAMPLE_FREQUENCY, 1, inFile); WriteWaveHeader(PLAYOUT_SAMPLE_FREQUENCY, 1, inFile);
GenerateMusic(inbuf, SAMPLES); GenerateMusic(inbuf, SAMPLES);
fwrite(inbuf,1,SAMPLES*sizeof(inbuf[0])*CHANNELS,inFile); mozilla::Unused << fwrite(inbuf,1,SAMPLES*sizeof(inbuf[0])*CHANNELS,inFile);
FinishWaveHeader(inFile); FinishWaveHeader(inFile);
fclose(inFile); fclose(inFile);

View File

@ -34,6 +34,8 @@
#include "pkixder.h" #include "pkixder.h"
#include "pkixutil.h" #include "pkixutil.h"
#include "mozilla/Unused.h"
using namespace std; using namespace std;
namespace mozilla { namespace pkix { namespace test { namespace mozilla { namespace pkix { namespace test {
@ -509,7 +511,7 @@ MaybeLogOutput(const ByteString& result, const char* suffix)
++counter; ++counter;
ScopedFILE file(OpenFile(logPath, filename, "wb")); ScopedFILE file(OpenFile(logPath, filename, "wb"));
if (file) { if (file) {
(void) fwrite(result.data(), result.length(), 1, file.get()); Unused << fwrite(result.data(), result.length(), 1, file.get());
} }
} }
} }

View File

@ -35,6 +35,8 @@
#include "gtest/internal/custom/gtest.h" #include "gtest/internal/custom/gtest.h"
#include "gtest/gtest-spi.h" #include "gtest/gtest-spi.h"
#include "mozilla/Unused.h"
#include <ctype.h> #include <ctype.h>
#include <math.h> #include <math.h>
#include <stdarg.h> #include <stdarg.h>
@ -3866,7 +3868,7 @@ class ScopedPrematureExitFile {
// errors are ignored as there's nothing better we can do and we // errors are ignored as there's nothing better we can do and we
// don't want to fail the test because of this. // don't want to fail the test because of this.
FILE* pfile = posix::FOpen(premature_exit_filepath, "w"); FILE* pfile = posix::FOpen(premature_exit_filepath, "w");
fwrite("0", 1, 1, pfile); mozilla::Unused << fwrite("0", 1, 1, pfile);
fclose(pfile); fclose(pfile);
} }
} }

View File

@ -13,6 +13,7 @@
#include "mozilla/Scoped.h" #include "mozilla/Scoped.h"
#include "mozilla/StaticPtr.h" #include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h" #include "mozilla/Telemetry.h"
#include "mozilla/Unused.h"
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h" #include "nsDirectoryServiceUtils.h"
#include "nsPrintfCString.h" #include "nsPrintfCString.h"
@ -59,7 +60,7 @@ public:
str.AppendPrintf(aFormat, list); str.AppendPrintf(aFormat, list);
va_end(list); va_end(list);
mSHA1.update(str.get(), str.Length()); mSHA1.update(str.get(), str.Length());
fwrite(str.get(), 1, str.Length(), mFile); Unused << fwrite(str.get(), 1, str.Length(), mFile);
} }
void Finish(SHA1Sum::Hash& aHash) void Finish(SHA1Sum::Hash& aHash)
{ {