Bug 851981: Make loop iterator in mozalloc_handle_oom a size_t instead of an int, to fix build warning for signed/unsigned comparison. r=bsmedberg

This commit is contained in:
Daniel Holbert 2013-03-18 10:58:31 -07:00
parent 31b4eb191e
commit 3a2a871ecc

View File

@ -11,6 +11,7 @@
#include "mozilla/mozalloc_abort.h"
#include "mozilla/mozalloc_oom.h"
#include "mozilla/Assertions.h"
static mozalloc_oom_abort_handler gAbortHandler;
@ -27,7 +28,7 @@ void
mozalloc_handle_oom(size_t size)
{
char oomMsg[] = OOM_MSG_LEADER OOM_MSG_DIGITS OOM_MSG_TRAILER;
int i;
size_t i;
// NB: this is handle_oom() stage 1, which simply aborts on OOM.
// we might proceed to a stage 2 in which an attempt is made to
@ -36,6 +37,9 @@ mozalloc_handle_oom(size_t size)
if (gAbortHandler)
gAbortHandler(size);
MOZ_STATIC_ASSERT(OOM_MSG_FIRST_DIGIT_OFFSET > 0,
"Loop below will never terminate (i can't go below 0)");
// Insert size into the diagnostic message using only primitive operations
for (i = OOM_MSG_LAST_DIGIT_OFFSET;
size && i >= OOM_MSG_FIRST_DIGIT_OFFSET; i--) {