Hi
The following is a trivial routine. Function: Using the SSI controller, write a byte of data (dat) into the SSI (Synchronous Serial Interface)(Luminary LM3S9B96) Tx register(actually a FIFO) and flush the Rx register(also a FIFO) by reading it. Works fine no problem... but the compliler (correctley) says:
Fatfs\port\fm_mmc.c(65): warning: #550-D: variable "rcvdat" was set but never used.
Any ideas on how to keep the code tight (can't see how you can make it tighter... - using direct pointers to the registers) and - stop it complaining?
#define HWREGB(x) (*((volatile unsigned char *)(x))) #define HWREG(x) (*((volatile unsigned long *)(x))) #define SSI0_BASE 0x40008000 // SSI0 // etc void XmitSsi (unsigned char dat) { unsigned char rcvdat; // Write dat // Wait until there is space. while(!(HWREG(SSI0_BASE + SSI_O_SR) & SSI_SR_TNF)){} // Write to the SSI. HWREGB(SSI0_BASE + SSI_O_DR) = dat; // Flush Recieve FIFO // Wait until there is data to be read. while(!(HWREG(SSI0_BASE + SSI_O_SR) & SSI_SR_RNE)){} // Read data from SSI. rcvdat = HWREGB(SSI0_BASE + SSI_O_DR); }
The (void) isn't needed for the code.
It's there as some form of "contract": Me (the developer) promises that I understand that the called function returns a value, but I do not want to keep that result.
Adding the (void) means that static code analyzers will not generate a warning about an unused return value. But the code will work (and the compiler itself) should not warn if you don't have any (void).