Bug 1406687 Pass return values from fwrite to Unused to silence the warn-unused-result warning r=njn
☠☠ backed out by ffccd2307ac1 ☠ ☠
authorTom Ritter <tom@mozilla.com>
Mon, 09 Oct 2017 00:26:16 -0500
changeset 427794 0317bcff40bc7f1e73422c4b6f8f22bd73b981ba
parent 427793 b226a2f626e2cc597d55bc9539313a3e28c2dea4
child 427795 118b67c940dc554a4adf6fb397db775861962c68
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersnjn
bugs1406687
milestone58.0a1
Bug 1406687 Pass return values from fwrite to Unused to silence the warn-unused-result warning r=njn MozReview-Commit-ID: 4v6tPF5aMz7
dom/media/AudioStream.cpp
dom/media/mediasource/ResourceQueue.cpp
gfx/thebes/gfxUtils.cpp
media/webrtc/signaling/gtest/mediaconduit_unittests.cpp
security/pkix/test/lib/pkixtestutil.cpp
testing/gtest/gtest/src/gtest.cc
xpcom/build/LateWriteChecks.cpp
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -8,16 +8,17 @@
 #include <string.h>
 #include "mozilla/Logging.h"
 #include "prdtoa.h"
 #include "AudioStream.h"
 #include "VideoUtils.h"
 #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"
 #include "nsPrintfCString.h"
 #include "gfxPrefs.h"
 #include "AudioConverter.h"
 #if defined(XP_WIN)
 #include "nsXULAppAPI.h"
@@ -272,37 +273,37 @@ OpenDumpFile(uint32_t aChannels, uint32_
     0x64, 0x61, 0x74, 0x61, 0xFE, 0xFF, 0xFF, 0x7F
   };
   static const int CHANNEL_OFFSET = 22;
   static const int SAMPLE_RATE_OFFSET = 24;
   static const int BLOCK_ALIGN_OFFSET = 32;
   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>
 typename EnableIf<IsSame<T, float>::value, void>::Type
 WriteDumpFileHelper(T* aInput, size_t aSamples, FILE* aFile) {
   AutoTArray<uint8_t, 1024*2> buf;
   buf.SetLength(aSamples*2);
   uint8_t* output = buf.Elements();
   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);
 }
 
 static void
 WriteDumpFile(FILE* aDumpFile, AudioStream* aStream, uint32_t aFrames,
               void* aBuffer)
 {
   if (!aDumpFile)
--- a/dom/media/mediasource/ResourceQueue.cpp
+++ b/dom/media/mediasource/ResourceQueue.cpp
@@ -6,16 +6,17 @@
 
 #include "ResourceQueue.h"
 #include "nsDeque.h"
 #include "MediaData.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Sprintf.h"
+#include "mozilla/Unused.h"
 
 extern mozilla::LogModule* GetSourceBufferResourceLog();
 
 #define SBR_DEBUG(arg, ...) MOZ_LOG(GetSourceBufferResourceLog(), mozilla::LogLevel::Debug, ("ResourceQueue(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 #define SBR_DEBUGV(arg, ...) MOZ_LOG(GetSourceBufferResourceLog(), mozilla::LogLevel::Verbose, ("ResourceQueue(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 
 namespace mozilla {
 
@@ -166,17 +167,17 @@ ResourceQueue::Dump(const char* aPath)
     ResourceItem* item = ResourceAt(i);
 
     char buf[255];
     SprintfLiteral(buf, "%s/%08u.bin", aPath, i);
     FILE* fp = fopen(buf, "wb");
     if (!fp) {
       return;
     }
-    fwrite(item->mData->Elements(), item->mData->Length(), 1, fp);
+    Unused << fwrite(item->mData->Elements(), item->mData->Length(), 1, fp);
     fclose(fp);
   }
 }
 #endif
 
 ResourceItem*
 ResourceQueue::ResourceAt(uint32_t aIndex) const
 {
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -20,16 +20,17 @@
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/DataSurfaceHelpers.h"
 #include "mozilla/gfx/Logging.h"
 #include "mozilla/gfx/PathHelpers.h"
 #include "mozilla/gfx/Swizzle.h"
 #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"
 #include "nsIFile.h"
 #include "nsIGfxInfo.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsRegion.h"
@@ -1043,17 +1044,17 @@ EncodeSourceSurfaceInternal(SourceSurfac
       }
     }
   }
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(!imgData.empty(), NS_ERROR_FAILURE);
 
   if (aBinaryOrData == gfxUtils::eBinaryEncode) {
     if (aFile) {
-      fwrite(imgData.begin(), 1, imgSize, aFile);
+      Unused << fwrite(imgData.begin(), 1, imgSize, aFile);
     }
     return NS_OK;
   }
 
   // base 64, result will be null-terminated
   nsCString encodedImg;
   rv = Base64Encode(Substring(imgData.begin(), imgSize), encodedImg);
   NS_ENSURE_SUCCESS(rv, rv);
old mode 100644
new mode 100755
--- a/media/webrtc/signaling/gtest/mediaconduit_unittests.cpp
+++ b/media/webrtc/signaling/gtest/mediaconduit_unittests.cpp
@@ -8,16 +8,17 @@
 #include <vector>
 #include <math.h>
 
 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"
 
 #define GTEST_HAS_RTTI 0
 #include "gtest/gtest.h"
 
 const uint32_t SSRC = 1;
@@ -219,17 +220,17 @@ void AudioSendAndReceive::GenerateAndRea
      free(inbuf);
      fclose(inFile);
      return;
    }
 
    //Create input file with the music
    WriteWaveHeader(PLAYOUT_SAMPLE_FREQUENCY, 1, inFile);
    GenerateMusic(inbuf, SAMPLES);
-   fwrite(inbuf,1,SAMPLES*sizeof(inbuf[0])*CHANNELS,inFile);
+   Unused << fwrite(inbuf,1,SAMPLES*sizeof(inbuf[0])*CHANNELS,inFile);
    FinishWaveHeader(inFile);
    fclose(inFile);
 
    WriteWaveHeader(PLAYOUT_SAMPLE_FREQUENCY, 1, outFile);
    unsigned int numSamplesReadFromInput = 0;
    do
    {
     if(!memcpy(audioInput.get(), inbuf, sampleLengthInBytes))
--- a/security/pkix/test/lib/pkixtestutil.cpp
+++ b/security/pkix/test/lib/pkixtestutil.cpp
@@ -29,16 +29,18 @@
 #include <limits>
 #include <new>
 #include <sstream>
 #include <cstdlib>
 
 #include "pkixder.h"
 #include "pkixutil.h"
 
+#include "mozilla/Unused.h"
+
 using namespace std;
 
 namespace mozilla { namespace pkix { namespace test {
 
 namespace {
 
 inline void
 fclose_void(FILE* file) {
@@ -504,17 +506,17 @@ MaybeLogOutput(const ByteString& result,
       assert(false);
       return;
     }
     string filename = counterStream.str() + '-' + suffix + ".der";
 
     ++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());
     }
   }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 // Certificates
 
 static ByteString TBSCertificate(long version, const ByteString& serialNumber,
old mode 100644
new mode 100755
--- a/testing/gtest/gtest/src/gtest.cc
+++ b/testing/gtest/gtest/src/gtest.cc
@@ -30,16 +30,18 @@
 // Author: wan@google.com (Zhanyong Wan)
 //
 // The Google C++ Testing Framework (Google Test)
 
 #include "gtest/gtest.h"
 #include "gtest/internal/custom/gtest.h"
 #include "gtest/gtest-spi.h"
 
+#include "mozilla/Unused.h"
+
 #include <ctype.h>
 #include <math.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 #include <wchar.h>
 #include <wctype.h>
@@ -3861,17 +3863,17 @@ class ScopedPrematureExitFile {
   explicit ScopedPrematureExitFile(const char* premature_exit_filepath)
       : premature_exit_filepath_(premature_exit_filepath) {
     // If a path to the premature-exit file is specified...
     if (premature_exit_filepath != NULL && *premature_exit_filepath != '\0') {
       // create the file with a single "0" character in it.  I/O
       // 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);
+      Unused << fwrite("0", 1, 1, pfile);
       fclose(pfile);
     }
   }
 
   ~ScopedPrematureExitFile() {
     if (premature_exit_filepath_ != NULL && *premature_exit_filepath_ != '\0') {
       remove(premature_exit_filepath_);
     }
--- a/xpcom/build/LateWriteChecks.cpp
+++ b/xpcom/build/LateWriteChecks.cpp
@@ -8,16 +8,17 @@
 
 #include "mozilla/IOInterposer.h"
 #include "mozilla/PoisonIOInterposer.h"
 #include "mozilla/ProcessedStack.h"
 #include "mozilla/SHA1.h"
 #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"
 #include "mozilla/StackWalk.h"
 #include "plstr.h"
 #include "prio.h"
 
 #ifdef XP_WIN
@@ -54,17 +55,17 @@ public:
   {
     MOZ_ASSERT(mFile);
     va_list list;
     va_start(list, aFormat);
     nsAutoCString str;
     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)
   {
     int fd = fileno(mFile);
     fflush(mFile);
     MozillaUnRegisterDebugFD(fd);
     fclose(mFile);
     mSHA1.finish(aHash);