Fix mtransport usages of gtest.h templates w/ mixed-sign types

RESOLVED FIXED in mozilla21

Status

()

Core
WebRTC
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

(Blocks: 1 bug)

Trunk
mozilla21
x86_64
Linux
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [WebRTC] [blocking-webrtc-] [qa-])

Attachments

(1 attachment, 1 obsolete attachment)

I get these build warnings for gtest.h template invocations where we're comparing two things w/ different signed-ness, when building current m-c and m-i:
{
 0:41.89 In file included from /scratch/work/builds/mozilla-inbound/mozilla/media/mtransport/test/ice_unittest.cpp:31:0:
 0:41.89 /scratch/work/builds/mozilla-inbound/mozilla/media/webrtc/trunk/testing/gtest/include/gtest/gtest.h: In instantiation of ‘testing::AssertionResult testing::internal::CmpHelperEQ(const char*, const char*, const T1&, const T2&) [with T1 = int; T2 = long unsigned int]’:
 0:41.89 /scratch/work/builds/mozilla-inbound/mozilla/media/webrtc/trunk/testing/gtest/include/gtest/gtest.h:1440:30:   required from ‘static testing::AssertionResult testing::internal::EqHelper<lhs_is_null_literal>::Compare(const char*, const char*, const T1&, const T2&) [with T1 = int; T2 = long unsigned int; bool lhs_is_null_literal = false]’
 0:41.89 /scratch/work/builds/mozilla-inbound/mozilla/media/mtransport/test/ice_unittest.cpp:317:5:   required from here
 0:41.89 Warning: -Wsign-compare in /scratch/work/builds/mozilla-inbound/mozilla/media/webrtc/trunk/testing/gtest/include/gtest/gtest.h: comparison between signed and unsigned integer expressions
 0:41.89 /scratch/work/builds/mozilla-inbound/mozilla/media/webrtc/trunk/testing/gtest/include/gtest/gtest.h:1403:3: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 0:41.90 In file included from /scratch/work/builds/mozilla-inbound/mozilla/media/mtransport/test/sctp_unittest.cpp:31:0:
 0:41.90 /scratch/work/builds/mozilla-inbound/mozilla/media/webrtc/trunk/testing/gtest/include/gtest/gtest.h: In instantiation of ‘testing::AssertionResult testing::internal::CmpHelperEQ(const char*, const char*, const T1&, const T2&) [with T1 = long unsigned int; T2 = int]’:
 0:41.90 /scratch/work/builds/mozilla-inbound/mozilla/media/webrtc/trunk/testing/gtest/include/gtest/gtest.h:1440:30:   required from ‘static testing::AssertionResult testing::internal::EqHelper<lhs_is_null_literal>::Compare(const char*, const char*, const T1&, const T2&) [with T1 = long unsigned int; T2 = int; bool lhs_is_null_literal = false]’
 0:41.90 /scratch/work/builds/mozilla-inbound/mozilla/media/mtransport/test/sctp_unittest.cpp:184:5:   required from here
 0:41.90 Warning: -Wsign-compare in /scratch/work/builds/mozilla-inbound/mozilla/media/webrtc/trunk/testing/gtest/include/gtest/gtest.h: comparison between signed and unsigned integer expressions
 0:41.90 /scratch/work/builds/mozilla-inbound/mozilla/media/webrtc/trunk/testing/gtest/include/gtest/gtest.h:1403:3: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 0:41.98 In file included from /scratch/work/builds/mozilla-inbound/mozilla/media/mtransport/test/transport_unittests.cpp:37:0:
 0:41.98 /scratch/work/builds/mozilla-inbound/mozilla/media/webrtc/trunk/testing/gtest/include/gtest/gtest.h: In instantiation of ‘testing::AssertionResult testing::internal::CmpHelperEQ(const char*, const char*, const T1&, const T2&) [with T1 = int; T2 = long unsigned int]’:
 0:41.98 /scratch/work/builds/mozilla-inbound/mozilla/media/webrtc/trunk/testing/gtest/include/gtest/gtest.h:1440:30:   required from ‘static testing::AssertionResult testing::internal::EqHelper<lhs_is_null_literal>::Compare(const char*, const char*, const T1&, const T2&) [with T1 = int; T2 = long unsigned int; bool lhs_is_null_literal = false]’
 0:41.98 /scratch/work/builds/mozilla-inbound/mozilla/media/mtransport/test/transport_unittests.cpp:131:5:   required from here
 0:41.99 Warning: -Wsign-compare in /scratch/work/builds/mozilla-inbound/mozilla/media/webrtc/trunk/testing/gtest/include/gtest/gtest.h: comparison between signed and unsigned integer expressions
 0:41.99 /scratch/work/builds/mozilla-inbound/mozilla/media/webrtc/trunk/testing/gtest/include/gtest/gtest.h:1403:3: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
}
(sorry for the unreadability of comment 0; it's very ugly, and that's why I'd love to have these warnings fixed. :))
Created attachment 707995 [details] [diff] [review]
fix

In two of the three cases, we're comparing to a numeric literal, which (by default) is treated as signed when we instantiate the template -- but we can add a "u" suffix to make the value unsigned instead.

In the third case, we're comparing an int to a size_t. I just cast the int to size_t, and I added a check to make sure it's nonnegative.
Assignee: nobody → dholbert
Attachment #707995 - Flags: review?(rjesup)
Created attachment 707996 [details] [diff] [review]
fix v2

(oops, previous fix accidentally had "> 0" instead of ">= 0" in the non-negative check.)
Attachment #707995 - Attachment is obsolete: true
Attachment #707995 - Flags: review?(rjesup)
Attachment #707996 - Flags: review?(rjesup)

Updated

5 years ago
Attachment #707996 - Flags: review?(rjesup) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/daa83b83531c
Status: NEW → ASSIGNED
Flags: in-testsuite-
Blocks: 836355

Updated

5 years ago
Whiteboard: [WebRTC] [blocking-webrtc-]
https://hg.mozilla.org/mozilla-central/rev/daa83b83531c
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21

Updated

5 years ago
Whiteboard: [WebRTC] [blocking-webrtc-] → [WebRTC] [blocking-webrtc-] [qa-]
You need to log in before you can comment on or make changes to this bug.