Fixing more warnings (Paul Stoffregen).

This commit is contained in:
David A. Mellis 2011-10-10 11:28:44 -04:00
parent 965480f148
commit ca671fdc05
10 changed files with 19 additions and 18 deletions

View File

@ -91,7 +91,7 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
#if !defined(USART_RX_vect) && !defined(SIG_USART0_RECV) && \ #if !defined(USART_RX_vect) && !defined(SIG_USART0_RECV) && \
!defined(SIG_UART0_RECV) && !defined(USART0_RX_vect) && \ !defined(SIG_UART0_RECV) && !defined(USART0_RX_vect) && \
!defined(SIG_UART_RECV) !defined(SIG_UART_RECV)
#error Don't know what the Data Received vector is called for the first UART #error "Don't know what the Data Received vector is called for the first UART"
#else #else
void serialEvent() __attribute__((weak)); void serialEvent() __attribute__((weak));
void serialEvent() {} void serialEvent() {}
@ -180,7 +180,7 @@ void serialEventRun(void)
// do nothing - on the 32u4 the first USART is USART1 // do nothing - on the 32u4 the first USART is USART1
#else #else
#if !defined(UART0_UDRE_vect) && !defined(UART_UDRE_vect) && !defined(USART0_UDRE_vect) && !defined(USART_UDRE_vect) #if !defined(UART0_UDRE_vect) && !defined(UART_UDRE_vect) && !defined(USART0_UDRE_vect) && !defined(USART_UDRE_vect)
#error Don't know what the Data Register Empty vector is called for the first UART #error "Don't know what the Data Register Empty vector is called for the first UART"
#else #else
#if defined(UART0_UDRE_vect) #if defined(UART0_UDRE_vect)
ISR(UART0_UDRE_vect) ISR(UART0_UDRE_vect)

View File

@ -54,7 +54,7 @@ size_t Print::print(const __FlashStringHelper *ifsh)
size_t Print::print(const String &s) size_t Print::print(const String &s)
{ {
size_t n = 0; size_t n = 0;
for (int i = 0; i < s.length(); i++) { for (uint16_t i = 0; i < s.length(); i++) {
n += write(s[i]); n += write(s[i]);
} }
return n; return n;

View File

@ -498,7 +498,7 @@ int String::lastIndexOf( char theChar ) const
return lastIndexOf(theChar, len - 1); return lastIndexOf(theChar, len - 1);
} }
int String::lastIndexOf(char ch, int fromIndex) const int String::lastIndexOf(char ch, unsigned int fromIndex) const
{ {
if (fromIndex >= len || fromIndex < 0) return -1; if (fromIndex >= len || fromIndex < 0) return -1;
char tempchar = buffer[fromIndex + 1]; char tempchar = buffer[fromIndex + 1];
@ -514,7 +514,7 @@ int String::lastIndexOf(const String &s2) const
return lastIndexOf(s2, len - s2.len); return lastIndexOf(s2, len - s2.len);
} }
int String::lastIndexOf(const String &s2, int fromIndex) const int String::lastIndexOf(const String &s2, unsigned int fromIndex) const
{ {
if (s2.len == 0 || len == 0 || s2.len > len || fromIndex < 0) return -1; if (s2.len == 0 || len == 0 || s2.len > len || fromIndex < 0) return -1;
if (fromIndex >= len) fromIndex = len - 1; if (fromIndex >= len) fromIndex = len - 1;
@ -522,7 +522,7 @@ int String::lastIndexOf(const String &s2, int fromIndex) const
for (char *p = buffer; p <= buffer + fromIndex; p++) { for (char *p = buffer; p <= buffer + fromIndex; p++) {
p = strstr(p, s2.buffer); p = strstr(p, s2.buffer);
if (!p) break; if (!p) break;
if (p - buffer <= fromIndex) found = p - buffer; if ((unsigned int)(p - buffer) <= fromIndex) found = p - buffer;
} }
return found; return found;
} }

View File

@ -154,9 +154,9 @@ public:
int indexOf( const String &str ) const; int indexOf( const String &str ) const;
int indexOf( const String &str, unsigned int fromIndex ) const; int indexOf( const String &str, unsigned int fromIndex ) const;
int lastIndexOf( char ch ) const; int lastIndexOf( char ch ) const;
int lastIndexOf( char ch, int fromIndex ) const; int lastIndexOf( char ch, unsigned int fromIndex ) const;
int lastIndexOf( const String &str ) const; int lastIndexOf( const String &str ) const;
int lastIndexOf( const String &str, int fromIndex ) const; int lastIndexOf( const String &str, unsigned int fromIndex ) const;
String substring( unsigned int beginIndex ) const; String substring( unsigned int beginIndex ) const;
String substring( unsigned int beginIndex, unsigned int endIndex ) const; String substring( unsigned int beginIndex, unsigned int endIndex ) const;

View File

@ -27,7 +27,6 @@
#include <avr/io.h> #include <avr/io.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include <avr/delay.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>

View File

@ -18,7 +18,7 @@
uint8_t nfilecount=0; uint8_t nfilecount=0;
*/ */
File::File(SdFile f, char *n) { File::File(SdFile f, const char *n) {
// oh man you are kidding me, new() doesnt exist? Ok we do it by hand! // oh man you are kidding me, new() doesnt exist? Ok we do it by hand!
_file = (SdFile *)malloc(sizeof(SdFile)); _file = (SdFile *)malloc(sizeof(SdFile));
if (_file) { if (_file) {

View File

@ -348,7 +348,7 @@ boolean SDClass::begin(uint8_t csPin) {
// this little helper is used to traverse paths // this little helper is used to traverse paths
SdFile SDClass::getParentDir(char *filepath, int *index) { SdFile SDClass::getParentDir(const char *filepath, int *index) {
// get parent directory // get parent directory
SdFile d1 = root; // start with the mostparent, root! SdFile d1 = root; // start with the mostparent, root!
SdFile d2; SdFile d2;
@ -357,7 +357,7 @@ SdFile SDClass::getParentDir(char *filepath, int *index) {
SdFile *parent = &d1; SdFile *parent = &d1;
SdFile *subdir = &d2; SdFile *subdir = &d2;
char *origpath = filepath; const char *origpath = filepath;
while (strchr(filepath, '/')) { while (strchr(filepath, '/')) {
@ -404,7 +404,7 @@ SdFile SDClass::getParentDir(char *filepath, int *index) {
} }
File SDClass::open(char *filepath, uint8_t mode) { File SDClass::open(const char *filepath, uint8_t mode) {
/* /*
Open the supplied file path for reading or writing. Open the supplied file path for reading or writing.

View File

@ -29,7 +29,7 @@ class File : public Stream {
SdFile *_file; // underlying file pointer SdFile *_file; // underlying file pointer
public: public:
File(SdFile f, char *name); // wraps an underlying SdFile File(SdFile f, const char *name); // wraps an underlying SdFile
File(void); // 'empty' constructor File(void); // 'empty' constructor
~File(void); // destructor ~File(void); // destructor
virtual size_t write(uint8_t); virtual size_t write(uint8_t);
@ -62,7 +62,7 @@ private:
SdFile root; SdFile root;
// my quick&dirty iterator, should be replaced // my quick&dirty iterator, should be replaced
SdFile getParentDir(char *filepath, int *indx); SdFile getParentDir(const char *filepath, int *indx);
public: public:
// This needs to be called to set up the connection to the SD card // This needs to be called to set up the connection to the SD card
// before other methods are used. // before other methods are used.
@ -71,7 +71,7 @@ public:
// Open the specified file/directory with the supplied mode (e.g. read or // Open the specified file/directory with the supplied mode (e.g. read or
// write, etc). Returns a File object for interacting with the file. // write, etc). Returns a File object for interacting with the file.
// Note that currently only one file can be open at a time. // Note that currently only one file can be open at a time.
File open(char *filename, uint8_t mode = FILE_READ); File open(const char *filename, uint8_t mode = FILE_READ);
// Methods to determine if the requested file path exists. // Methods to determine if the requested file path exists.
boolean exists(char *filepath); boolean exists(char *filepath);

View File

@ -30,10 +30,11 @@
/** Store and print a string in flash memory followed by a CR/LF.*/ /** Store and print a string in flash memory followed by a CR/LF.*/
#define PgmPrintln(x) SerialPrintln_P(PSTR(x)) #define PgmPrintln(x) SerialPrintln_P(PSTR(x))
/** Defined so doxygen works for function definitions. */ /** Defined so doxygen works for function definitions. */
#define NOINLINE __attribute__((noinline)) #define NOINLINE __attribute__((noinline,unused))
#define UNUSEDOK __attribute__((unused))
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** Return the number of bytes currently free in RAM. */ /** Return the number of bytes currently free in RAM. */
static int FreeRam(void) { static UNUSEDOK int FreeRam(void) {
extern int __bss_end; extern int __bss_end;
extern int* __brkval; extern int* __brkval;
int free_memory; int free_memory;

View File

@ -23,6 +23,7 @@
#include <avr/io.h> #include <avr/io.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include <compat/twi.h> #include <compat/twi.h>
#include "Arduino.h" // for digitalWrite
#ifndef cbi #ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))