Skip to content

Commit

Permalink
Bug 791906: Replace NSPR integer limit constants with stdint ones; r=…
Browse files Browse the repository at this point in the history
…ehsan
  • Loading branch information
Isaac Aggrey committed Sep 28, 2012
1 parent 5f0577d commit 6765a02
Show file tree
Hide file tree
Showing 230 changed files with 485 additions and 485 deletions.
2 changes: 1 addition & 1 deletion accessible/src/base/nsAccessibilityService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
// Create accessible for visible text frames.
if (content->IsNodeOfType(nsINode::eTEXT)) {
nsAutoString text;
weakFrame->GetRenderedText(&text, nullptr, nullptr, 0, PR_UINT32_MAX);
weakFrame->GetRenderedText(&text, nullptr, nullptr, 0, UINT32_MAX);
if (text.IsEmpty()) {
if (aIsSubtreeHidden)
*aIsSubtreeHidden = true;
Expand Down
2 changes: 1 addition & 1 deletion accessible/src/generic/Accessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class Accessible : public nsAccessNodeWrap,
* then text form start offset till the end is appended
*/
virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
uint32_t aLength = PR_UINT32_MAX);
uint32_t aLength = UINT32_MAX);

/**
* Assert if child not in parent's cache if the cache was initialized at this
Expand Down
2 changes: 1 addition & 1 deletion accessible/src/generic/TextLeafAccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TextLeafAccessible : public LinkableAccessible
// Accessible
virtual mozilla::a11y::role NativeRole();
virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
uint32_t aLength = PR_UINT32_MAX);
uint32_t aLength = UINT32_MAX);
virtual ENameValueFlag Name(nsString& aName);

// TextLeafAccessible
Expand Down
2 changes: 1 addition & 1 deletion accessible/src/html/HTMLListAccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class HTMLListBulletAccessible : public LeafAccessible
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
uint32_t aLength = PR_UINT32_MAX);
uint32_t aLength = UINT32_MAX);

// HTMLListBulletAccessible

Expand Down
2 changes: 1 addition & 1 deletion caps/idl/nsIScriptSecurityManager.idl
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ interface nsIScriptSecurityManager : nsIXPCSecurityManager


const unsigned long NO_APP_ID = 0;
const unsigned long UNKNOWN_APP_ID = 4294967295; // PR_UINT32_MAX
const unsigned long UNKNOWN_APP_ID = 4294967295; // UINT32_MAX

/**
* Returns the extended origin for the uri.
Expand Down
2 changes: 1 addition & 1 deletion content/base/src/WebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ WebSocket::Send(nsIDOMBlob* aData,
return;
}

if (msgLength > PR_UINT32_MAX) {
if (msgLength > UINT32_MAX) {
aRv.Throw(NS_ERROR_FILE_TOO_BIG);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions content/base/src/nsAttrValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class nsAttrValue {
* @return whether the value could be parsed
*/
bool ParseIntValue(const nsAString& aString) {
return ParseIntWithBounds(aString, PR_INT32_MIN, PR_INT32_MAX);
return ParseIntWithBounds(aString, INT32_MIN, INT32_MAX);
}

/**
Expand All @@ -291,7 +291,7 @@ class nsAttrValue {
* @return whether the value could be parsed
*/
bool ParseIntWithBounds(const nsAString& aString, int32_t aMin,
int32_t aMax = PR_INT32_MAX);
int32_t aMax = INT32_MAX);

/**
* Parse a string value into a non-negative integer.
Expand Down
2 changes: 1 addition & 1 deletion content/base/src/nsContentList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ nsContentList::Item(uint32_t aIndex, bool aDoFlush)
}

if (mState != LIST_UP_TO_DATE)
PopulateSelf(NS_MIN(aIndex, PR_UINT32_MAX - 1) + 1);
PopulateSelf(NS_MIN(aIndex, UINT32_MAX - 1) + 1);

ASSERT_IN_SYNC;
NS_ASSERTION(!mRootNode || mState != LIST_DIRTY,
Expand Down
2 changes: 1 addition & 1 deletion content/base/src/nsContentList.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

// Magic namespace id that means "match all namespaces". This is
// negative so it won't collide with actual namespace constants.
#define kNameSpaceID_Wildcard PR_INT32_MIN
#define kNameSpaceID_Wildcard INT32_MIN

// This is a callback function type that can be used to implement an
// arbitrary matching algorithm. aContent is the content that may
Expand Down
2 changes: 1 addition & 1 deletion content/base/src/nsDOMFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ nsDOMMemoryFile::CreateSlice(uint64_t aStart, uint64_t aLength,
NS_IMETHODIMP
nsDOMMemoryFile::GetInternalStream(nsIInputStream **aStream)
{
if (mLength > PR_INT32_MAX)
if (mLength > INT32_MAX)
return NS_ERROR_FAILURE;

return DataOwnerAdapter::Create(mDataOwner, mStart, mLength, aStream);
Expand Down
4 changes: 2 additions & 2 deletions content/base/src/nsDOMFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ nsDOMFileReader::DoOnDataAvailable(nsIRequest *aRequest,
NS_ASSERTION(mResult.Length() == aOffset,
"unexpected mResult length");
uint32_t oldLen = mResult.Length();
if (uint64_t(oldLen) + aCount > PR_UINT32_MAX)
if (uint64_t(oldLen) + aCount > UINT32_MAX)
return NS_ERROR_OUT_OF_MEMORY;

PRUnichar *buf = nullptr;
Expand All @@ -314,7 +314,7 @@ nsDOMFileReader::DoOnDataAvailable(nsIRequest *aRequest,
}
else {
//Update memory buffer to reflect the contents of the file
if (aOffset + aCount > PR_UINT32_MAX) {
if (aOffset + aCount > UINT32_MAX) {
// PR_Realloc doesn't support over 4GB memory size even if 64-bit OS
return NS_ERROR_OUT_OF_MEMORY;
}
Expand Down
2 changes: 1 addition & 1 deletion content/base/src/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8238,7 +8238,7 @@ nsresult
nsIDocument::ScheduleFrameRequestCallback(nsIFrameRequestCallback* aCallback,
int32_t *aHandle)
{
if (mFrameRequestCallbackCounter == PR_INT32_MAX) {
if (mFrameRequestCallbackCounter == INT32_MAX) {
// Can't increment without overflowing; bail out
return NS_ERROR_NOT_AVAILABLE;
}
Expand Down
4 changes: 2 additions & 2 deletions content/base/src/nsFrameMessageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,11 +901,11 @@ nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
nsString dataString;
uint64_t avail64 = 0;
if (input && NS_SUCCEEDED(input->Available(&avail64)) && avail64) {
if (avail64 > PR_UINT32_MAX) {
if (avail64 > UINT32_MAX) {
return;
}
nsCString buffer;
uint32_t avail = (uint32_t)NS_MIN(avail64, (uint64_t)PR_UINT32_MAX);
uint32_t avail = (uint32_t)NS_MIN(avail64, (uint64_t)UINT32_MAX);
if (NS_FAILED(NS_ReadInputStreamToString(input, buffer, avail))) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion content/base/src/nsNodeInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ nsNodeInfo::nsNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, int32_t aNamespaceID,
SetDOMStringToNull(mLocalName);
break;
default:
NS_ABORT_IF_FALSE(aNodeType == PR_UINT16_MAX,
NS_ABORT_IF_FALSE(aNodeType == UINT16_MAX,
"Unknown node type");
}
}
Expand Down
4 changes: 2 additions & 2 deletions content/base/src/nsNodeInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ CheckValidNodeInfo(uint16_t aNodeType, nsIAtom *aName, int32_t aNamespaceID,
aNodeType == nsIDOMNode::DOCUMENT_NODE ||
aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE ||
aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE ||
aNodeType == PR_UINT16_MAX,
aNodeType == UINT16_MAX,
"Invalid nodeType");
NS_ABORT_IF_FALSE((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) ==
!!aExtraName,
"Supply aExtraName for and only for PIs and doctypes");
NS_ABORT_IF_FALSE(aNodeType == nsIDOMNode::ELEMENT_NODE ||
aNodeType == nsIDOMNode::ATTRIBUTE_NODE ||
aNodeType == PR_UINT16_MAX ||
aNodeType == UINT16_MAX ||
aNamespaceID == kNameSpaceID_None,
"Only attributes and elements can be in a namespace");
NS_ABORT_IF_FALSE(aName && aName != nsGkAtoms::_empty, "Invalid localName");
Expand Down
8 changes: 4 additions & 4 deletions content/base/src/nsSyncLoadService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ nsSyncLoadService::PushSyncStreamToListener(nsIInputStream* aIn,
if (NS_FAILED(rv)) {
chunkSize = 4096;
}
chunkSize = NS_MIN(int32_t(PR_UINT16_MAX), chunkSize);
chunkSize = NS_MIN(int32_t(UINT16_MAX), chunkSize);

rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream), aIn,
chunkSize);
Expand All @@ -366,11 +366,11 @@ nsSyncLoadService::PushSyncStreamToListener(nsIInputStream* aIn,
break;
}

if (readCount > PR_UINT32_MAX)
readCount = PR_UINT32_MAX;
if (readCount > UINT32_MAX)
readCount = UINT32_MAX;

rv = aListener->OnDataAvailable(aChannel, nullptr, aIn,
(uint32_t)NS_MIN(sourceOffset, (uint64_t)PR_UINT32_MAX),
(uint32_t)NS_MIN(sourceOffset, (uint64_t)UINT32_MAX),
(uint32_t)readCount);
if (NS_FAILED(rv)) {
break;
Expand Down
2 changes: 1 addition & 1 deletion content/base/src/nsXMLHttpRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2443,7 +2443,7 @@ GetRequestBody(nsIDOMDocument* aDoc, nsIInputStream** aResult,
NS_ENSURE_SUCCESS(rv, rv);

nsCOMPtr<nsIStorageStream> storStream;
rv = NS_NewStorageStream(4096, PR_UINT32_MAX, getter_AddRefs(storStream));
rv = NS_NewStorageStream(4096, UINT32_MAX, getter_AddRefs(storStream));
NS_ENSURE_SUCCESS(rv, rv);

nsCOMPtr<nsIOutputStream> output;
Expand Down
6 changes: 3 additions & 3 deletions content/events/src/nsContentEventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static uint32_t CountNewlinesInXPLength(nsIContent* aContent,
return 0;
// For automated tests, we should abort on debug build.
NS_ABORT_IF_FALSE(
(aXPLength == PR_UINT32_MAX || aXPLength <= text->GetLength()),
(aXPLength == UINT32_MAX || aXPLength <= text->GetLength()),
"aXPLength is out-of-bounds");
const uint32_t length = NS_MIN(aXPLength, text->GetLength());
uint32_t newlines = 0;
Expand All @@ -204,7 +204,7 @@ static uint32_t CountNewlinesInNativeLength(nsIContent* aContent,
}
// For automated tests, we should abort on debug build.
NS_ABORT_IF_FALSE(
(aNativeLength == PR_UINT32_MAX || aNativeLength <= text->GetLength() * 2),
(aNativeLength == UINT32_MAX || aNativeLength <= text->GetLength() * 2),
"aNativeLength is unexpected value");
const uint32_t xpLength = text->GetLength();
uint32_t newlines = 0;
Expand All @@ -222,7 +222,7 @@ static uint32_t CountNewlinesInNativeLength(nsIContent* aContent,
}
#endif

static uint32_t GetNativeTextLength(nsIContent* aContent, uint32_t aMaxLength = PR_UINT32_MAX)
static uint32_t GetNativeTextLength(nsIContent* aContent, uint32_t aMaxLength = UINT32_MAX)
{
if (aContent->IsNodeOfType(nsINode::eTEXT)) {
uint32_t textLengthDifference =
Expand Down
2 changes: 1 addition & 1 deletion content/events/src/nsEventStateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5252,7 +5252,7 @@ nsEventStateManager::DeltaAccumulator::Reset()
{
mX = mY = 0.0;
mPendingScrollAmountX = mPendingScrollAmountY = 0.0;
mHandlingDeltaMode = PR_UINT32_MAX;
mHandlingDeltaMode = UINT32_MAX;
mHandlingPixelOnlyDevice = false;
}

Expand Down
4 changes: 2 additions & 2 deletions content/events/src/nsEventStateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ class nsEventStateManager : public nsSupportsWeakReference,
sInstance = nullptr;
}

bool IsInTransaction() { return mHandlingDeltaMode != PR_UINT32_MAX; }
bool IsInTransaction() { return mHandlingDeltaMode != UINT32_MAX; }

/**
* InitLineOrPageDelta() stores pixel delta values of WheelEvents which are
Expand All @@ -585,7 +585,7 @@ class nsEventStateManager : public nsSupportsWeakReference,
private:
DeltaAccumulator() :
mX(0.0), mY(0.0), mPendingScrollAmountX(0.0), mPendingScrollAmountY(0.0),
mHandlingDeltaMode(PR_UINT32_MAX), mHandlingPixelOnlyDevice(false)
mHandlingDeltaMode(UINT32_MAX), mHandlingPixelOnlyDevice(false)
{
}

Expand Down
4 changes: 2 additions & 2 deletions content/html/content/src/nsHTMLCanvasElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ nsHTMLCanvasElement::ToDataURLImpl(const nsAString& aMimeType,
uint64_t count;
rv = stream->Available(&count);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(count <= PR_UINT32_MAX, NS_ERROR_FILE_TOO_BIG);
NS_ENSURE_TRUE(count <= UINT32_MAX, NS_ERROR_FILE_TOO_BIG);

return Base64EncodeInputStream(stream, aDataURL, (uint32_t)count, aDataURL.Length());
}
Expand Down Expand Up @@ -585,7 +585,7 @@ nsHTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName,
uint64_t imgSize;
rv = stream->Available(&imgSize);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(imgSize <= PR_UINT32_MAX, NS_ERROR_FILE_TOO_BIG);
NS_ENSURE_TRUE(imgSize <= UINT32_MAX, NS_ERROR_FILE_TOO_BIG);

void* imgData = nullptr;
rv = NS_ReadInputStreamToBuffer(stream, &imgData, (uint32_t)imgSize);
Expand Down
2 changes: 1 addition & 1 deletion content/media/AudioSegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ AudioSegment::WriteTo(nsAudioStream* aOutput)
uint32_t frameSize = GetSampleSize(aOutput->GetFormat())*mChannels;
for (ChunkIterator ci(*this); !ci.IsEnded(); ci.Next()) {
AudioChunk& c = *ci;
if (frameSize*c.mDuration > PR_UINT32_MAX) {
if (frameSize*c.mDuration > UINT32_MAX) {
NS_ERROR("Buffer overflow");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion content/media/FileBlockCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ nsresult FileBlockCache::Read(int64_t aOffset,
{
MonitorAutoLock mon(mDataMonitor);

if (!mFD || (aOffset / BLOCK_SIZE) > PR_INT32_MAX)
if (!mFD || (aOffset / BLOCK_SIZE) > INT32_MAX)
return NS_ERROR_FAILURE;

int32_t bytesToRead = aLength;
Expand Down
2 changes: 1 addition & 1 deletion content/media/MediaResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ void FileMediaResource::EnsureSizeInitialized()
// Get the file size and inform the decoder.
uint64_t size;
nsresult res = mInput->Available(&size);
if (NS_SUCCEEDED(res) && size <= PR_INT64_MAX) {
if (NS_SUCCEEDED(res) && size <= INT64_MAX) {
mSize = (int64_t)size;
nsCOMPtr<nsIRunnable> event = new LoadedEvent(mDecoder);
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
Expand Down
4 changes: 2 additions & 2 deletions content/media/MediaSegment.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace mozilla {
*/
typedef int64_t MediaTime;
const int64_t MEDIA_TIME_FRAC_BITS = 20;
const int64_t MEDIA_TIME_MAX = PR_INT64_MAX;
const int64_t MEDIA_TIME_MAX = INT64_MAX;

inline MediaTime MillisecondsToMediaTime(int32_t aMS)
{
Expand All @@ -41,7 +41,7 @@ inline double MediaTimeToSeconds(MediaTime aTime)
* 2^MEDIA_TIME_FRAC_BITS doesn't overflow, so we set its max accordingly.
*/
typedef int64_t TrackTicks;
const int64_t TRACK_TICKS_MAX = PR_INT64_MAX >> MEDIA_TIME_FRAC_BITS;
const int64_t TRACK_TICKS_MAX = INT64_MAX >> MEDIA_TIME_FRAC_BITS;

/**
* A MediaSegment is a chunk of media data sequential in time. Different
Expand Down
14 changes: 7 additions & 7 deletions content/media/TimeVarying.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ class TimeVarying : public TimeVaryingBase {
/**
* Returns the final value of the function. If aTime is non-null,
* sets aTime to the time at which the function changes to that final value.
* If there are no changes after the current time, returns PR_INT64_MIN in aTime.
* If there are no changes after the current time, returns INT64_MIN in aTime.
*/
const T& GetLast(Time* aTime = nullptr) const
{
if (mChanges.IsEmpty()) {
if (aTime) {
*aTime = PR_INT64_MIN;
*aTime = INT64_MIN;
}
return mCurrent;
}
Expand Down Expand Up @@ -119,10 +119,10 @@ class TimeVarying : public TimeVaryingBase {
/**
* Returns the value of the function at time aTime.
* If aEnd is non-null, sets *aEnd to the time at which the function will
* change from the returned value to a new value, or PR_INT64_MAX if that
* change from the returned value to a new value, or INT64_MAX if that
* never happens.
* If aStart is non-null, sets *aStart to the time at which the function
* changed to the returned value, or PR_INT64_MIN if that happened at or
* changed to the returned value, or INT64_MIN if that happened at or
* before the current time.
*
* Currently uses a linear search, but could use a binary search.
Expand All @@ -131,17 +131,17 @@ class TimeVarying : public TimeVaryingBase {
{
if (mChanges.IsEmpty() || aTime < mChanges[0].mTime) {
if (aStart) {
*aStart = PR_INT64_MIN;
*aStart = INT64_MIN;
}
if (aEnd) {
*aEnd = mChanges.IsEmpty() ? PR_INT64_MAX : mChanges[0].mTime;
*aEnd = mChanges.IsEmpty() ? INT64_MAX : mChanges[0].mTime;
}
return mCurrent;
}
int32_t changesLength = mChanges.Length();
if (mChanges[changesLength - 1].mTime <= aTime) {
if (aEnd) {
*aEnd = PR_INT64_MAX;
*aEnd = INT64_MAX;
}
if (aStart) {
*aStart = mChanges[changesLength - 1].mTime;
Expand Down
2 changes: 1 addition & 1 deletion content/media/VideoUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CheckedInt64 UsecsToFrames(int64_t aUsecs, uint32_t aRate) {
static int32_t ConditionDimension(float aValue)
{
// This will exclude NaNs and too-big values.
if (aValue > 1.0 && aValue <= PR_INT32_MAX)
if (aValue > 1.0 && aValue <= INT32_MAX)
return int32_t(NS_round(aValue));
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions content/media/nsAudioStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ int32_t nsNativeAudioStream::GetMinWriteSize()
&size);
if (r == SA_ERROR_NOT_SUPPORTED)
return 1;
else if (r != SA_SUCCESS || size > PR_INT32_MAX)
else if (r != SA_SUCCESS || size > INT32_MAX)
return -1;

return static_cast<int32_t>(size / mChannels / sizeof(short));
Expand Down Expand Up @@ -1152,7 +1152,7 @@ nsBufferedAudioStream::GetPositionInFramesUnlocked()
if (position >= mLostFrames) {
adjustedPosition = position - mLostFrames;
}
return NS_MIN<uint64_t>(adjustedPosition, PR_INT64_MAX);
return NS_MIN<uint64_t>(adjustedPosition, INT64_MAX);
}

bool
Expand Down
Loading

0 comments on commit 6765a02

Please sign in to comment.