summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Herrmann <andreas.herrmann3@amd.com>2011-05-27 14:56:37 +0200
committerDave Jones <davej@redhat.com>2011-05-27 14:25:55 -0400
commitd53455d4c2ee6641373e8b754e258c939c3cb5e6 (patch)
tree147d1a431c468a8f3f2520b5d7afbb5d05ba9ab7
parentff0de4d4a2ff915ea58d1e7c526dbb53ccb13e93 (diff)
x86info: Fix buggy pointer arithmetic
Patch 208fb9613c8c151b2885e89066a3eb22a977df6f introduced breakage on x86_64. Fix this and also replace usage of post by pre-increment to avoid potential issues with operator priority. Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
-rw-r--r--rdmsr.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/rdmsr.c b/rdmsr.c
index 5f2cc10..823cab0 100644
--- a/rdmsr.c
+++ b/rdmsr.c
@@ -70,10 +70,10 @@ int read_msr(int cpu, unsigned int idx, unsigned long long *val)
{
char cpuname[16];
unsigned char buffer[8];
- unsigned long lo, hi;
+ unsigned long long lo, hi;
int fh;
static int nodriver=0;
- unsigned long *ptr = (unsigned long *) buffer;
+ unsigned int *ptr = (unsigned int *) buffer;
if (nodriver==1)
return 0;
@@ -101,10 +101,9 @@ int read_msr(int cpu, unsigned int idx, unsigned long long *val)
return 0;
}
- lo = *(ptr)++;
- hi = *(ptr);
- *val = hi;
- *val = (*val<<32) | lo;
+ lo = *ptr;
+ hi = *(++ptr);
+ *val = (hi << 32) | lo;
}
if (close(fh) == -1) {
perror("close");