msrtool: Add endptr to str2msr() showing how many characters were parsed

This also introduces a small change in the user interface for immediate
mode (-i). Previously, whitespace could separate high and low words in
an MSR as such:

msrtool -i 4c00000f='f2f100ff 56960004'

That is no longer allowed, a space character now ends the MSR value. Any
other character can still be used as separator however, so the following
syntax still works as expected:

msrtool -i 4c00000f=f2f100ff:56960004

Signed-off-by: Peter Stuge <peter@stuge.se>
Acked-by: Stefan Reinauer <stepan@coresystems.de>


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5032 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Peter Stuge
2010-01-17 18:33:53 +00:00
parent 838c5a5d80
commit 34f2907a1b
3 changed files with 8 additions and 7 deletions

View File

@ -208,7 +208,7 @@ int do_diff(const char *difffn) {
m1start = line + tmp + m1pos;
for (len = strlen(m1start) - 1; NULL != strchr("\r\n", m1start[len]); --len)
m1start[len] = 0;
if (!str2msr(m1start, &m1)) {
if (!str2msr(m1start, &m1, NULL)) {
fprintf(stderr, "%s:%d: invalid MSR value '%s'\n", difffn, linenum, m1start);
continue;
}
@ -288,7 +288,7 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "missing value in -i argument!\n");
break;
}
if (!str2msr(++optarg, &msrval))
if (!str2msr(++optarg, &msrval, NULL))
fprintf(stderr, "invalid value in -i argument!\n");
break;
case 's':