Werror: Enable warnings as errors

Added C/CXX warning messages similar to MRAA (w/ -Werror).

    * Added syslog warning for missing switch cases
    * Cleaned up uint vs int usage
    * Fixed redifinition errors for C structs
    * Added virtual destructors for base classes
    * Removed redundant CMAKE_CXX_FLAGS from COMPILE_FLAGS for all three
      wrapper languages.  The CMAKE_CXX_FLAGS were showing up twice in
      the compile commands for the wrappers.
    * Added CMake WERROR option to enable/disable warnings as errors for
      all targets.
    * Disable a handful of compiler warnings for the wrapper cxx files,
      this minimizes the number of warnings from auto-generated code).

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck
2016-10-13 12:18:52 -07:00
parent 58dfa9d95a
commit 6be7012987
26 changed files with 185 additions and 40 deletions

View File

@ -37,11 +37,11 @@
// an internal struct we use to store information on the devices
// found during initialization
typedef struct _ds18b20_info_t {
struct _ds18b20_info_t {
uint8_t id[ROMCODE_SIZE]; // 8-byte romcode id
float temperature;
DS18B20_RESOLUTIONS_T resolution;
} ds18b20_info_t;
};
// internal utility function forward to read temperature from a single
// device
@ -121,7 +121,7 @@ ds18b20_context ds18b20_init(unsigned int uart)
if (!dsPtr)
{
printf("%s: realloc(%d) failed\n",
printf("%s: realloc(%zu) failed\n",
__FUNCTION__,
sizeof(ds18b20_info_t) * (dev->numDevices + 1));
ds18b20_close(dev);

View File

@ -25,6 +25,7 @@
#include <iostream>
#include <time.h>
#include <stdexcept>
#include <syslog.h>
#include "ds18b20.hpp"
@ -214,6 +215,9 @@ float DS18B20::readSingleTemp(int index)
case RESOLUTION_9BITS: frac &= 0x08; break;
case RESOLUTION_10BITS: frac &= 0x0c; break;
case RESOLUTION_11BITS: frac &= 0x0e; break;
default:
syslog(LOG_WARNING, "%s: switch case not defined",
std::string(__FUNCTION__).c_str());
}
// remove the fractional with extreme prejudice