Open
Bug 740122
Opened 12 years ago
Updated 2 years ago
fix MSVC "possible loss of data" warnings in netwerk/
Categories
(Core :: Networking, defect, P5)
Tracking
()
NEW
People
(Reporter: froydnj, Unassigned)
References
(Blocks 1 open bug)
Details
(Whiteboard: [necko-would-take])
Attachments
(1 file)
16.65 KB,
patch
|
briansmith
:
review-
|
Details | Diff | Splinter Review |
There are a fair number of these warnings (C4244); I think most of them are fairly harmless, but there are a couple that may point to actual problems. Once these are all flushed out, maybe we can turn on /we4244 for netwerk?
Reporter | ||
Comment 1•12 years ago
|
||
Here's a patch with the warnings fixed in rather a mindless way.
Attachment #610265 -
Flags: feedback?(jduell.mcbugs)
Comment 2•12 years ago
|
||
Comment on attachment 610265 [details] [diff] [review] patch Thanks for the patch. Some but not all of these already have r+d patches in bugzilla that I haven't checked in yet (Search for assigned:bsmith@mozilla.com). I can review the patch in a few days, after I check in the fixes for the other bugs.
Attachment #610265 -
Flags: review?(bsmith)
Comment 3•12 years ago
|
||
Comment on attachment 610265 [details] [diff] [review] patch Review of attachment 610265 [details] [diff] [review]: ----------------------------------------------------------------- I'll let Brian take this then.
Attachment #610265 -
Flags: feedback?(jduell.mcbugs)
Comment 4•12 years ago
|
||
Comment on attachment 610265 [details] [diff] [review] patch Review of attachment 610265 [details] [diff] [review]: ----------------------------------------------------------------- ::: netwerk/base/src/nsStreamTransportService.cpp @@ +218,5 @@ > } > } > > // limit amount read > + PRUint32 max = PRUint32(mLimit - mOffset); Why not this?: PRUint64 max = mLimit - mOffset; @@ +417,5 @@ > } > } > > // limit amount written > + PRUint32 max = PRUint32(mLimit - mOffset); Ditto. ::: netwerk/protocol/http/nsHttpChannel.cpp @@ +4154,5 @@ > *_retval = 0; \ > return NS_OK; \ > } \ > *_retval = mChannelCreationTime + \ > + PRTime((stamp - mChannelCreationTimestamp).ToMicroseconds()); \ Fixed in bug 736887. @@ +4603,5 @@ > // > nsresult rv = mListener->OnDataAvailable(this, > mListenerContext, > input, > + (PRUint32) mLogicalOffset, Fixed in bug 736903. (Note that this was a bug and that the cast is not correct.) ::: netwerk/protocol/websocket/WebSocketChannel.cpp @@ +1040,5 @@ > // reset to detect if next message illegally starts with continuation > mFragmentOpcode = kContinuation; > } else { > opcode = kContinuation; > + mFragmentAccumulator += PRUint32(payloadLength); We know payloadLength fits in a 32-bit integer because above we check that it is less than the 32-bit integer mMaxMessageSize. Instead of doing all the casting below, we should rename payload to payloadLength64, and then after that check, set const PRUint32 payloadLength = PRUint32(payloadLength64); This will avoid most, but not all, of the need for casts, AFAICT. ::: netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ +334,5 @@ > > NS_IMETHODIMP > nsPartChannel::GetContentLength(PRInt32 *aContentLength) > { > + *aContentLength = PRInt32(mContentLength); // XXX truncates 64-bit value Should nsIChannel.contentLength be clamped to 2^31, or is it OK to truncate it like this? OnDataAvailable is specified as clamping the value to 2^31 and it seems like a good idea to be consistent. @@ +843,5 @@ > > rv = mPartChannel->SetContentType(mContentType); > if (NS_FAILED(rv)) return rv; > > + rv = mPartChannel->SetContentLength(PRInt32(mContentLength)); // XXX Truncates 64-bit! This is wrong. We can define a new SetContentLength64(PRInt64) function on nsPartChannel, which avoids the truncation. And... @@ +905,5 @@ > if (aLen == 0) > return NS_OK; > } > > + PRUint32 offset = PRUint32(mTotalSent); We cannot truncate the offset to 32 bits. Instead, we have to clamp it, as was done in bug 736903. I recommend changing the type of offset to PRInt64, and then changing the signature of nsPartChannel::SendOnDataAvailable to take a 64-bit offset, and then have nsPartChannel::SendOnDataAvailable do the clamping.
Attachment #610265 -
Flags: review?(bsmith) → review-
Updated•8 years ago
|
Whiteboard: [necko-would-take]
Comment 6•7 years ago
|
||
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P5
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•