flash/nor: improved API of flash_driver.info & fixed buffer overruns
[openocd.git] / src / flash / nor / msp432.c
index b6933e1e9bbdd5b1c3d25821592390da9a6b9c23..22f7c77a2e3ccc51996eda02cd0fac2dcbb5916a 100644 (file)
@@ -975,60 +975,50 @@ static int msp432_auto_probe(struct flash_bank *bank)
        return retval;
 }
 
-static int msp432_info(struct flash_bank *bank, char *buf, int buf_size)
+static int msp432_info(struct flash_bank *bank, struct command_invocation *cmd)
 {
        struct msp432_bank *msp432_bank = bank->driver_priv;
-       int printed = 0;
 
        switch (msp432_bank->device_type) {
                case MSP432P401X_DEPR:
                        if (0xFFFF == msp432_bank->device_id) {
                                /* Very early pre-production silicon currently deprecated */
-                               printed = snprintf(buf, buf_size,
-                                       "MSP432P401x pre-production device (deprecated silicon)\n"
+                               command_print_sameline(cmd, "MSP432P401x pre-production device (deprecated silicon)\n"
                                        SUPPORT_MESSAGE);
                        } else {
                                /* Revision A or B silicon, also deprecated */
-                               printed = snprintf(buf, buf_size,
-                                       "MSP432P401x Device Rev %c (deprecated silicon)\n"
+                               command_print_sameline(cmd, "MSP432P401x Device Rev %c (deprecated silicon)\n"
                                        SUPPORT_MESSAGE, (char)msp432_bank->hardware_rev);
                        }
                        break;
                case MSP432P401X:
-                       printed = snprintf(buf, buf_size,
-                               "MSP432P401x Device Rev %c\n",
+                       command_print_sameline(cmd, "MSP432P401x Device Rev %c\n",
                                (char)msp432_bank->hardware_rev);
                        break;
                case MSP432P411X:
-                       printed = snprintf(buf, buf_size,
-                               "MSP432P411x Device Rev %c\n",
+                       command_print_sameline(cmd, "MSP432P411x Device Rev %c\n",
                                (char)msp432_bank->hardware_rev);
                        break;
                case MSP432E401Y:
-                       printed = snprintf(buf, buf_size, "MSP432E401Y Device\n");
+                       command_print_sameline(cmd, "MSP432E401Y Device\n");
                        break;
                case MSP432E411Y:
-                       printed = snprintf(buf, buf_size, "MSP432E411Y Device\n");
+                       command_print_sameline(cmd, "MSP432E411Y Device\n");
                        break;
                case MSP432E4X_GUESS:
-                       printed = snprintf(buf, buf_size,
+                       command_print_sameline(cmd,
                                "Unrecognized MSP432E4 DID0 and DID1 IDs (%08" PRIX32 ", %08" PRIX32 ")",
                                msp432_bank->device_id, msp432_bank->hardware_rev);
                        break;
                case MSP432P401X_GUESS:
                case MSP432P411X_GUESS:
                default:
-                       printed = snprintf(buf, buf_size,
+                       command_print_sameline(cmd,
                                "Unrecognized MSP432P4 Device ID and Hardware Rev (%04" PRIX32 ", %02" PRIX32 ")",
                                msp432_bank->device_id, msp432_bank->hardware_rev);
                        break;
        }
 
-       buf_size -= printed;
-
-       if (0 > buf_size)
-               return ERROR_BUF_TOO_SMALL;
-
        return ERROR_OK;
 }
 

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)