removing warnings discovered by using -Weffc++ flag for gcc

pull/330/head
Rohit Grover 2014-05-26 18:04:46 +01:00
parent 6d53312090
commit f65b7d9077
31 changed files with 113 additions and 74 deletions

View File

@ -51,13 +51,13 @@ public:
* An integer with each bit corresponding to the value read from the associated DigitalIn pin
*/
int read();
/** Set the input pin mode
*
* @param mode PullUp, PullDown, PullNone
*/
void mode(PinMode pull);
#ifdef MBED_OPERATORS
/** A shorthand for read()
*/
@ -66,6 +66,11 @@ public:
protected:
DigitalIn* _pin[16];
/* disallow copy constructor and assignment operators */
private:
BusIn(const BusIn&);
BusIn & operator = (const BusIn&);
};
} // namespace mbed

View File

@ -86,6 +86,11 @@ public:
protected:
DigitalInOut* _pin[16];
/* disallow copy constructor and assignment operators */
private:
BusInOut(const BusInOut&);
BusInOut & operator = (const BusInOut&);
};
} // namespace mbed

View File

@ -69,6 +69,11 @@ public:
protected:
DigitalOut* _pin[16];
/* disallow copy constructor and assignment operators */
private:
BusOut(const BusOut&);
BusOut & operator = (const BusOut&);
};
} // namespace mbed

View File

@ -33,7 +33,7 @@ class CANMessage : public CAN_Message {
public:
/** Creates empty CAN message.
*/
CANMessage() {
CANMessage() : CAN_Message() {
len = 8;
type = CANData;
format = CANStandard;
@ -159,17 +159,17 @@ public:
GlobalTest,
SilentTest
};
/** Change CAN operation to the specified mode
*
* @param mode The new operation mode (CAN::Normal, CAN::Silent, CAN::LocalTest, CAN::GlobalTest, CAN::SilentTest)
*
* @returns
* 0 if mode change failed or unsupported,
* 1 if mode change was successful
* 1 if mode change was successful
*/
int mode(Mode mode);
/** Filter out incomming messages
*
* @param id the id to filter on
@ -182,7 +182,7 @@ public:
* new filter handle if successful
*/
int filter(unsigned int id, unsigned int mask, CANFormat format = CANAny, int handle = 0);
/** Returns number of read errors to detect read overflow errors.
*/
unsigned char rderror();
@ -202,7 +202,7 @@ public:
BeIrq,
IdIrq
};
/** Attach a function to call whenever a CAN frame received interrupt is
* generated.
*

View File

@ -56,7 +56,7 @@ namespace mbed {
* }
* @endcode
*/
typedef FunctionPointer* pFunctionPointer_t;
class CallChain {
@ -64,7 +64,7 @@ public:
/** Create an empty chain
*
* @param size (optional) Initial size of the chain
*/
*/
CallChain(int size = 4);
virtual ~CallChain();
@ -98,7 +98,7 @@ public:
* The function object created for 'function'
*/
pFunctionPointer_t add_front(void (*function)(void));
/** Add a function at the beginning of the chain
*
* @param tptr pointer to the object to call the member function on
@ -150,7 +150,7 @@ public:
/** Call all the functions in the chain in sequence
*/
void call();
#ifdef MBED_OPERATORS
void operator ()(void) {
call();
@ -168,6 +168,11 @@ private:
pFunctionPointer_t* _chain;
int _size;
int _elements;
/* disallow copy constructor and assignment operators */
private:
CallChain(const CallChain&);
CallChain & operator = (const CallChain&);
};
} // namespace mbed

View File

@ -50,7 +50,7 @@ public:
*
* @param pin DigitalIn pin to connect to
*/
DigitalIn(PinName pin) {
DigitalIn(PinName pin) : gpio() {
gpio_init_in(&gpio, pin);
}
@ -59,7 +59,7 @@ public:
* @param pin DigitalIn pin to connect to
* @param mode the initial mode of the pin
*/
DigitalIn(PinName pin, PinMode mode) {
DigitalIn(PinName pin, PinMode mode) : gpio() {
gpio_init_in_ex(&gpio, pin, mode);
}
/** Read the input, represented as 0 or 1 (int)

View File

@ -31,7 +31,7 @@ public:
*
* @param pin DigitalInOut pin to connect to
*/
DigitalInOut(PinName pin) {
DigitalInOut(PinName pin) : gpio() {
gpio_init_in(&gpio, pin);
}
@ -42,7 +42,7 @@ public:
* @param mode the initial mode of the pin
* @param value the initial value of the pin if is an output
*/
DigitalInOut(PinName pin, PinDirection direction, PinMode mode, int value) {
DigitalInOut(PinName pin, PinDirection direction, PinMode mode, int value) : gpio() {
gpio_init_inout(&gpio, pin, direction, mode, value);
}

View File

@ -45,7 +45,7 @@ public:
*
* @param pin DigitalOut pin to connect to
*/
DigitalOut(PinName pin) {
DigitalOut(PinName pin) : gpio() {
gpio_init_out(&gpio, pin);
}
@ -54,7 +54,7 @@ public:
* @param pin DigitalOut pin to connect to
* @param value the initial pin value
*/
DigitalOut(PinName pin, int value){
DigitalOut(PinName pin, int value) : gpio() {
gpio_init_out_ex(&gpio, pin, value);
}

View File

@ -68,6 +68,11 @@ protected:
FileBase *_next;
const char *_name;
PathType _path_type;
/* disallow copy constructor and assignment operators */
private:
FileBase(const FileBase&);
FileBase & operator = (const FileBase&);
};
} // namespace mbed

View File

@ -83,10 +83,10 @@ private:
(o->*m)();
}
void (*_function)(void); // static function pointer - 0 if none attached
void *_object; // object this pointer - 0 if none attached
char _member[16]; // raw member function pointer storage - converted back by registered _membercaller
void (*_membercaller)(void*, char*); // registered membercaller function to convert back and call _member on _object
void (*_function)(void); // static function pointer - 0 if none attached
void *_object; // object this pointer - 0 if none attached
char _member[16]; // raw member function pointer storage - converted back by registered _membercaller
void (*_membercaller)(void*, char*); // registered membercaller function to convert back and call _member on _object
};
} // namespace mbed

View File

@ -92,6 +92,10 @@ public:
*/
virtual int write(int value);
public:
virtual ~SPI() {
}
protected:
spi_t _spi;

View File

@ -59,7 +59,7 @@ public:
protected:
virtual int _getc();
virtual int _putc(int c);
virtual int _putc(int c);
};
} // namespace mbed

View File

@ -106,11 +106,11 @@ public:
/** Generate a break condition on the serial line
*/
void send_break();
#if DEVICE_SERIAL_FC
/** Set the flow control type on the serial port
*
* @param type the flow control type (Disabled, RTS, CTS, RTSCTS)
* @param type the flow control type (Disabled, RTS, CTS, RTSCTS)
* @param flow1 the first flow control pin (RTS for RTS or RTSCTS, CTS for CTS)
* @param flow2 the second flow control pin (CTS for RTSCTS)
*/
@ -121,7 +121,8 @@ public:
protected:
SerialBase(PinName tx, PinName rx);
virtual ~SerialBase();
int _base_getc();
int _base_putc(int c);

View File

@ -49,6 +49,11 @@ protected:
virtual int _getc() = 0;
std::FILE *_file;
/* disallow copy constructor and assignment operators */
private:
Stream(const Stream&);
Stream & operator = (const Stream&);
};
} // namespace mbed

View File

@ -41,6 +41,9 @@ struct CAN_Message {
unsigned char len; // Length of data field in bytes
CANFormat format; // 0 - STANDARD, 1- EXTENDED IDENTIFIER
CANType type; // 0 - DATA FRAME, 1 - REMOTE FRAME
virtual ~CAN_Message() {
}
};
typedef struct CAN_Message CAN_Message;

View File

@ -21,7 +21,7 @@
namespace mbed {
CAN::CAN(PinName rd, PinName td) {
CAN::CAN(PinName rd, PinName td) : _can(), _irq() {
can_init(&_can, rd, td);
can_irq_init(&_can, (&CAN::_irq_handler), (uint32_t)this);
}

View File

@ -3,13 +3,13 @@
namespace mbed {
CallChain::CallChain(int size) : _size(size), _elements(0) {
CallChain::CallChain(int size) : _chain(), _size(size), _elements(0) {
_chain = new pFunctionPointer_t[size]();
}
CallChain::~CallChain() {
clear();
delete _chain;
delete _chain;
}
pFunctionPointer_t CallChain::add(void (*function)(void)) {

View File

@ -19,10 +19,9 @@ namespace mbed {
FileBase *FileBase::_head = NULL;
FileBase::FileBase(const char *name, PathType t) {
_name = name;
_path_type = t;
FileBase::FileBase(const char *name, PathType t) : _next(NULL),
_name(name),
_path_type(t) {
if (name != NULL) {
// put this object at head of the list
_next = _head;

View File

@ -29,8 +29,7 @@ public:
off_t n;
struct dirent cur_entry;
BaseDirHandle() {
n = 0;
BaseDirHandle() : n(0), cur_entry() {
}
virtual int closedir() {

View File

@ -17,7 +17,9 @@
namespace mbed {
FunctionPointer::FunctionPointer(void (*function)(void)) {
FunctionPointer::FunctionPointer(void (*function)(void)): _function(),
_object(),
_membercaller() {
attach(function);
}

View File

@ -21,10 +21,9 @@ namespace mbed {
I2C *I2C::_owner = NULL;
I2C::I2C(PinName sda, PinName scl) {
I2C::I2C(PinName sda, PinName scl) : _i2c(), _hz(100000) {
// The init function also set the frequency to 100000
i2c_init(&_i2c, sda, scl);
_hz = 100000;
// Used to avoid unnecessary frequency updates
_owner = this;

View File

@ -19,7 +19,7 @@
namespace mbed {
I2CSlave::I2CSlave(PinName sda, PinName scl) {
I2CSlave::I2CSlave(PinName sda, PinName scl) : _i2c() {
i2c_init(&_i2c, sda, scl);
i2c_frequency(&_i2c, 100000);
i2c_slave_mode(&_i2c, 1);

View File

@ -19,7 +19,10 @@
namespace mbed {
InterruptIn::InterruptIn(PinName pin) {
InterruptIn::InterruptIn(PinName pin) : gpio(),
gpio_irq(),
_rise(),
_fall() {
gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this);
gpio_init_in(&gpio, pin);
}

View File

@ -107,9 +107,7 @@ FILEHANDLE local_file_open(const char* name, int flags) {
return fh;
}
LocalFileHandle::LocalFileHandle(FILEHANDLE fh) {
_fh = fh;
pos = 0;
LocalFileHandle::LocalFileHandle(FILEHANDLE fh) : _fh(fh), pos(0) {
}
int LocalFileHandle::close() {
@ -163,8 +161,7 @@ public:
struct dirent cur_entry;
XFINFO info;
LocalDirHandle() {
info.fileID = 0;
LocalDirHandle() : cur_entry(), info() {
}
virtual int closedir() {

View File

@ -19,11 +19,12 @@
namespace mbed {
SPI::SPI(PinName mosi, PinName miso, PinName sclk, PinName _unused) {
SPI::SPI(PinName mosi, PinName miso, PinName sclk, PinName _unused) :
_spi(),
_bits(8),
_mode(0),
_hz(1000000) {
spi_init(&_spi, mosi, miso, sclk, NC);
_bits = 8;
_mode = 0;
_hz = 1000000;
spi_format(&_spi, _bits, _mode, 0);
spi_frequency(&_spi, _hz);
}

View File

@ -19,11 +19,13 @@
namespace mbed {
SPISlave::SPISlave(PinName mosi, PinName miso, PinName sclk, PinName ssel) {
SPISlave::SPISlave(PinName mosi, PinName miso, PinName sclk, PinName ssel) :
_spi(),
_bits(8),
_mode(0),
_hz(1000000)
{
spi_init(&_spi, mosi, miso, sclk, ssel);
_bits = 8;
_mode = 0;
_hz = 1000000;
spi_format(&_spi, _bits, _mode, 1);
spi_frequency(&_spi, _hz);
}

View File

@ -20,9 +20,8 @@
namespace mbed {
SerialBase::SerialBase(PinName tx, PinName rx) {
SerialBase::SerialBase(PinName tx, PinName rx) : _serial(), _baud(9600) {
serial_init(&_serial, tx, rx);
_baud = 9600;
serial_irq_handler(&_serial, SerialBase::_irq_handler, (uint32_t)this);
}
@ -71,7 +70,7 @@ void SerialBase::send_break() {
// Wait for 1.5 frames before clearing the break condition
// This will have different effects on our platforms, but should
// ensure that we keep the break active for at least one frame.
// We consider a full frame (1 start bit + 8 data bits bits +
// We consider a full frame (1 start bit + 8 data bits bits +
// 1 parity bit + 2 stop bits = 12 bits) for computation.
// One bit time (in us) = 1000000/_baud
// Twelve bits: 12000000/baud delay
@ -88,16 +87,16 @@ void SerialBase::set_flow_control(Flow type, PinName flow1, PinName flow2) {
case RTS:
serial_set_flow_control(&_serial, flow_type, flow1, NC);
break;
case CTS:
serial_set_flow_control(&_serial, flow_type, NC, flow1);
break;
case RTSCTS:
case Disabled:
serial_set_flow_control(&_serial, flow_type, flow1, flow2);
break;
default:
break;
}

View File

@ -19,7 +19,7 @@
namespace mbed {
Stream::Stream(const char *name) : FileLike(name) {
Stream::Stream(const char *name) : FileLike(name), _file(NULL) {
/* open ourselves */
char buf[12]; /* :0x12345678 + null byte */
std::sprintf(buf, ":%p", this);

View File

@ -18,7 +18,7 @@
namespace mbed {
Timer::Timer() {
Timer::Timer() : _running(), _start(), _time() {
reset();
}

View File

@ -20,7 +20,7 @@
namespace mbed {
TimerEvent::TimerEvent() {
TimerEvent::TimerEvent() : event() {
us_ticker_set_handler((&TimerEvent::irq));
}

View File

@ -52,27 +52,27 @@ const int ethernet_MTU_SIZE = 0x300;
#define ETHERNET_ADDR_SIZE 6
PACKED struct RX_DESC_TypeDef { /* RX Descriptor struct */
struct RX_DESC_TypeDef { /* RX Descriptor struct */
unsigned int Packet;
unsigned int Ctrl;
};
} PACKED;
typedef struct RX_DESC_TypeDef RX_DESC_TypeDef;
PACKED struct RX_STAT_TypeDef { /* RX Status struct */
struct RX_STAT_TypeDef { /* RX Status struct */
unsigned int Info;
unsigned int HashCRC;
};
} PACKED;
typedef struct RX_STAT_TypeDef RX_STAT_TypeDef;
PACKED struct TX_DESC_TypeDef { /* TX Descriptor struct */
struct TX_DESC_TypeDef { /* TX Descriptor struct */
unsigned int Packet;
unsigned int Ctrl;
};
} PACKED;
typedef struct TX_DESC_TypeDef TX_DESC_TypeDef;
PACKED struct TX_STAT_TypeDef { /* TX Status struct */
struct TX_STAT_TypeDef { /* TX Status struct */
unsigned int Info;
};
} PACKED;
typedef struct TX_STAT_TypeDef TX_STAT_TypeDef;
/* MAC Configuration Register 1 */
@ -436,9 +436,9 @@ int ethernet_init() {
int regv, tout;
char mac[ETHERNET_ADDR_SIZE];
unsigned int clock = clockselect();
LPC_SC->PCONP |= 0x40000000; /* Power Up the EMAC controller. */
LPC_PINCON->PINSEL2 = 0x50150105; /* Enable P1 Ethernet Pins. */
LPC_PINCON->PINSEL3 = (LPC_PINCON->PINSEL3 & ~0x0000000F) | 0x00000005;
@ -531,9 +531,9 @@ int ethernet_init() {
void ethernet_free() {
LPC_EMAC->IntEnable &= ~(INT_RX_DONE | INT_TX_DONE);
LPC_EMAC->IntClear = 0xFFFF;
LPC_SC->PCONP &= ~0x40000000; /* Power down the EMAC controller. */
LPC_PINCON->PINSEL2 &= ~0x50150105; /* Disable P1 ethernet pins. */
LPC_PINCON->PINSEL3 = (LPC_PINCON->PINSEL3 & ~0x0000000F) | 0x00000000;
}