diff options
author | Dave Jones <davej@redhat.com> | 2011-03-14 15:56:25 -0400 |
---|---|---|
committer | Dave Jones <davej@redhat.com> | 2011-03-14 15:56:25 -0400 |
commit | 208fb9613c8c151b2885e89066a3eb22a977df6f (patch) | |
tree | 91217e77eb1f219431d38ee71e959625e86a8d70 | |
parent | d228d451d49ad2b3d65bc6206dab65c6eef4fa5e (diff) |
Fix up aliasing warnings.
gcc has started complaining about these even if passed -fno-strict-aliasing
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | cpuid.c | 9 | ||||
-rw-r--r-- | rdmsr.c | 5 | ||||
-rw-r--r-- | x86info.c | 2 |
5 files changed, 12 insertions, 11 deletions
@@ -1,8 +1,7 @@ -VERSION=1.28 +VERSION=1.29 -CFLAGS = -g -O2 -Werror -Wall -Wshadow -Wextra -Wmissing-declarations -Wdeclaration-after-statement -Wredundant-decls -fno-strict-aliasing +CFLAGS = -g -O2 -Werror -Wall -Wshadow -Wextra -Wmissing-declarations -Wdeclaration-after-statement -Wredundant-decls LDFLAGS = -Wl,-z,relro,-z,now -# -Wstrict-overflow=5 CC = gcc SHELL = /bin/sh @@ -1,4 +1,4 @@ -x86info v1.28 http://www.codemonkey.org.uk/projects/x86info +x86info v1.29 http://www.codemonkey.org.uk/projects/x86info Dave Jones <davej@redhat.com> Somewhere in the mists of time, there was a program by Phil Karn (KA9Q) @@ -159,6 +159,7 @@ void cpuid(unsigned int CPU_number, unsigned long long idx, static int nodriver=0; char cpuname[20]; unsigned char buffer[CPUID_CHUNK_SIZE]; + unsigned int *ptr = (unsigned int *)buffer; int fh; if (eax != NULL) { @@ -190,10 +191,10 @@ void cpuid(unsigned int CPU_number, unsigned long long idx, perror(cpuname); exit(EXIT_FAILURE); } - if (eax!=0) *eax = (*(unsigned *)(buffer )); - if (ebx!=0) *ebx = (*(unsigned *)(buffer+ 4)); - if (ecx!=0) *ecx = (*(unsigned *)(buffer+ 8)); - if (edx!=0) *edx = (*(unsigned *)(buffer+12)); + if (eax!=0) *eax = *(ptr)++; + if (ebx!=0) *ebx = *(ptr)++; + if (ecx!=0) *ecx = *(ptr)++; + if (edx!=0) *edx = *(ptr); if (close(fh) == -1) { perror("close"); exit(EXIT_FAILURE); @@ -73,6 +73,7 @@ int read_msr(int cpu, unsigned int idx, unsigned long long *val) unsigned long lo, hi; int fh; static int nodriver=0; + unsigned long *ptr = (unsigned long *) buffer; if (nodriver==1) return 0; @@ -100,8 +101,8 @@ int read_msr(int cpu, unsigned int idx, unsigned long long *val) return 0; } - lo = (*(unsigned long *)buffer); - hi = (*(unsigned long *)(buffer+4)); + lo = *(ptr)++; + hi = *(ptr); *val = hi; *val = (*val<<32) | lo; } @@ -169,7 +169,7 @@ int main (int argc, char **argv) parse_command_line(argc, argv); - printf("x86info v1.28. Dave Jones 2001-2011\n"); + printf("x86info v1.29beta. Dave Jones 2001-2011\n"); printf("Feedback to <davej@redhat.com>.\n\n"); if ((HaveCPUID()) == 0) { |