Skip to content

Commit

Permalink
Bug 1406687 Pass return values from fwrite to Unused to silence the w…
Browse files Browse the repository at this point in the history
…arn-unused-result warning r=njn

MozReview-Commit-ID: 4v6tPF5aMz7

--HG--
extra : rebase_source : fe434db73a8da686391462c12b91648348abcdc9
  • Loading branch information
tomrittervg committed Oct 9, 2017
1 parent fdab21a commit 701ee70
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
7 changes: 4 additions & 3 deletions dom/media/AudioStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "mozilla/Monitor.h"
#include "mozilla/Mutex.h"
#include "mozilla/Sprintf.h"
#include "mozilla/Unused.h"
#include <algorithm>
#include "mozilla/Telemetry.h"
#include "CubebUtils.h"
Expand Down Expand Up @@ -279,15 +280,15 @@ OpenDumpFile(uint32_t aChannels, uint32_t aRate)
SetUint16LE(header + CHANNEL_OFFSET, aChannels);
SetUint32LE(header + SAMPLE_RATE_OFFSET, aRate);
SetUint16LE(header + BLOCK_ALIGN_OFFSET, aChannels * 2);
fwrite(header, sizeof(header), 1, f);
Unused << fwrite(header, sizeof(header), 1, f);

return f;
}

template <typename T>
typename EnableIf<IsSame<T, int16_t>::value, void>::Type
WriteDumpFileHelper(T* aInput, size_t aSamples, FILE* aFile) {
fwrite(aInput, sizeof(T), aSamples, aFile);
Unused << fwrite(aInput, sizeof(T), aSamples, aFile);
}

template <typename T>
Expand All @@ -299,7 +300,7 @@ WriteDumpFileHelper(T* aInput, size_t aSamples, FILE* aFile) {
for (uint32_t i = 0; i < aSamples; ++i) {
SetUint16LE(output + i*2, int16_t(aInput[i]*32767.0f));
}
fwrite(output, 2, aSamples, aFile);
Unused << fwrite(output, 2, aSamples, aFile);
fflush(aFile);
}

Expand Down
3 changes: 2 additions & 1 deletion dom/media/mediasource/ResourceQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/Logging.h"
#include "mozilla/Sprintf.h"
#include "mozilla/Unused.h"

extern mozilla::LogModule* GetSourceBufferResourceLog();

Expand Down Expand Up @@ -171,7 +172,7 @@ ResourceQueue::Dump(const char* aPath)
if (!fp) {
return;
}
fwrite(item->mData->Elements(), item->mData->Length(), 1, fp);
Unused << fwrite(item->mData->Elements(), item->mData->Length(), 1, fp);
fclose(fp);
}
}
Expand Down
3 changes: 2 additions & 1 deletion gfx/thebes/gfxUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "mozilla/Maybe.h"
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtrExtensions.h"
#include "mozilla/Unused.h"
#include "mozilla/Vector.h"
#include "nsComponentManagerUtils.h"
#include "nsIClipboardHelper.h"
Expand Down Expand Up @@ -1048,7 +1049,7 @@ EncodeSourceSurfaceInternal(SourceSurface* aSurface,

if (aBinaryOrData == gfxUtils::eBinaryEncode) {
if (aFile) {
fwrite(imgData.begin(), 1, imgSize, aFile);
Unused << fwrite(imgData.begin(), 1, imgSize, aFile);
}
return NS_OK;
}
Expand Down
3 changes: 2 additions & 1 deletion media/webrtc/signaling/gtest/mediaconduit_unittests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using namespace std;
#include <MediaConduitInterface.h>
#include <VideoConduit.h>
#include "mozilla/UniquePtr.h"
#include "mozilla/Unused.h"
#include "nss.h"
#include "runnable_utils.h"
#include "signaling/src/common/EncodingConstraints.h"
Expand Down Expand Up @@ -224,7 +225,7 @@ void AudioSendAndReceive::GenerateAndReadSamples()
//Create input file with the music
WriteWaveHeader(PLAYOUT_SAMPLE_FREQUENCY, 1, inFile);
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);
fclose(inFile);

Expand Down
4 changes: 3 additions & 1 deletion security/pkix/test/lib/pkixtestutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "pkixder.h"
#include "pkixutil.h"

#include "mozilla/Unused.h"

using namespace std;

namespace mozilla { namespace pkix { namespace test {
Expand Down Expand Up @@ -509,7 +511,7 @@ MaybeLogOutput(const ByteString& result, const char* suffix)
++counter;
ScopedFILE file(OpenFile(logPath, filename, "wb"));
if (file) {
(void) fwrite(result.data(), result.length(), 1, file.get());
Unused << fwrite(result.data(), result.length(), 1, file.get());
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion testing/gtest/gtest/src/gtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "gtest/internal/custom/gtest.h"
#include "gtest/gtest-spi.h"

#include "mozilla/Unused.h"

#include <ctype.h>
#include <math.h>
#include <stdarg.h>
Expand Down Expand Up @@ -3866,7 +3868,7 @@ class ScopedPrematureExitFile {
// errors are ignored as there's nothing better we can do and we
// don't want to fail the test because of this.
FILE* pfile = posix::FOpen(premature_exit_filepath, "w");
fwrite("0", 1, 1, pfile);
mozilla::Unused << fwrite("0", 1, 1, pfile);
fclose(pfile);
}
}
Expand Down
3 changes: 2 additions & 1 deletion xpcom/build/LateWriteChecks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "mozilla/Scoped.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h"
#include "mozilla/Unused.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsPrintfCString.h"
Expand Down Expand Up @@ -59,7 +60,7 @@ class SHA1Stream
str.AppendPrintf(aFormat, list);
va_end(list);
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)
{
Expand Down

0 comments on commit 701ee70

Please sign in to comment.