From e6cf7c0d4f1ce7dc5933956e744fa9bf44c7c3bc Mon Sep 17 00:00:00 2001 From: Peter Stuge Date: Sat, 16 Jan 2010 18:39:35 +0000 Subject: msrtool: More trivial rearrangement Rename some variables Remove the 'found' variable which turns out not to be needed anyway Signed-off-by: Peter Stuge Acked-by: Peter Stuge git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5024 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- util/msrtool/msrtool.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'util') diff --git a/util/msrtool/msrtool.c b/util/msrtool/msrtool.c index 7ef40d82b4..570f1fb7b2 100644 --- a/util/msrtool/msrtool.c +++ b/util/msrtool/msrtool.c @@ -180,13 +180,13 @@ done: } int do_diff(const char *difffn) { - char tmpfn[20], line[512]; - size_t start, len; - int ret = 1, found, tmp; + char tmpfn[20], line[512], *m1start; + size_t len; + int ret = 1, tmp, m1pos; FILE *fin = NULL, *fout = stdout; uint8_t rev = 0; uint32_t addr, linenum; - struct msr mf = MSR1(0), mhw = MSR1(0); + struct msr m1 = MSR1(0), m2 = MSR1(0); if (':' == difffn[0]) { rev = 1; @@ -202,20 +202,19 @@ int do_diff(const char *difffn) { if (!sys->open(cpu, SYS_RDONLY)) goto done; for (linenum = 1; NULL != fgets(line, sizeof(line), fin); ++linenum) { - start = (0 == strncmp("0x", line, 2)) ? 2 : 0; - found = sscanf(line + start, "%8x %n%*x", &addr, &tmp); - if (found < 1) + tmp = strncmp("0x", line, 2) ? 0 : 2; + if (sscanf(line + tmp, "%8x %n%*x", &addr, &m1pos) < 1) continue; - start += tmp; - for (len = strlen(line) - 1; NULL != strchr("\r\n", line[len]); --len) - line[len] = 0; - if (!str2msr(line + start, &mf)) { - fprintf(stderr, "%s:%d: invalid MSR value '%s'\n", difffn, linenum, line + start); + m1start = line + tmp + m1pos; + for (len = strlen(m1start) - 1; NULL != strchr("\r\n", m1start[len]); --len) + m1start[len] = 0; + if (!str2msr(m1start, &m1)) { + fprintf(stderr, "%s:%d: invalid MSR value '%s'\n", difffn, linenum, m1start); continue; } - if (!sys->rdmsr(cpu, addr, &mhw)) + if (!sys->rdmsr(cpu, addr, &m2)) goto done; - if (diff_msr(fout, addr, rev ? mhw : mf, rev ? mf : mhw)) + if (diff_msr(fout, addr, rev ? m2 : m1, rev ? m1 : m2)) fprintf(fout, "\n"); } if (!feof(fin)) -- cgit v1.2.3