jtag_get_device() now returns NULL and reports error instead of invoking exit()
[openocd.git] / src / jtag / jtag.c
index 6a84db40201f0e4e98290b1e8035d87cf6e79281..d8f3ccdccb2524ff07d0ddfc132f08afcba7a97a 100644 (file)
@@ -369,7 +369,7 @@ jtag_device_t* jtag_get_device(int num)
        }
 
        LOG_ERROR("jtag device number %d not defined", num);
-       exit(-1);
+       return NULL;
 }
 
 void* cmd_queue_alloc(size_t size)
@@ -477,6 +477,10 @@ int MINIDRIVER(interface_jtag_add_ir_scan)(int num_fields, scan_field_t *fields,
        {
                int found = 0;
                device = jtag_get_device(i);
+               if (device == NULL)
+               {
+                       exit(-1);
+               }
                scan_size = device->ir_length;
                (*last_cmd)->cmd.scan->fields[i].device = i;
                (*last_cmd)->cmd.scan->fields[i].num_bits = scan_size;
@@ -2120,7 +2124,12 @@ int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **a
        for (i = 0; i < argc / 2; i++)
        {
                int device = strtoul(args[i*2], NULL, 0);
-               int field_size = jtag_get_device(device)->ir_length;
+               jtag_device_t *device_ptr=jtag_get_device(device);
+               if (device==NULL)
+               {
+                       return ERROR_FAIL;
+               }
+               int field_size = device_ptr->ir_length;
                fields[i].device = device;
                fields[i].out_value = malloc(CEIL(field_size, 8));
                buf_set_u32(fields[i].out_value, 0, field_size, strtoul(args[i*2+1], NULL, 0));

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)