diff options
author | Alexander Yurchenko <grange@cvs.openbsd.org> | 2004-02-27 21:21:45 +0000 |
---|---|---|
committer | Alexander Yurchenko <grange@cvs.openbsd.org> | 2004-02-27 21:21:45 +0000 |
commit | a4d8cdb935a371d71353ddb2bb736445122279a1 (patch) | |
tree | 17abf6a33c32e973ee5c2f7e744db6d5972e9253 /sys | |
parent | ee12c624d5dc098c53cefbf630e1a2fd819b7b0f (diff) |
Backport from i386 andreas' diff for removing leading and
duplicated spaces from cpu brand string.
ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/identcpu.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c index b2fd81a6a74..f843aedf085 100644 --- a/sys/arch/amd64/amd64/identcpu.c +++ b/sys/arch/amd64/amd64/identcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identcpu.c,v 1.2 2004/02/09 22:15:52 mickey Exp $ */ +/* $OpenBSD: identcpu.c,v 1.3 2004/02/27 21:21:44 grange Exp $ */ /* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /* @@ -95,6 +95,8 @@ identifycpu(struct cpu_info *ci) u_int32_t dummy, val; u_int32_t brand[12]; int i, max; + char *brandstr_from, *brandstr_to; + int skipspace; CPUID(1, ci->ci_signature, val, dummy, ci->ci_feature_flags); CPUID(0x80000001, dummy, dummy, dummy, ci->ci_feature_eflags); @@ -104,6 +106,21 @@ identifycpu(struct cpu_info *ci) CPUID(0x80000004, brand[8], brand[9], brand[10], brand[11]); strlcpy(cpu_model, (char *)brand, sizeof(cpu_model)); + + /* Remove leading and duplicated spaces from cpu_model */ + brandstr_from = brandstr_to = cpu_model; + skipspace = 1; + while (*brandstr_from != '\0') { + if (!skipspace || *brandstr_from != ' ') { + skipspace = 0; + *(brandstr_to++) = *brandstr_from; + } + if (*brandstr_from == ' ') + skipspace = 1; + brandstr_from++; + } + *brandstr_to = '\0'; + if (cpu_model[0] == 0) strlcpy(cpu_model, "Opteron or Athlon 64", sizeof(cpu_model)); |