diff options
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/image.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/target/image.c b/src/target/image.c index 1eb95672..72a3828c 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -57,15 +57,19 @@ static int autodetect_image_type(image_t *image, char *url) { return retval; } - if ((retval = fileio_read(&fileio, 9, buffer, &read_bytes)) != ERROR_OK) - { - return ERROR_FILEIO_OPERATION_FAILED; - } - if (read_bytes != 9) + retval = fileio_read(&fileio, 9, buffer, &read_bytes); + + if (retval==ERROR_OK) { - return ERROR_FILEIO_OPERATION_FAILED; + if (read_bytes != 9) + { + retval=ERROR_FILEIO_OPERATION_FAILED; + } } fileio_close(&fileio); + + if (retval!=ERROR_OK) + return retval; /* check header against known signatures */ if (strncmp((char*)buffer,ELFMAG,SELFMAG)==0) |