diff options
author | Trevor Saunders <tbsaunde+binutils@tbsaunde.org> | 2016-03-20 01:36:16 -0400 |
---|---|---|
committer | Trevor Saunders <tbsaunde+binutils@tbsaunde.org> | 2016-03-22 19:12:00 -0400 |
commit | 74b4e47aa64c64069928884d35a5bc255bfcf41d (patch) | |
tree | d8d6111ea6978e8b5ed31a7d7b06225082829cdd | |
parent | 0a433ebc90ae1d3d86382757aa049a0e91bd5019 (diff) | |
download | gdb-74b4e47aa64c64069928884d35a5bc255bfcf41d.zip gdb-74b4e47aa64c64069928884d35a5bc255bfcf41d.tar.gz gdb-74b4e47aa64c64069928884d35a5bc255bfcf41d.tar.bz2 |
tc-sparc.c: get rid of wierd usage of strchr ()
This lets us avoid assigning a literal to a char *, and perhaps more
importantly makes it clearer what is going on here.
gas/ChangeLog:
2016-03-22 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
* config/tc-sparc.c (sparc_regname_to_dw2regnum): Replace strchr ()
call with a switch.
-rw-r--r-- | gas/ChangeLog | 5 | ||||
-rw-r--r-- | gas/config/tc-sparc.c | 19 |
2 files changed, 18 insertions, 6 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 0c5d973..a6960a22 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,10 @@ 2016-03-22 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> + * config/tc-sparc.c (sparc_regname_to_dw2regnum): Replace strchr () + call with a switch. + +2016-03-22 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> + * config/tc-ia64.c (ia64_do_align): Remove. (ia64_cons_align): Call do_align () directly. (dot_proc): Likewise. diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c index cac5d18..5d4e0d6 100644 --- a/gas/config/tc-sparc.c +++ b/gas/config/tc-sparc.c @@ -4829,18 +4829,25 @@ sparc_cfi_frame_initial_instructions (void) int sparc_regname_to_dw2regnum (char *regname) { - char *p, *q; + char *q; + int i; if (!regname[0]) return -1; - q = "goli"; - p = strchr (q, regname[0]); - if (p) + switch (regname[0]) + { + case 'g': i = 0; break; + case 'o': i = 1; break; + case 'l': i = 2; break; + case 'i': i = 3; break; + default: i = -1; break; + } + if (i != -1) { if (regname[1] < '0' || regname[1] > '8' || regname[2]) return -1; - return (p - q) * 8 + regname[1] - '0'; + return i * 8 + regname[1] - '0'; } if (regname[0] == 's' && regname[1] == 'p' && !regname[2]) return 14; @@ -4851,7 +4858,7 @@ sparc_regname_to_dw2regnum (char *regname) unsigned int regnum; regnum = strtoul (regname + 1, &q, 10); - if (p == q || *q) + if (q == NULL || *q) return -1; if (regnum >= ((regname[0] == 'f' && SPARC_OPCODE_ARCH_V9_P (max_architecture)) |