stlink: swo: use completely the available buffer 61/6061/2
authorAntonio Borneo <borneo.antonio@gmail.com>
Sat, 13 Feb 2021 22:28:16 +0000 (23:28 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Wed, 10 Mar 2021 21:36:01 +0000 (21:36 +0000)
The buffer passed to stlink_usb_trace_read() is allocated of size
*size and does not need to be zero-terminated. There is no reason
to not fill its last byte.

When checking the bytes available on swo, limit the retrieved byte
length to *size.

Change-Id: Iade0f8963118695931f13a8a3f1ab204911236b6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Adrian Negreanu <adrian.negreanu@nxp.com>
Reviewed-on: http://openocd.zylin.com/6061
Tested-by: jenkins
Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
src/jtag/drivers/stlink_usb.c

index 73169e1e4866c75aa57896d402f6a8e32aa0a651..a5f8bdff1963229dd27d0cc75439cd8297d13306 100644 (file)
@@ -1967,7 +1967,7 @@ static int stlink_usb_trace_read(void *handle, uint8_t *buf, size_t *size)
                        return res;
 
                size_t bytes_avail = le_to_h_u16(h->databuf);
-               *size = bytes_avail < *size ? bytes_avail : *size - 1;
+               *size = bytes_avail < *size ? bytes_avail : *size;
 
                if (*size > 0) {
                        res = stlink_usb_read_trace(handle, buf, *size);

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)