Bug 1079672 - Fix -Wpointer-arith warning in GonkAudioDecoderManager.cpp. r=cpearce
authorChris Peterson <cpeterson@mozilla.com>
Sat, 04 Oct 2014 23:18:43 -0700
changeset 209515 9efe56741acfcbc7cc13df4f63c090f1ab847571
parent 209514 7fce65c28e7cc2a899e2043e233b81c0e83526e9
child 209516 2fcc35b3ff891ef66740c253979f57f4b0b3e2f2
push id50196
push usercpeterson@mozilla.com
push dateThu, 09 Oct 2014 03:08:38 +0000
treeherdermozilla-inbound@9efe56741acf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1079672
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1079672 - Fix -Wpointer-arith warning in GonkAudioDecoderManager.cpp. r=cpearce
configure.in
content/media/fmp4/gonk/GonkAudioDecoderManager.cpp
--- a/configure.in
+++ b/configure.in
@@ -1525,25 +1525,25 @@ if test "$GNU_CXX"; then
     # -Wtrigraphs - catches unlikely use of trigraphs
     # -Wtype-limits - catches overflow bugs, few false positives
     # -Wunused-label - catches unused goto labels
     # -Wwrite-strings - catches non-const char* pointers to string literals
     #
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall"
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wempty-body"
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Woverloaded-virtual"
-    _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wpointer-arith"
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wsign-compare"
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wwrite-strings"
 
     # Treat some warnings as errors:
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=endif-labels"
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=int-to-pointer-cast"
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=missing-braces"
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=parentheses"
+    _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=pointer-arith"
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=sequence-point"
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=unused-label"
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=trigraphs"
     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=type-limits"
 
     # Turn off the following warnings that -Wall turns on:
     # -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
--- a/content/media/fmp4/gonk/GonkAudioDecoderManager.cpp
+++ b/content/media/fmp4/gonk/GonkAudioDecoderManager.cpp
@@ -89,43 +89,38 @@ GonkAudioDecoderManager::Init(MediaDataD
   } else {
     ALOG("Failed to input codec specific data!");
     return nullptr;
   }
 }
 
 nsresult
 GonkAudioDecoderManager::CreateAudioData(int64_t aStreamOffset, AudioData **v) {
-
-  void *data;
-  size_t dataOffset;
-  size_t size;
-  int64_t timeUs;
-
   if (!(mAudioBuffer != nullptr && mAudioBuffer->data() != nullptr)) {
     ALOG("Audio Buffer is not valid!");
     return NS_ERROR_UNEXPECTED;
   }
 
+  int64_t timeUs;
   if (!mAudioBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) {
     return NS_ERROR_UNEXPECTED;
   }
 
   if (mAudioBuffer->range_length() == 0) {
     // Some decoders may return spurious empty buffers that we just want to ignore
     // quoted from Android's AwesomePlayer.cpp
     ReleaseAudioBuffer();
     return NS_ERROR_NOT_AVAILABLE;
   }
 
-  data = mAudioBuffer->data();
-  dataOffset = mAudioBuffer->range_offset();
-  size = mAudioBuffer->range_length();
+  const uint8_t *data = static_cast<const uint8_t*>(mAudioBuffer->data());
+  size_t dataOffset = mAudioBuffer->range_offset();
+  size_t size = mAudioBuffer->range_length();
 
-  nsAutoArrayPtr<AudioDataValue> buffer(new AudioDataValue[size/2] );
+  nsAutoArrayPtr<AudioDataValue> buffer(new AudioDataValue[size/2]);
   memcpy(buffer.get(), data+dataOffset, size);
   uint32_t frames = size / (2 * mAudioChannels);
 
   CheckedInt64 duration = FramesToUsecs(frames, mAudioRate);
   if (!duration.isValid()) {
     return NS_ERROR_UNEXPECTED;
   }
   *v = new AudioData(aStreamOffset,
@@ -148,17 +143,17 @@ GonkAudioDecoderManager::Output(int64_t 
   err = mDecoder->Output(&mAudioBuffer, READ_OUTPUT_BUFFER_TIMEOUT_US);
 
   switch (err) {
     case OK:
     {
       AudioData* data = nullptr;
       nsresult rv = CreateAudioData(aStreamOffset, &data);
       if (rv == NS_ERROR_NOT_AVAILABLE) {
-	// Decoder outputs a empty video buffer, try again
+        // Decoder outputs an empty video buffer, try again
         return NS_ERROR_NOT_AVAILABLE;
       } else if (rv != NS_OK || data == nullptr) {
         return NS_ERROR_UNEXPECTED;
       }
       aOutData = data;
       return NS_OK;
     }
     case android::INFO_FORMAT_CHANGED: