Bug 1345671 - Fix format strings in libstagefright - r?kinetik
MozReview-Commit-ID: BJpOgY9j4UC
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -5,16 +5,17 @@
#include "mp4_demuxer/MoofParser.h"
#include "mp4_demuxer/Box.h"
#include "mp4_demuxer/SinfParser.h"
#include <limits>
#include "Intervals.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/Logging.h"
+#include "mozilla/SizePrintfMacros.h"
#if defined(MOZ_FMP4)
extern mozilla::LogModule* GetDemuxerLog();
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define LOG(name, arg, ...) MOZ_LOG(GetDemuxerLog(), mozilla::LogLevel::Debug, (TOSTRING(name) "(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
#else
@@ -579,17 +580,17 @@ Moof::ParseTrun(Box& aBox, Tfhd& aTfhd,
((flags & 4) ? sizeof(uint32_t) : 0);
uint16_t flag[] = { 0x100, 0x200, 0x400, 0x800, 0 };
for (size_t i = 0; flag[i]; i++) {
if (flags & flag[i]) {
need += sizeof(uint32_t) * sampleCount;
}
}
if (reader->Remaining() < need) {
- LOG(Moof, "Incomplete Box (have:%lld need:%lld)",
+ LOG(Moof, "Incomplete Box (have:%" PRIuSIZE " need:%" PRIuSIZE ")",
reader->Remaining(), need);
return false;
}
uint64_t offset = aTfhd.mBaseDataOffset + (flags & 1 ? reader->ReadU32() : 0);
uint32_t firstSampleFlags =
flags & 4 ? reader->ReadU32() : aTfhd.mDefaultSampleFlags;
uint64_t decodeTime = *aDecodeTime;
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -197,17 +197,17 @@ status_t MPEG4DataSource::setCachedRange
}
////////////////////////////////////////////////////////////////////////////////
static void hexdump(const void *_data, size_t size) {
const uint8_t *data = (const uint8_t *)_data;
size_t offset = 0;
while (offset < size) {
- printf("0x%04x ", offset);
+ printf("0x%04x ", static_cast<unsigned int>(offset));
size_t n = size - offset;
if (n > 16) {
n = 16;
}
for (size_t i = 0; i < 16; ++i) {
if (i == 8) {
@@ -892,17 +892,17 @@ status_t MPEG4Extractor::parseChunk(off6
entriesoffset += 8;
segment_duration = sd;
media_time = mt;
} else {
return ERROR_IO;
}
entriesoffset += 4; // ignore media_rate_integer and media_rate_fraction.
if (media_time == -1 && i) {
- ALOGW("ignoring invalid empty edit", i);
+ ALOGW("ignoring invalid empty edit");
break;
} else if (media_time == -1) {
// Starting offsets for tracks (streams) are represented by an initial empty edit.
if (!mLastTrack) {
return ERROR_MALFORMED;
}
mLastTrack->empty_duration = segment_duration;
continue;
@@ -1667,17 +1667,17 @@ status_t MPEG4Extractor::parseChunk(off6
*offset += chunk_size;
break;
}
case FOURCC('a', 'v', 'c', 'C'):
{
if (chunk_data_size < 7) {
- ALOGE("short avcC chunk (%d bytes)", chunk_data_size);
+ ALOGE("short avcC chunk (%" PRId64 " bytes)", int64_t(chunk_data_size));
return ERROR_MALFORMED;
}
sp<ABuffer> buffer = new (fallible) ABuffer(chunk_data_size);
if (!buffer.get() || !buffer->data()) {
return -ENOMEM;
}
--- a/media/libstagefright/frameworks/av/media/libstagefright/MediaBuffer.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MediaBuffer.cpp
@@ -131,17 +131,19 @@ size_t MediaBuffer::range_offset() const
}
size_t MediaBuffer::range_length() const {
return mRangeLength;
}
void MediaBuffer::set_range(size_t offset, size_t length) {
if ((mGraphicBuffer == NULL) && (offset + length > mSize)) {
- ALOGE("offset = %d, length = %d, mSize = %d", offset, length, mSize);
+ ALOGE("offset = %" PRIuSIZE ", length = %" PRIuSIZE
+ ", mSize = %" PRIuSIZE,
+ offset, length, mSize);
}
CHECK((mGraphicBuffer != NULL) || (offset + length <= mSize));
mRangeOffset = offset;
mRangeLength = length;
}
sp<GraphicBuffer> MediaBuffer::graphicBuffer() const {
--- a/media/libstagefright/frameworks/av/media/libstagefright/MetaData.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MetaData.cpp
@@ -23,16 +23,19 @@
#include <string.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AString.h>
#include <media/stagefright/foundation/hexdump.h>
#include <media/stagefright/MetaData.h>
#include "mozilla/Assertions.h"
+#include "mozilla/SizePrintfMacros.h"
+
+#include <cinttypes>
namespace stagefright {
MetaData::MetaData() {
}
MetaData::MetaData(const MetaData &from)
: RefBase(),
@@ -306,17 +309,17 @@ void MetaData::typed_data::freeStorage()
mSize = 0;
}
String8 MetaData::typed_data::asString() const {
String8 out;
const void *data = storage();
switch(mType) {
case TYPE_NONE:
- out = String8::format("no type, size %d)", mSize);
+ out = String8::format("no type, size %" PRIuSIZE ")", mSize);
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:
@@ -332,17 +335,18 @@ String8 MetaData::typed_data::asString()
{
const Rect *r = (const Rect *)data;
out = String8::format("Rect(%d, %d, %d, %d)",
r->mLeft, r->mTop, r->mRight, r->mBottom);
break;
}
default:
- out = String8::format("(unknown type %d, size %d)", mType, mSize);
+ out = String8::format("(unknown type %" PRIu32 ", size %" PRIuSIZE ")",
+ mType, mSize);
if (mSize <= 48) { // if it's less than three lines of hex data, dump it
AString foo;
hexdump(data, mSize, 0, &foo);
out.append("\n");
out.append(foo.c_str());
}
break;
}
--- a/media/libstagefright/frameworks/av/media/libstagefright/SampleTable.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/SampleTable.cpp
@@ -23,16 +23,19 @@
#include "include/SampleIterator.h"
#include <arpa/inet.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/Utils.h>
+#include "mozilla/SizePrintfMacros.h"
+
+#include <cinttypes>
#include <stdint.h>
namespace stagefright {
// static
const uint32_t SampleTable::kChunkOffsetType32 = FOURCC('s', 't', 'c', 'o');
// static
const uint32_t SampleTable::kChunkOffsetType64 = FOURCC('c', 'o', '6', '4');
@@ -557,18 +560,18 @@ SampleTable::setSampleAuxiliaryInformati
data_offset, mCencSizes.Elements(), mCencInfoCount)
< mCencInfoCount) {
return ERROR_IO;
}
data_offset += mCencInfoCount;
}
if (data_offset != data_end) {
- ALOGW("wrong saiz data size, expected %lu, actual %lu",
- data_size, data_offset - (data_end - data_size));
+ ALOGW("wrong saiz data size, expected %" PRIuSIZE ", actual %" PRIu64,
+ data_size, uint64_t(data_offset - (data_end - data_size)));
// Continue, assume extra data is not important.
// Parser will skip past the box end.
}
return parseSampleCencInfo();
}
status_t
@@ -627,18 +630,18 @@ SampleTable::setSampleAuxiliaryInformati
ALOGE("error reading cenc aux info offsets");
return ERROR_IO;
}
data_offset += 8;
}
}
if (data_offset != data_end) {
- ALOGW("wrong saio data size, expected %lu, actual %lu",
- data_size, data_offset - (data_end - data_size));
+ ALOGW("wrong saio data size, expected %" PRIuSIZE ", actual %" PRIu64,
+ data_size, uint64_t(data_offset - (data_end - data_size)));
// Continue, assume extra data is not important.
// Parser will skip past the box end.
}
return parseSampleCencInfo();
}
status_t