This is an automated email from Gerrit.

Harishkumar V ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/2431

-- gerrit

commit ce0fef8a1c19f6a30887ae0b61fe6e745b379d09
Author: HarishKumar <[email protected]>
Date:   Tue Dec 9 19:38:08 2014 +0530

    Tcl commands: Fix improper return status in flash commands and load_image.
    
    Nand write command :
    nand_fileio_cleanup() always returns ERROR_OK. Due to this,
    handle_nand_write_command() retuns ERROR_OK in the case
    of nand failure. ERROR_FAIL should be returned.
    
    Flash erase_sector command :
    handle_flash_erase_command() always returns ERROR_OK even if
    the erase functionality of actual driver implementation fails.
    retval value should be returned.
    
    Flash write_bank command :
    handle_flash_write_bank_command() returns ERROR_OK even if
    fileio_open() and fileio_read fails. ERROR_FAIL should be
    returned.
    
    Load_image command :
    handle_load_image_command() retuns ERROR_OK even if image_open()
    fails. ERROR_FAIL should be returned.
    When the buffer is null, breaking the loop without setting
    retval = ERROR_FAIL would cause load_image to return ERROR_OK.
    
    Change-Id: Ice32f6036971ab5e8e4dd65edf54b394b001c80c
    Signed-off-by: HarishKumar <[email protected]>

diff --git a/src/flash/nand/tcl.c b/src/flash/nand/tcl.c
index 20854c7..b06659f 100644
--- a/src/flash/nand/tcl.c
+++ b/src/flash/nand/tcl.c
@@ -256,7 +256,8 @@ COMMAND_HANDLER(handle_nand_write_command)
                int bytes_read = nand_fileio_read(nand, &s);
                if (bytes_read <= 0) {
                        command_print(CMD_CTX, "error while reading file");
-                       return nand_fileio_cleanup(&s);
+                       nand_fileio_cleanup(&s);
+                       return ERROR_FAIL;
                }
                s.size -= bytes_read;
 
@@ -266,7 +267,8 @@ COMMAND_HANDLER(handle_nand_write_command)
                        command_print(CMD_CTX, "failed writing file %s "
                                "to NAND flash %s at offset 0x%8.8" PRIx32,
                                CMD_ARGV[1], CMD_ARGV[0], s.address);
-                       return nand_fileio_cleanup(&s);
+                       nand_fileio_cleanup(&s);
+                       return retval;
                }
                s.address += s.page_size;
        }
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c
index 8f97ebd..f0e04c3 100644
--- a/src/flash/nor/tcl.c
+++ b/src/flash/nor/tcl.c
@@ -318,7 +318,7 @@ COMMAND_HANDLER(handle_flash_erase_command)
                        "in %fs", first, last, p->bank_number, 
duration_elapsed(&bench));
        }
 
-       return ERROR_OK;
+       return retval;
 }
 
 COMMAND_HANDLER(handle_flash_protect_command)
@@ -571,7 +571,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
        COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], offset);
 
        if (fileio_open(&fileio, CMD_ARGV[1], FILEIO_READ, FILEIO_BINARY) != 
ERROR_OK)
-               return ERROR_OK;
+               return ERROR_FAIL;
 
        int filesize;
        retval = fileio_size(&fileio, &filesize);
@@ -590,7 +590,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
        if (fileio_read(&fileio, filesize, buffer, &buf_cnt) != ERROR_OK) {
                free(buffer);
                fileio_close(&fileio);
-               return ERROR_OK;
+               return ERROR_FAIL;
        }
 
        retval = flash_driver_write(p, buffer, offset, buf_cnt);
diff --git a/src/target/target.c b/src/target/target.c
index d7a2c48..e330914 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -2994,7 +2994,7 @@ COMMAND_HANDLER(handle_load_image_command)
        duration_start(&bench);
 
        if (image_open(&image, CMD_ARGV[0], (CMD_ARGC >= 3) ? CMD_ARGV[2] : 
NULL) != ERROR_OK)
-               return ERROR_OK;
+               return ERROR_FAIL;
 
        image_size = 0x0;
        retval = ERROR_OK;
@@ -3004,6 +3004,7 @@ COMMAND_HANDLER(handle_load_image_command)
                        command_print(CMD_CTX,
                                                  "error allocating buffer for 
section (%d bytes)",
                                                  
(int)(image.sections[i].size));
+                       retval = ERROR_FAIL;
                        break;
                }
 

-- 

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to