[Cocci] Re: problems with typecasts
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Thu Mar 5 16:25:50 CET 2009
And another followup...
The codebase I'm working on can be downloaded with subversion:
svn co svn://coreboot.org/repos/trunk/util/flashrom
cd flashrom
make
There should be no warnings during compilation.
flashrom is a tool to reflash your BIOS flash chip, so reading the man
page is recommended if you intend to run it as root.
The following source patch is required if you want to test compilation
with any of the semantic patches I posted.
Index: flash.h
===================================================================
--- flash.h (Revision 3970)
+++ flash.h (Arbeitskopie)
@@ -58,6 +58,36 @@
#define INL inl
#endif
+static inline void writeb(uint8_t b, volatile void *addr)
+{
+ *(volatile uint8_t *) addr = b;
+}
+
+static inline void writew(uint16_t b, volatile void *addr)
+{
+ *(volatile uint16_t *) addr = b;
+}
+
+static inline void writel(uint32_t b, volatile void *addr)
+{
+ *(volatile uint32_t *) addr = b;
+}
+
+static inline uint8_t readb(const volatile void *addr)
+{
+ return *(volatile uint8_t *) addr;
+}
+
+static inline uint16_t readw(const volatile void *addr)
+{
+ return *(volatile uint16_t *) addr;
+}
+
+static inline uint32_t readl(const volatile void *addr)
+{
+ return *(volatile uint32_t *) addr;
+}
+
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
struct flashchip {
Regards,
Carl-Daniel
More information about the Cocci
mailing list