Close dangling file handle
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 24 Apr 2008 20:40:52 +0000 (20:40 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 24 Apr 2008 20:40:52 +0000 (20:40 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@616 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/flash/flash.c
src/target/image.c

index b9e5a9dc14c3a3ba8bd453f8c2fade76d1e5ce50..3478b6a28d3e9b1ebd534d2001f5aba2888f6a26 100644 (file)
@@ -478,7 +478,7 @@ int handle_flash_erase_address_command(struct command_context_s *cmd_ctx, char *
        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 */
index 1eb956728f58c8b45cbca1162177b8aa627b1e99..72a3828c36f0cbadef4b75b75d9f373f5962d93a 100644 (file)
@@ -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)