From 4ebb6ec7b18eac17df94506ae7fe3fbff8516a2a Mon Sep 17 00:00:00 2001 From: Dan Church <amphetamachine@gmail.com> Date: Fri, 10 Mar 2017 21:17:22 -0600 Subject: [PATCH] Fix compiler warnings Fix the following warnings, seen when compiling with GCC 5.4: CXX OLEDDisplay.o ./OLEDDisplay.cpp: In member function 'void OLEDDisplay::drawStringInternal(int16_t, int16_t, char*, uint16_t, uint16_t)': ./OLEDDisplay.cpp:381:10: error: enumeration value 'TEXT_ALIGN_LEFT' not handled in switch [-Werror=switch] switch (textAlignment) { ^ ./OLEDDisplay.cpp: In member function 'void OLEDDisplay::drawInternal(int16_t, int16_t, int16_t, int16_t, const char*, uint16_t, uint16_t)': ./OLEDDisplay.cpp:722:13: warning: unused variable 'yScreenPos' [-Wunused-variable] int16_t yScreenPos = yMove + yOffset; ^ ./OLEDDisplay.cpp: In member function 'void OLEDDisplay::drawXbm(int16_t, int16_t, int16_t, int16_t, const char*)': ./OLEDDisplay.cpp:361:19: error: 'data' may be used uninitialized in this function [-Werror=maybe-uninitialized] data >>= 1; // Move a bit ^ cc1plus: some warnings being treated as errors --- OLEDDisplay.cpp | 4 +++- OLEDDisplay.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/OLEDDisplay.cpp b/OLEDDisplay.cpp index f8fc226..df38b3b 100644 --- a/OLEDDisplay.cpp +++ b/OLEDDisplay.cpp @@ -353,7 +353,7 @@ void OLEDDisplay::drawFastImage(int16_t xMove, int16_t yMove, int16_t width, int void OLEDDisplay::drawXbm(int16_t xMove, int16_t yMove, int16_t width, int16_t height, const char *xbm) { int16_t widthInXbm = (width + 7) / 8; - uint8_t data; + uint8_t data = 0; for(int16_t y = 0; y < height; y++) { for(int16_t x = 0; x < width; x++ ) { @@ -388,6 +388,8 @@ void OLEDDisplay::drawStringInternal(int16_t xMove, int16_t yMove, char* text, u case TEXT_ALIGN_RIGHT: xMove -= textWidth; break; + case TEXT_ALIGN_LEFT: + break; } // Don't draw anything if it is not on the screen. diff --git a/OLEDDisplay.h b/OLEDDisplay.h index 81537a2..e01f4bb 100644 --- a/OLEDDisplay.h +++ b/OLEDDisplay.h @@ -250,7 +250,7 @@ class OLEDDisplay : public Print { virtual void sendCommand(uint8_t com) {}; // Connect to the display - virtual bool connect() {}; + virtual bool connect() {return true;}; // Send all the init commands void sendInitCommands(); -- GitLab