Closed Bug 556559 Opened 12 years ago Closed 12 years ago

Fix warnings in TestTArray.cpp - "warning: comparison between signed and unsigned integer expressions"

Categories

(Core :: XPCOM, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: dholbert, Assigned: dholbert)

Details

(Whiteboard: [build_warning])

Attachments

(1 file)

{
> TestTArray.cpp: In function 'PRBool TestTArray::test_string_array()':
> TestTArray.cpp:318: warning: comparison between signed and unsigned integer expressions
> TestTArray.cpp: In function 'PRBool TestTArray::test_indexof()':
> TestTArray.cpp:521: warning: comparison between signed and unsigned integer expressions
> TestTArray.cpp: In function 'PRBool TestTArray::test_basic_array(ElementType*, PRUint32, const ElementType&) [with ElementType = int]':
> TestTArray.cpp:175:   instantiated from here
> TestTArray.cpp:105: warning: comparison between signed and unsigned integer expressions
> TestTArray.cpp: In function 'PRBool TestTArray::test_basic_array(ElementType*, PRUint32, const ElementType&) [with ElementType = PRInt64]':
> TestTArray.cpp:180:   instantiated from here
> TestTArray.cpp:105: warning: comparison between signed and unsigned integer expressions
> TestTArray.cpp: In function 'PRBool TestTArray::test_basic_array(ElementType*, PRUint32, const ElementType&) [with ElementType = char]':
> TestTArray.cpp:185:   instantiated from here
> TestTArray.cpp:105: warning: comparison between signed and unsigned integer expressions
> TestTArray.cpp: In function 'PRBool TestTArray::test_basic_array(ElementType*, PRUint32, const ElementType&) [with ElementType = PRUint32]':
> TestTArray.cpp:190:   instantiated from here
> TestTArray.cpp:105: warning: comparison between signed and unsigned integer expressions
> TestTArray.cpp: In function 'PRBool TestTArray::test_basic_array(ElementType*, PRUint32, const ElementType&) [with ElementType = nsCString]':
> TestTArray.cpp:325:   instantiated from here
> TestTArray.cpp:105: warning: comparison between signed and unsigned integer expressions
> TestTArray.cpp: In function 'PRBool TestTArray::test_basic_array(ElementType*, PRUint32, const ElementType&) [with ElementType = nsCOMPtr<nsIFile>]':
> TestTArray.cpp:366:   instantiated from here
> TestTArray.cpp:105: warning: comparison between signed and unsigned integer expressions
}

This is due to lines like:
{
318   if (strArray.BinaryIndexOf(EmptyCString()) != -1)
319     return PR_FALSE;
}

Note that BinaryIndexOf returns an unsigned value.  We should be comparing it against nsTArray::NoIndex instead of -1.
Attached patch fixSplinter Review
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #436524 - Flags: review?(benjamin)
Attachment #436524 - Flags: review?(benjamin) → review+
http://hg.mozilla.org/mozilla-central/rev/ccce7bebe7d9
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: [build_warning]
You need to log in before you can comment on or make changes to this bug.