p = get_flash_bank_by_addr(target, address);
if (p == NULL)
{
- return ERROR_COMMAND_SYNTAX_ERROR;
+ return ERROR_FAIL;
}
/* We can't know if we did a resume + halt, in which case we no longer know the erased state */
{
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)