[Rpcemu] Patch: Silence fpa.c:30 Warning by Removing Code.
ralph at inputplus.co.uk
Sat May 29 14:59:56 PDT 2010
Compilation currently produces
fpa.c: In function âresetfpaâ:
fpa.c:30: warning: dereferencing type-punned pointer will break
The patch below stops that warning. I think the code is attempting to
store a float in memory and then read that memory (plus possibly a bit
more depending on the size of a float and a double) back, treating it as
double. It then prints the float and what was read back as a double.
But I think the code is buggy and has never been doing that. Instead,
it stores 0.12f at temp through the float *tfs, then loads a float from
memory, through the tfs pointer again, before casting that float to a
double and assigning it to tf. All that's being tested here is the
compiler casting a float to a double. To work as intended, perhaps
tf = *(double *)temp;
would have been better. Although that was still generate a warning
because it isn't legal in C99 to use casts to treat memory as holding a
float and a double.
So, given the code does nothing useful AFAICS, I've removed those bits.
diff -r 02cb887ed259 src/fpa.c
--- a/src/fpa.c Sat May 29 14:15:29 2010 +0100
+++ b/src/fpa.c Sat May 29 22:54:22 2010 +0100
@@ -24,13 +24,9 @@ static void dumpfpa(void)
- uint32_t temp;
- float *tfs;
- double tf;
- tfs=(float *)temp;
- rpclog("Double size %i Float size %i %f %f\n",sizeof(double),sizeof(float),*tfs,tf);
+ rpclog("Double size %i Float size %i\n", sizeof (double),
+ sizeof (float));
fpsr=0x81000000; /*FPA system*/
More information about the Rpcemu