summaryrefslogtreecommitdiff
path: root/src/target/etm.c
diff options
context:
space:
mode:
authorØyvind Harboe <oyvind.harboe@zylin.com>2010-09-29 09:11:01 +0200
committerØyvind Harboe <oyvind.harboe@zylin.com>2010-09-29 18:56:07 +0200
commit3931b99d142d337ea6558fd09aad2e0812c04507 (patch)
tree20ca8392b75964e038b941b607dcce8162513b2d /src/target/etm.c
parent3a693ef526575633cc350a69aa1a5d1f08e64c46 (diff)
downloadopenocd+libswd-3931b99d142d337ea6558fd09aad2e0812c04507.tar.gz
openocd+libswd-3931b99d142d337ea6558fd09aad2e0812c04507.tar.bz2
openocd+libswd-3931b99d142d337ea6558fd09aad2e0812c04507.tar.xz
openocd+libswd-3931b99d142d337ea6558fd09aad2e0812c04507.zip
fileio: fileio_size() can now fail
Part of making the fileio API more robust. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Diffstat (limited to 'src/target/etm.c')
-rw-r--r--src/target/etm.c10
1 files changed, 9 insertions, 1 deletions
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);