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
This commit is contained in:
Peter Stuge 2010-01-16 18:39:35 +00:00
parent 0401bd89b6
commit e6cf7c0d4f

View file

@ -180,13 +180,13 @@ done:
} }
int do_diff(const char *difffn) { int do_diff(const char *difffn) {
char tmpfn[20], line[512]; char tmpfn[20], line[512], *m1start;
size_t start, len; size_t len;
int ret = 1, found, tmp; int ret = 1, tmp, m1pos;
FILE *fin = NULL, *fout = stdout; FILE *fin = NULL, *fout = stdout;
uint8_t rev = 0; uint8_t rev = 0;
uint32_t addr, linenum; uint32_t addr, linenum;
struct msr mf = MSR1(0), mhw = MSR1(0); struct msr m1 = MSR1(0), m2 = MSR1(0);
if (':' == difffn[0]) { if (':' == difffn[0]) {
rev = 1; rev = 1;
@ -202,20 +202,19 @@ int do_diff(const char *difffn) {
if (!sys->open(cpu, SYS_RDONLY)) if (!sys->open(cpu, SYS_RDONLY))
goto done; goto done;
for (linenum = 1; NULL != fgets(line, sizeof(line), fin); ++linenum) { for (linenum = 1; NULL != fgets(line, sizeof(line), fin); ++linenum) {
start = (0 == strncmp("0x", line, 2)) ? 2 : 0; tmp = strncmp("0x", line, 2) ? 0 : 2;
found = sscanf(line + start, "%8x %n%*x", &addr, &tmp); if (sscanf(line + tmp, "%8x %n%*x", &addr, &m1pos) < 1)
if (found < 1)
continue; continue;
start += tmp; m1start = line + tmp + m1pos;
for (len = strlen(line) - 1; NULL != strchr("\r\n", line[len]); --len) for (len = strlen(m1start) - 1; NULL != strchr("\r\n", m1start[len]); --len)
line[len] = 0; m1start[len] = 0;
if (!str2msr(line + start, &mf)) { if (!str2msr(m1start, &m1)) {
fprintf(stderr, "%s:%d: invalid MSR value '%s'\n", difffn, linenum, line + start); fprintf(stderr, "%s:%d: invalid MSR value '%s'\n", difffn, linenum, m1start);
continue; continue;
} }
if (!sys->rdmsr(cpu, addr, &mhw)) if (!sys->rdmsr(cpu, addr, &m2))
goto done; 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"); fprintf(fout, "\n");
} }
if (!feof(fin)) if (!feof(fin))