Closed Bug 865774 Opened 11 years ago Closed 11 years ago

cpr_string.c:203:78: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Categories

(Core :: WebRTC, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla23

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

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

Attachments

(1 file)

GCC warning:
{
media/webrtc/signaling/src/sipcc/cpr/common/cpr_string.c:203:78: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
}
for this line:
203     MOZ_ASSERT(vsnprintf_result > 0 && vsnprintf_result < (fs->buffer_length - fs->string_length));
http://mxr.mozilla.org/mozilla-central/source/media/webrtc/signaling/src/sipcc/cpr/common/cpr_string.c#203

* vsnprintf_result is signed (it's an int)
* fs->buffer_length - fs->string_length is unsigned (both are 'size_t')

We can just static_cast vsnprintf_result to size_t, which is safe because we just checked that it's greater than 0.
er, s/static_cast/cast/ since this is a .c file
Attached patch fix v1Splinter Review
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #741940 - Flags: review?(rjesup)
MXR link showing that buffer_length and string_length are size_t:

> 73 typedef struct {
> 74   char *buffer;
> 75   size_t buffer_length;
> 76   size_t string_length;
> 77 } flex_string;
http://mxr.mozilla.org/mozilla-central/source/media/webrtc/signaling/src/sipcc/cpr/include/cpr_string.h#75
Attachment #741940 - Flags: review?(rjesup) → review+
Keywords: checkin-needed
Whiteboard: [WebRTC][blocking-webrtc-]
https://hg.mozilla.org/mozilla-central/rev/d3f88b2e42f7
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
Whiteboard: [WebRTC][blocking-webrtc-] → [WebRTC][blocking-webrtc-][qa-]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: