Bug 1345609 - add -Werror=format to libstagefright; r?gerald draft
authorTom Tromey <tom@tromey.com>
Wed, 08 Mar 2017 14:43:22 -0700
changeset 496800 665f2cb7b09bbddf24a2c64f90efa7ec52ba5535
parent 496794 1054561cc24575ba69867086a317036715d1f96e
child 548704 9dbb7ac1ae401dc30d931e3a487fd52dc4867e12
push id48697
push userbmo:ttromey@mozilla.com
push dateFri, 10 Mar 2017 18:15:36 +0000
reviewersgerald
bugs1345609
milestone55.0a1
Bug 1345609 - add -Werror=format to libstagefright; r?gerald MozReview-Commit-ID: 8JCRDusR4Dg
media/libstagefright/binding/MoofParser.cpp
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
media/libstagefright/frameworks/av/media/libstagefright/MetaData.cpp
media/libstagefright/moz.build
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -648,17 +648,17 @@ Tkhd::Tkhd(Box& aBox)
     LOG(Tkhd, "Incomplete Box (missing flags)");
     return;
   }
   uint32_t flags = reader->ReadU32();
   uint8_t version = flags >> 24;
   size_t need =
     3*(version ? sizeof(int64_t) : sizeof(int32_t)) + 2*sizeof(int32_t);
   if (reader->Remaining() < need) {
-    LOG(Tkhd, "Incomplete Box (have:%lld need:%lld)",
+    LOG(Tkhd, "Incomplete Box (have:%" PRIu64 " need:%" PRIu64 ")",
         (uint64_t)reader->Remaining(), (uint64_t)need);
     return;
   }
   if (version == 0) {
     mCreationTime = reader->ReadU32();
     mModificationTime = reader->ReadU32();
     mTrackId = reader->ReadU32();
     uint32_t reserved = reader->ReadU32();
@@ -683,17 +683,17 @@ Mvhd::Mvhd(Box& aBox)
     LOG(Mdhd, "Incomplete Box (missing flags)");
     return;
   }
   uint32_t flags = reader->ReadU32();
   uint8_t version = flags >> 24;
   size_t need =
     3*(version ? sizeof(int64_t) : sizeof(int32_t)) + sizeof(uint32_t);
   if (reader->Remaining() < need) {
-    LOG(Mvhd, "Incomplete Box (have:%lld need:%lld)",
+    LOG(Mvhd, "Incomplete Box (have:%" PRIu64 " need:%" PRIu64 ")",
         (uint64_t)reader->Remaining(), (uint64_t)need);
     return;
   }
 
   if (version == 0) {
     mCreationTime = reader->ReadU32();
     mModificationTime = reader->ReadU32();
     mTimescale = reader->ReadU32();
@@ -716,17 +716,17 @@ Mdhd::Mdhd(Box& aBox)
   : Mvhd(aBox)
 {
 }
 
 Trex::Trex(Box& aBox)
 {
   BoxReader reader(aBox);
   if (reader->Remaining() < 6*sizeof(uint32_t)) {
-    LOG(Trex, "Incomplete Box (have:%lld need:%lld)",
+    LOG(Trex, "Incomplete Box (have:%" PRIu64 " need:%" PRIu64 ")",
         (uint64_t)reader->Remaining(), (uint64_t)6*sizeof(uint32_t));
     return;
   }
   mFlags = reader->ReadU32();
   mTrackId = reader->ReadU32();
   mDefaultSampleDescriptionIndex = reader->ReadU32();
   mDefaultSampleDuration = reader->ReadU32();
   mDefaultSampleSize = reader->ReadU32();
@@ -751,17 +751,17 @@ Tfhd::Tfhd(Box& aBox, Trex& aTrex)
   uint8_t flag[] = { 1, 2, 8, 0x10, 0x20, 0 };
   uint8_t flagSize[] = { sizeof(uint64_t), sizeof(uint32_t), sizeof(uint32_t), sizeof(uint32_t), sizeof(uint32_t) };
   for (size_t i = 0; flag[i]; i++) {
     if (mFlags & flag[i]) {
       need += flagSize[i];
     }
   }
   if (reader->Remaining() < need) {
-    LOG(Tfhd, "Incomplete Box (have:%lld need:%lld)",
+    LOG(Tfhd, "Incomplete Box (have:%" PRIu64 " need:%" PRIu64 ")",
         (uint64_t)reader->Remaining(), (uint64_t)need);
     return;
   }
   mTrackId = reader->ReadU32();
   mBaseDataOffset =
     mFlags & 1 ? reader->ReadU64() : aBox.Parent()->Parent()->Offset();
   if (mFlags & 2) {
     mDefaultSampleDescriptionIndex = reader->ReadU32();
@@ -784,17 +784,17 @@ Tfdt::Tfdt(Box& aBox)
   if (!reader->CanReadType<uint32_t>()) {
     LOG(Tfdt, "Incomplete Box (missing flags)");
     return;
   }
   uint32_t flags = reader->ReadU32();
   uint8_t version = flags >> 24;
   size_t need = version ? sizeof(uint64_t) : sizeof(uint32_t) ;
   if (reader->Remaining() < need) {
-    LOG(Tfdt, "Incomplete Box (have:%lld need:%lld)",
+    LOG(Tfdt, "Incomplete Box (have:%" PRIu64 " need:%" PRIu64 ")",
         (uint64_t)reader->Remaining(), (uint64_t)need);
     return;
   }
   if (version == 0) {
     mBaseMediaDecodeTime = reader->ReadU32();
   } else if (version == 1) {
     mBaseMediaDecodeTime = reader->ReadU64();
   }
@@ -815,17 +815,17 @@ Edts::Edts(Box& aBox)
     LOG(Edts, "Incomplete Box (missing flags)");
     return;
   }
   uint32_t flags = reader->ReadU32();
   uint8_t version = flags >> 24;
   size_t need =
     sizeof(uint32_t) + 2*(version ? sizeof(int64_t) : sizeof(uint32_t));
   if (reader->Remaining() < need) {
-    LOG(Edts, "Incomplete Box (have:%lld need:%lld)",
+    LOG(Edts, "Incomplete Box (have:%" PRIu64 " need:%" PRIu64 ")",
         (uint64_t)reader->Remaining(), (uint64_t)need);
     return;
   }
   bool emptyEntry = false;
   uint32_t entryCount = reader->ReadU32();
   for (uint32_t i = 0; i < entryCount; i++) {
     uint64_t segment_duration;
     int64_t media_time;
@@ -860,17 +860,17 @@ Saiz::Saiz(Box& aBox, AtomType aDefaultT
     LOG(Saiz, "Incomplete Box (missing flags)");
     return;
   }
   uint32_t flags = reader->ReadU32();
   uint8_t version = flags >> 24;
   size_t need =
     ((flags & 1) ? 2*sizeof(uint32_t) : 0) + sizeof(uint8_t) + sizeof(uint32_t);
   if (reader->Remaining() < need) {
-    LOG(Saiz, "Incomplete Box (have:%lld need:%lld)",
+    LOG(Saiz, "Incomplete Box (have:%" PRIu64 " need:%" PRIu64 ")",
         (uint64_t)reader->Remaining(), (uint64_t)need);
     return;
   }
   if (flags & 1) {
     mAuxInfoType = reader->ReadU32();
     mAuxInfoTypeParameter = reader->ReadU32();
   }
   uint8_t defaultSampleInfoSize = reader->ReadU8();
@@ -898,28 +898,28 @@ Saio::Saio(Box& aBox, AtomType aDefaultT
   if (!reader->CanReadType<uint32_t>()) {
     LOG(Saio, "Incomplete Box (missing flags)");
     return;
   }
   uint32_t flags = reader->ReadU32();
   uint8_t version = flags >> 24;
   size_t need = ((flags & 1) ? (2*sizeof(uint32_t)) : 0) + sizeof(uint32_t);
   if (reader->Remaining() < need) {
-    LOG(Saio, "Incomplete Box (have:%lld need:%lld)",
+    LOG(Saio, "Incomplete Box (have:%" PRIu64 " need:%" PRIu64 ")",
         (uint64_t)reader->Remaining(), (uint64_t)need);
     return;
   }
   if (flags & 1) {
     mAuxInfoType = reader->ReadU32();
     mAuxInfoTypeParameter = reader->ReadU32();
   }
   size_t count = reader->ReadU32();
   need = (version ? sizeof(uint64_t) : sizeof(uint32_t)) * count;
   if (reader->Remaining() < need) {
-    LOG(Saio, "Incomplete Box (have:%lld need:%lld)",
+    LOG(Saio, "Incomplete Box (have:%" PRIu64 " need:%" PRIu64 ")",
         (uint64_t)reader->Remaining(), (uint64_t)need);
     return;
   }
   if (!mOffsets.SetCapacity(count, fallible)) {
     LOG(Saiz, "OOM");
     return;
   }
   if (version == 0) {
@@ -945,33 +945,33 @@ Sbgp::Sbgp(Box& aBox)
 
   uint32_t flags = reader->ReadU32();
   const uint8_t version = flags >> 24;
   flags = flags & 0xffffff;
 
   // Make sure we have enough bytes to read as far as the count.
   uint32_t need = (version == 1 ? sizeof(uint32_t) : 0) + sizeof(uint32_t) * 2;
   if (reader->Remaining() < need) {
-    LOG(Sbgp, "Incomplete Box (have:%lld, need:%lld)",
+    LOG(Sbgp, "Incomplete Box (have:%" PRIu64 ", need:%" PRIu64 ")",
         (uint64_t)reader->Remaining(), (uint64_t)need);
     return;
   }
 
   mGroupingType = reader->ReadU32();
 
   if (version == 1) {
     mGroupingTypeParam = reader->Read32();
   }
 
   uint32_t count = reader->ReadU32();
 
   // Make sure we can read all the entries.
   need = sizeof(uint32_t) * 2 * count;
   if (reader->Remaining() < need) {
-    LOG(Sbgp, "Incomplete Box (have:%lld, need:%lld). Failed to read entries",
+    LOG(Sbgp, "Incomplete Box (have:%" PRIu64 ", need:%" PRIu64 "). Failed to read entries",
         (uint64_t)reader->Remaining(), (uint64_t)need);
     return;
   }
 
   for (uint32_t i = 0; i < count; i++) {
     uint32_t sampleCount = reader->ReadU32();
     uint32_t groupDescriptionIndex = reader->ReadU32();
 
@@ -992,17 +992,17 @@ Sgpd::Sgpd(Box& aBox)
   }
 
   uint32_t flags = reader->ReadU32();
   const uint8_t version = flags >> 24;
   flags = flags & 0xffffff;
 
   uint32_t need = ((flags & 1) ? sizeof(uint32_t) : 0) + sizeof(uint32_t) * 2;
   if (reader->Remaining() < need) {
-    LOG(Sgpd, "Incomplete Box (have:%lld need:%lld)",
+    LOG(Sgpd, "Incomplete Box (have:%" PRIu64 " need:%" PRIu64 ")",
         (uint64_t)reader->Remaining(), (uint64_t)need);
     return;
   }
 
   mGroupingType = reader->ReadU32();
 
   const uint32_t entrySize = sizeof(uint32_t) + kKeyIdSize;
   uint32_t defaultLength = 0;
@@ -1016,17 +1016,17 @@ Sgpd::Sgpd(Box& aBox)
 
   uint32_t count = reader->ReadU32();
 
   // Make sure we have sufficient remaining bytes to read the entries.
   need =
     count * (sizeof(uint32_t) * (version == 1 && defaultLength == 0 ? 2 : 1) +
              kKeyIdSize * sizeof(uint8_t));
   if (reader->Remaining() < need) {
-    LOG(Sgpd, "Incomplete Box (have:%lld need:%lld). Failed to read entries",
+    LOG(Sgpd, "Incomplete Box (have:%" PRIu64 " need:%" PRIu64 "). Failed to read entries",
         (uint64_t)reader->Remaining(), (uint64_t)need);
     return;
   }
   for (uint32_t i = 0; i < count; ++i) {
     if (version == 1 && defaultLength == 0) {
       uint32_t descriptionLength = reader->ReadU32();
       if (descriptionLength < entrySize) {
         return;
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -1707,17 +1707,17 @@ status_t MPEG4Extractor::parseChunk(off6
              * optionally, "d263" box itself may contain a 16-byte
              * bit rate box (bitr)
              *   average bit rate - 4 bytes
              *   max bit rate - 4 bytes
              */
             char buffer[23];
             if (chunk_data_size != 7 &&
                 chunk_data_size != 23) {
-                ALOGE("Incorrect D263 box size %lld", chunk_data_size);
+                ALOGE("Incorrect D263 box size %" PRId64, chunk_data_size);
                 return ERROR_MALFORMED;
             }
 
             if (mDataSource->readAt(
                     data_offset, buffer, chunk_data_size) < chunk_data_size) {
                 return ERROR_IO;
             }
 
--- a/media/libstagefright/frameworks/av/media/libstagefright/MetaData.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MetaData.cpp
@@ -318,17 +318,17 @@ String8 MetaData::typed_data::asString()
             break;
         case TYPE_C_STRING:
             out = String8::format("(char*) %s", (const char *)data);
             break;
         case TYPE_INT32:
             out = String8::format("(int32_t) %d", *(int32_t *)data);
             break;
         case TYPE_INT64:
-            out = String8::format("(int64_t) %lld", *(int64_t *)data);
+            out = String8::format("(int64_t) %" PRId64, *(int64_t *)data);
             break;
         case TYPE_FLOAT:
             out = String8::format("(float) %f", *(float *)data);
             break;
         case TYPE_POINTER:
             out = String8::format("(void*) %p", *(void **)data);
             break;
         case TYPE_RECT:
--- a/media/libstagefright/moz.build
+++ b/media/libstagefright/moz.build
@@ -156,18 +156,17 @@ if CONFIG['_MSC_VER']:
     ]
 elif CONFIG['GNU_CXX']:
     CFLAGS += [
         '-Wno-comment',
         '-Wno-sign-compare',
         '-Wno-unused-function',
     ]
     CXXFLAGS += [
-        '-Wno-format',
-        '-Wno-format-security',
+        '-Werror=format',
         '-Wno-multichar',
         '-Wno-sign-compare',
         '-Wno-unused',
     ]
     if CONFIG['CLANG_CXX']:
         CXXFLAGS += [
             '-Wno-mismatched-tags',
             '-Wno-tautological-constant-out-of-range-compare',