target: arc: rewrite command 'arc add-reg-type-flags' as COMMAND_HANDLER
commit92ef27494c510a2df7cbbee8b19d5c0d4d943d40
authorAntonio Borneo <borneo.antonio@gmail.com>
Mon, 26 Dec 2022 23:28:16 +0000 (27 00:28 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Fri, 3 Feb 2023 22:48:15 +0000 (3 22:48 +0000)
treeff6713a39da75d3985408f85518de8599f072262
parentea6a99208e1bc41a878234f7220501e26ec4a7f1
target: arc: rewrite command 'arc add-reg-type-flags' as COMMAND_HANDLER

Use a COMMAND_HELPER() to avoid memory leaks when the helper
COMMAND_PARSE_NUMBER() returns due to an error.

While there:
- fix potential SIGSEGV due to dereference 'type' before checking
  it's not NULL;
- fix an incorrect NUL byte termination while copying to
  type->data_type.id and to bitfields[cur_field].name;
- fix some coding style error.

Change-Id: Ide4cbc829871a6a523026ccc0d3100dadc2afd06
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7424
Tested-by: jenkins
Reviewed-by: Evgeniy Didin <didin@synopsys.com>
src/target/arc_cmd.c