diff options
author | Ian Romanick <idr@umwelt.(none)> | 2006-07-14 15:26:56 -0700 |
---|---|---|
committer | Ian Romanick <idr@umwelt.(none)> | 2006-07-14 15:26:56 -0700 |
commit | 490fb304599b1f24b36439e5c1397781e7d2f612 (patch) | |
tree | 7ef3f64809ee41be66392f96aa2f73c566eb30ca /hw/xfree86/int10 | |
parent | d3ee49bcbafe4b4e6b308686020847e978473779 (diff) |
Rearrange code in xf86int10ParseBiosLocation to use strncasecmp. This
eliminates the need for the first use of xstrdup in this function.
The second use of xstrdup was *never* necessary and has also been
eliminated.
Diffstat (limited to 'hw/xfree86/int10')
-rw-r--r-- | hw/xfree86/int10/helper_mem.c | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/hw/xfree86/int10/helper_mem.c b/hw/xfree86/int10/helper_mem.c index 624359f23..0338a86de 100644 --- a/hw/xfree86/int10/helper_mem.c +++ b/hw/xfree86/int10/helper_mem.c @@ -284,36 +284,30 @@ void xf86int10ParseBiosLocation(void* options, xf86int10BiosLocationPtr bios) { - char *s; - char *p; - char *str = NULL; - - if (options) - str = xf86GetOptValString(options,OPT_BIOS_LOCATION); + const char *p; + const char *str; bios->bus = BUS_NONE; - if (!str) + + if ((options == NULL) + || ((str = xf86GetOptValString(options, OPT_BIOS_LOCATION)) == NULL)) { return; - - s = xstrdup(str); - p = strtok(s,":"); - if (xf86NameCmp(p,"pci") == 0) bios->bus = BUS_PCI; - else - if (xf86NameCmp(p,"primary") == 0) bios->bus = BUS_ISA; + } - xfree(s); - - if (bios->bus == BUS_NONE) return; + if (strncasecmp(str, "pci", 3) == 0) { + bios->bus = BUS_PCI; + } else if (strncasecmp(str, "primary", 7) == 0) { + bios->bus = BUS_ISA; + } + else { + return; + } - s = xstrdup(str); - p = strchr(s, ':'); + p = strchr(str, ':'); switch (bios->bus) { case BUS_ISA: - if (p) - bios->location.legacy = atoi(++p); - else - bios->location.legacy = 0; + bios->location.legacy = (p != NULL) ? atoi(++p) : 0; break; case BUS_PCI: if (p) { @@ -332,7 +326,6 @@ xf86int10ParseBiosLocation(void* options, default: break; } - xfree(s); } |