[Live-devel] [patch] getc returns int, using char truncates value
Erik Hovland
erik at hovland.org
Fri Jul 4 13:27:37 PDT 2008
Getc and all of the char I/O calls return an int. When a char is used to
store that return value then the return value is truncated.
Since all it takes to get the true value is to change the variable type
that is storing the returned value, that is what this patch does.
E
---
liveMedia/WAVAudioFileSource.cpp | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/liveMedia/WAVAudioFileSource.cpp b/liveMedia/WAVAudioFileSource.cpp
index 595cff6..e80d5c7 100644
--- a/liveMedia/WAVAudioFileSource.cpp
+++ b/liveMedia/WAVAudioFileSource.cpp
@@ -78,7 +78,7 @@ unsigned char WAVAudioFileSource::getAudioFormat() {
#define ucEOF ((unsigned char)EOF)
static Boolean get4Bytes(FILE* fid, unsigned& result) { // little-endian
- unsigned char c0, c1, c2, c3;
+ int c0, c1, c2, c3;
if ((c0 = nextc) == ucEOF || (c1 = nextc) == ucEOF ||
(c2 = nextc) == ucEOF || (c3 = nextc) == ucEOF) return False;
result = (c3<<24)|(c2<<16)|(c1<<8)|c0;
@@ -86,7 +86,7 @@ static Boolean get4Bytes(FILE* fid, unsigned& result) { // little-endian
}
static Boolean get2Bytes(FILE* fid, unsigned short& result) {//little-endian
- unsigned char c0, c1;
+ int c0, c1;
if ((c0 = nextc) == ucEOF || (c1 = nextc) == ucEOF) return False;
result = (c1<<8)|c0;
return True;
@@ -157,7 +157,7 @@ WAVAudioFileSource::WAVAudioFileSource(UsageEnvironment& env, FILE* fid)
if (!skipBytes(fid, formatLength - 16)) break;
// FACT chunk (optional):
- unsigned char c = nextc;
+ int c = nextc;
if (c == 'f') {
if (nextc != 'a' || nextc != 'c' || nextc != 't') break;
unsigned factLength;
--
Erik Hovland
mail: erik at hovland.org
web: http://hovland.org/
PGP/GPG public key available on request
More information about the live-devel
mailing list