[coreboot] Patch set updated for coreboot: 99271c9 Fix warnings in coreboot utilities.
Stefan Reinauer (stefan.reinauer@coreboot.org)
gerrit at coreboot.org
Fri Mar 9 17:02:28 CET 2012
Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/752
-gerrit
commit 99271c901598c2e9e397664bc2bc000263653597
Author: Stefan Reinauer <reinauer at chromium.org>
Date: Mon Nov 14 12:40:34 2011 -0800
Fix warnings in coreboot utilities.
Fix some poor programming practice (breaks of strict aliasing as well as not
checking the return value of read)
Change-Id: I08b2e8d1bbc908f6b1f26d25cb3a4b03d818e124
Signed-off-by: Stefan Reinauer <reinauer at google.com>
---
util/inteltool/cpu.c | 6 ++++--
util/inteltool/inteltool.c | 4 +++-
util/nvramtool/cli/nvramtool.c | 3 ++-
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/util/inteltool/cpu.c b/util/inteltool/cpu.c
index 20748bd..3bffa4e 100644
--- a/util/inteltool/cpu.c
+++ b/util/inteltool/cpu.c
@@ -67,8 +67,10 @@ msr_t rdmsr(int addr)
}
if (read(fd_msr, buf, 8) == 8) {
- msr.lo = *(uint32_t *)buf;
- msr.hi = *(uint32_t *)(buf + 4);
+ msr.lo = buf[0] | (buf[1] << 8) |
+ (buf[2] << 16) | (buf[3] << 24);
+ msr.hi = buf[4] | (buf[5] << 8) |
+ (buf[6] << 16) | (buf[7] << 24);
return msr;
}
diff --git a/util/inteltool/inteltool.c b/util/inteltool/inteltool.c
index 6b99605..e5c2b86 100644
--- a/util/inteltool/inteltool.c
+++ b/util/inteltool/inteltool.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <inttypes.h>
#include <getopt.h>
#include <fcntl.h>
#include <sys/mman.h>
@@ -99,7 +100,8 @@ void *map_physical(uint64_t phys_addr, size_t len)
fd_mem, (off_t) phys_addr);
if (virt_addr == MAP_FAILED) {
- printf("Error mapping physical memory 0x%08lx[0x%zx]\n", phys_addr, len);
+ printf("Error mapping physical memory 0x%08" PRIx64 "[0x%zx]\n",
+ phys_addr, len);
return NULL;
}
diff --git a/util/nvramtool/cli/nvramtool.c b/util/nvramtool/cli/nvramtool.c
index 11a1a70..20097b8 100644
--- a/util/nvramtool/cli/nvramtool.c
+++ b/util/nvramtool/cli/nvramtool.c
@@ -143,7 +143,8 @@ int main(int argc, char *argv[])
if (fd_stat.st_size < 128) {
lseek(fd, 127, SEEK_SET);
- write(fd, "\0", 1);
+ if (write(fd, "\0", 1) != 1)
+ fprintf(stderr, "Write failed.\n");
fsync(fd);
}
More information about the coreboot
mailing list