summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-06-10 02:26:15 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-06-10 02:26:15 +0000
commit5f4d687cb9879654c147f48f195b5e0177c480f1 (patch)
tree9565ba319e4c326d15cdcf34bcd26212f23680f2
parent0ae6f70fddea4abfc94f5a1929748f681ef22ee1 (diff)
downloadrockbox-5f4d687cb9879654c147f48f195b5e0177c480f1.tar.gz
rockbox-5f4d687cb9879654c147f48f195b5e0177c480f1.zip
rockboy: use unions instead of type-punning
avoid a warning when using -Os git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26734 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/rockboy/save.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/apps/plugins/rockboy/save.c b/apps/plugins/rockboy/save.c
index 4211ceb77f..817973bcb2 100644
--- a/apps/plugins/rockboy/save.c
+++ b/apps/plugins/rockboy/save.c
@@ -16,17 +16,21 @@
16#define LIL(x) ((x<<24)|((x&0xff00)<<8)|((x>>8)&0xff00)|(x>>24)) 16#define LIL(x) ((x<<24)|((x&0xff00)<<8)|((x>>8)&0xff00)|(x>>24))
17#endif 17#endif
18 18
19#define I1(s, p) { 1, s, p } 19#define I1(s, p) { 1, { s }, p }
20#define I2(s, p) { 2, s, p } 20#define I2(s, p) { 2, { s }, p }
21#define I4(s, p) { 4, s, p } 21#define I4(s, p) { 4, { s }, p }
22#define R(r) I1(#r, &R_##r) 22#define R(r) I1(#r, &R_##r)
23#define NOSAVE { -1, "\0\0\0\0", 0 } 23#define NOSAVE { -1, { "\0\0\0\0" }, 0 }
24#define END { 0, "\0\0\0\0", 0 } 24#define END { 0, { "\0\0\0\0" }, 0 }
25 25
26struct svar 26struct svar
27{ 27{
28 int len; 28 int len;
29 char key[4]; 29 union
30 {
31 char key_[4];
32 un32 key;
33 } k;
30 void *ptr; 34 void *ptr;
31}; 35};
32 36
@@ -176,7 +180,7 @@ void loadstate(int fd)
176 { 180 {
177 for (i = 0; svars[i].ptr; i++) 181 for (i = 0; svars[i].ptr; i++)
178 { 182 {
179 if (header[j][0] != *(un32 *)svars[i].key) 183 if (header[j][0] != svars[i].k.key)
180 continue; 184 continue;
181 d = LIL(header[j][1]); 185 d = LIL(header[j][1]);
182 switch (svars[i].len) 186 switch (svars[i].len)
@@ -239,7 +243,7 @@ void savestate(int fd)
239 243
240 for (i = 0; svars[i].len > 0; i++) 244 for (i = 0; svars[i].len > 0; i++)
241 { 245 {
242 header[i][0] = *(un32 *)svars[i].key; 246 header[i][0] = svars[i].k.key;
243 switch (svars[i].len) 247 switch (svars[i].len)
244 { 248 {
245 case 1: 249 case 1: