summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhenrik.lundin@webrtc.org <henrik.lundin@webrtc.org>2014-09-25 07:38:14 +0000
committerhenrik.lundin@webrtc.org <henrik.lundin@webrtc.org>2014-09-25 07:38:14 +0000
commit7ce45b575d4f9592b35dbe869fb1c1fb32b9185f (patch)
treec102944991c5fa1ad6ea5585aa080dff6751017b
parentfc65f4aeded074f364424f5c639e7d9a3dc406cd (diff)
downloadwebrtc-7ce45b575d4f9592b35dbe869fb1c1fb32b9185f.tar.gz
Revert r7049/r7123, which added unnecessary "u"s to "return 0"s.
r7049 added some unnecessary casts ("return 0" -> "return static_cast<uint16_t>(0)"). r7123 converted these to "return 0u". The original impetus for this was to eliminate type conversion warnings. However, the 'u's are unnecessary; Visual Studio can return "0" from a function returning an unsigned value without producing a warning. The real reason for the original warnings was that the code was returning -1 from a function returning an unsigned value, which does need a cast; the -1s were eliminated before the above two revisions landed. Also reverse the order of some conditionals to prevent possible underflow. While the underflow wouldn't have changed the behavior of the code, it's easier to reason about the code when such underflow can't happen, and possibly safer against future modifications as well. BUG=3663 TEST=none R=tina.legrand@webrtc.org Review URL: https://webrtc-codereview.appspot.com/22599004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@7296 4adac7df-926f-26a2-2b94-8c16560cd09d
-rw-r--r--modules/audio_coding/main/test/RTPFile.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/modules/audio_coding/main/test/RTPFile.cc b/modules/audio_coding/main/test/RTPFile.cc
index 4cef5924..b7f587b8 100644
--- a/modules/audio_coding/main/test/RTPFile.cc
+++ b/modules/audio_coding/main/test/RTPFile.cc
@@ -109,7 +109,7 @@ uint16_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
if (packet->payloadSize > 0 && payloadSize >= packet->payloadSize) {
memcpy(payloadData, packet->payloadData, packet->payloadSize);
} else {
- return 0u;
+ return 0;
}
*offset = (packet->timeStamp / (packet->frequency / 1000));
@@ -216,7 +216,7 @@ uint16_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
/* Check if we have reached end of file. */
if ((read_len == 0) && feof(_rtpFile)) {
_rtpEOF = true;
- return 0u;
+ return 0;
}
EXPECT_EQ(1u, fread(&plen, 2, 1, _rtpFile));
EXPECT_EQ(1u, fread(offset, 4, 1, _rtpFile));
@@ -232,13 +232,13 @@ uint16_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
EXPECT_EQ(lengthBytes, plen + 8);
if (plen == 0) {
- return 0u;
- }
- if (payloadSize < (lengthBytes - 20)) {
- return 0u;
+ return 0;
}
if (lengthBytes < 20) {
- return 0u;
+ return 0;
+ }
+ if (payloadSize < (lengthBytes - 20)) {
+ return 0;
}
lengthBytes -= 20;
EXPECT_EQ(lengthBytes, fread(payloadData, 1, lengthBytes, _rtpFile));