From 9ffaa58ba47f5211cce25483e7408dbaf9a6cbfc Mon Sep 17 00:00:00 2001 From: Kenneth Mortensen Date: Thu, 13 Nov 2014 10:44:33 +0100 Subject: No error termination in case of zero read bytes --- src/InputFileReader.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/InputFileReader.cpp') diff --git a/src/InputFileReader.cpp b/src/InputFileReader.cpp index 52fbb99..4a7e050 100644 --- a/src/InputFileReader.cpp +++ b/src/InputFileReader.cpp @@ -284,13 +284,18 @@ int InputFileReader::GetNextFrame(void* buffer) if (read_bytes != frameSize) { // A short read of a frame (i.e. reading an incomplete frame) // is not tolerated. Input files must not contain incomplete frames - fprintf(stderr, - "Unable to read a complete frame of %u data bytes from input file!\n", - frameSize); - - perror(filename_.c_str()); - logger_.level(error) << "Unable to read from input file!"; - return -1; + if (read_bytes != 0){ + fprintf(stderr, + "Unable to read a complete frame of %u data bytes from input file!\n", + frameSize); + + perror(filename_.c_str()); + logger_.level(error) << "Unable to read from input file!"; + return -1; + } + else { + return 0; + } } memset(&((uint8_t*)buffer)[frameSize], 0x55, 6144 - frameSize); -- cgit v1.2.3 From aa63facf2c4140acef2ba6e7f1b8012eec5536bf Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 22 Dec 2014 18:20:32 +0100 Subject: Reindent InputFileReader::GetNextFrame() --- src/InputFileReader.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/InputFileReader.cpp') diff --git a/src/InputFileReader.cpp b/src/InputFileReader.cpp index 4a7e050..205fbfa 100644 --- a/src/InputFileReader.cpp +++ b/src/InputFileReader.cpp @@ -284,17 +284,17 @@ int InputFileReader::GetNextFrame(void* buffer) if (read_bytes != frameSize) { // A short read of a frame (i.e. reading an incomplete frame) // is not tolerated. Input files must not contain incomplete frames - if (read_bytes != 0){ - fprintf(stderr, - "Unable to read a complete frame of %u data bytes from input file!\n", - frameSize); - - perror(filename_.c_str()); - logger_.level(error) << "Unable to read from input file!"; - return -1; + if (read_bytes != 0) { + fprintf(stderr, + "Unable to read a complete frame of %u data bytes from input file!\n", + frameSize); + + perror(filename_.c_str()); + logger_.level(error) << "Unable to read from input file!"; + return -1; } else { - return 0; + return 0; } } -- cgit v1.2.3