From 3931b99d142d337ea6558fd09aad2e0812c04507 Mon Sep 17 00:00:00 2001 From: Øyvind Harboe Date: Wed, 29 Sep 2010 09:11:01 +0200 Subject: fileio: fileio_size() can now fail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Part of making the fileio API more robust. Signed-off-by: Øyvind Harboe --- src/target/etm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/target/etm.c') diff --git a/src/target/etm.c b/src/target/etm.c index c71c5d19..9f7bc83d 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -1897,7 +1897,15 @@ COMMAND_HANDLER(handle_etm_load_command) return ERROR_FAIL; } - if (fileio_size(&file) % 4) + int filesize; + int retval = fileio_size(&file, &filesize); + if (retval != ERROR_OK) + { + fileio_close(&file); + return retval; + } + + if (filesize % 4) { command_print(CMD_CTX, "size isn't a multiple of 4, no valid trace data"); fileio_close(&file); -- cgit v1.2.3