summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPeter Stuge <peter@stuge.se>2010-01-16 18:39:35 +0000
committerPeter Stuge <peter@stuge.se>2010-01-16 18:39:35 +0000
commite6cf7c0d4f1ce7dc5933956e744fa9bf44c7c3bc (patch)
tree254d5c5d85b50445cfb5a085a21afd53b295bc43 /util
parent0401bd89b6e7105ca597a221fdbe2a8b75c35296 (diff)
downloadcoreboot-e6cf7c0d4f1ce7dc5933956e744fa9bf44c7c3bc.tar.xz
msrtool: More trivial rearrangement
Rename some variables Remove the 'found' variable which turns out not to be needed anyway Signed-off-by: Peter Stuge <peter@stuge.se> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5024 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util')
-rw-r--r--util/msrtool/msrtool.c27
1 files changed, 13 insertions, 14 deletions
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))