From 513bfe54a9a74f00dbcfccc04cb05c12b8dd3bdb Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Mon, 18 Mar 2013 10:58:31 -0700 Subject: [PATCH] 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 --- memory/mozalloc/mozalloc_oom.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/memory/mozalloc/mozalloc_oom.cpp b/memory/mozalloc/mozalloc_oom.cpp index 39a464ef7a0f..4ad24142482d 100644 --- a/memory/mozalloc/mozalloc_oom.cpp +++ b/memory/mozalloc/mozalloc_oom.cpp @@ -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--) {