- Fixing two compiler warnings
authormifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 10 Dec 2007 19:46:04 +0000 (19:46 +0000)
committermifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 10 Dec 2007 19:46:04 +0000 (19:46 +0000)
- Reducing  stack usage for recursive scripts
- Do not exit on bogus arguments to reset_config. No longer exit the application upon bogus arguments to reset_config, but return errors.

thanks to √ėyvind Harboe for these patches.

git-svn-id: svn://svn.berlios.de/openocd/trunk@226 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/flash/at91sam7.c
src/flash/cfi.c
src/helper/command.c
src/jtag/jtag.c

index 0115c18b641adea2a5c97fe0781b45f01906c76f..907302eb2b75f15de3b56ffbe219b326f592e4ca 100644 (file)
@@ -674,7 +674,7 @@ int at91sam7_erase(struct flash_bank_s *bank, int first, int last)
 
 int at91sam7_protect(struct flash_bank_s *bank, int set, int first, int last)
 {
-       u32 cmd, pagen, status;
+       u32 cmd, pagen;
        u8 flashplane;
        int lockregion;
        
index b952bb7f49173d6c8f89d59518385a6ff9099ef3..ee99408e8a5a9b4f4ec5dcbf9ca5af774af8dd99 100644 (file)
@@ -2046,7 +2046,7 @@ int cfi_info(struct flash_bank_s *bank, char *buf, int buf_size)
        int printed;
        cfi_flash_bank_t *cfi_info = bank->driver_priv;
 
-       if (cfi_info->qry[0] == -1)
+       if (cfi_info->qry[0] == (char)-1)
        {
                printed = snprintf(buf, buf_size, "\ncfi flash bank not probed yet\n");
                return ERROR_OK;
index 11284a1c4c86744b6eb7f13d160e388fa4f85c75..f69deb49d8778c6c3a030e895b01995e8ca62838 100644 (file)
@@ -383,7 +383,11 @@ int command_run_file(command_context_t *context, FILE *file, enum command_mode m
 {
        int retval = ERROR_OK;
        int old_command_mode;
-       char buffer[4096];
+       char *buffer=malloc(4096);
+       if (buffer==NULL)
+       {
+               return ERROR_INVALID_ARGUMENTS;
+       }
        
        old_command_mode = context->mode;
        context->mode = mode;
@@ -422,6 +426,9 @@ int command_run_file(command_context_t *context, FILE *file, enum command_mode m
        }
        
        context->mode = old_command_mode;
+
+       
+       free(buffer);
        
        return retval;
 }
index 09cffef799e601cdc59a8acb02262c72c29d6534..6356bec6ac2e7defbbad51b5beb203cb904dea83 100644 (file)
@@ -1446,7 +1446,8 @@ int jtag_init(struct command_context_s *cmd_ctx)
                                        if (validate_tries > 5)
                                        {
                                                ERROR("Could not validate JTAG chain, exit");
-                                               exit(-1);
+                                               jtag = NULL;
+                                               return ERROR_JTAG_INVALID_INTERFACE;
                                        }
                                        usleep(10000);
                                }
@@ -1568,8 +1569,9 @@ int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, ch
                        jtag_reset_config = RESET_TRST_AND_SRST;
                else
                {
-                       ERROR("invalid reset_config argument");
-                       exit(-1);
+                       ERROR("invalid reset_config argument, defaulting to none");
+                       jtag_reset_config = RESET_NONE;
+                       return ERROR_INVALID_ARGUMENTS;
                }
        }
        
@@ -1585,8 +1587,9 @@ int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, ch
                        jtag_reset_config &= ~(RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST);
                else
                {
-                       ERROR("invalid reset_config argument");
-                       exit(-1);
+                       ERROR("invalid reset_config argument, defaulting to none");
+                       jtag_reset_config = RESET_NONE;
+                       return ERROR_INVALID_ARGUMENTS;
                }
        }
        
@@ -1598,8 +1601,9 @@ int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, ch
                        jtag_reset_config &= ~RESET_TRST_OPEN_DRAIN;
                else
                {
-                       ERROR("invalid reset_config argument");
-                       exit(-1);
+                       ERROR("invalid reset_config argument, defaulting to none");
+                       jtag_reset_config = RESET_NONE;
+                       return ERROR_INVALID_ARGUMENTS;
                }
        }
 
@@ -1611,8 +1615,9 @@ int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, ch
                        jtag_reset_config &= ~RESET_SRST_PUSH_PULL;
                else
                {
-                       ERROR("invalid reset_config argument");
-                       exit(-1);
+                       ERROR("invalid reset_config argument, defaulting to none");
+                       jtag_reset_config = RESET_NONE;
+                       return ERROR_INVALID_ARGUMENTS;
                }
        }
        

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)