From ad4ba21fd5759eaa7f6b2fb297d5d1e7e96de1b2 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Mon, 5 Apr 2010 14:56:35 -0700 Subject: [PATCH] Bug 556303: Fix unsigned/signed compiler warning in nsTArray.cpp. r=bsmedberg --- xpcom/glue/nsTArray.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xpcom/glue/nsTArray.cpp b/xpcom/glue/nsTArray.cpp index b5945266f002..ba57c6de67bf 100644 --- a/xpcom/glue/nsTArray.cpp +++ b/xpcom/glue/nsTArray.cpp @@ -85,7 +85,9 @@ nsTArray_base::EnsureCapacity(size_type capacity, size_type elemSize) { } // Use doubling algorithm when forced to increase available capacity. - capacity = PR_MAX(capacity, mHdr->mCapacity << 1); + // (Note that mCapacity is only 31 bits wide, so multiplication promotes its + // type. We use |2u| instead of |2| to make sure it's promoted to unsigned.) + capacity = PR_MAX(capacity, mHdr->mCapacity * 2u); Header *header; if (UsesAutoArrayBuffer()) {