Fix compile time issues
[collectd.git] / src / barometer.c
index 17c2a1a..fd733b4 100644 (file)
 
 #include "collectd.h"
 
-#include "common.h"
 #include "plugin.h"
+#include "utils/common/common.h"
 #include "utils_cache.h"
 
 #include <fcntl.h>
 #include <linux/i2c-dev.h>
+#if HAVE_I2C_SMBUS_H
+#include <i2c/smbus.h>
+#endif
 #include <math.h>
 #include <stdint.h>
 #include <sys/ioctl.h>
@@ -180,11 +183,11 @@ static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
 static char *config_device;       /**< I2C bus device */
 static int config_oversample = 1; /**< averaging window */
 
-static double config_press_offset = 0.0; /**< pressure offset */
-static double config_temp_offset = 0.0;  /**< temperature offset */
+static double config_press_offset; /**< pressure offset */
+static double config_temp_offset;  /**< temperature offset */
 
 static double config_altitude = NAN; /**< altitude */
-static int config_normalize = 0;     /**< normalization method */
+static int config_normalize;         /**< normalization method */
 
 static bool configured; /**< the whole plugin config status */
 
@@ -193,7 +196,7 @@ static int i2c_bus_fd = -1; /**< I2C bus device FD */
 static enum Sensor_type sensor_type =
     Sensor_none; /**< detected/used sensor type */
 
-static __s32 mpl3115_oversample = 0; /**< MPL3115 CTRL1 oversample setting */
+static __s32 mpl3115_oversample; /**< MPL3115 CTRL1 oversample setting */
 
 // BMP085 configuration
 static unsigned bmp085_oversampling; /**< BMP085 oversampling (0-3) */
@@ -249,7 +252,7 @@ static averaging_t temperature_averaging;
  * @return Zero when successful
  */
 static int averaging_create(averaging_t *avg, int size) {
-  avg->ring_buffer = calloc((size_t)size, sizeof(*avg->ring_buffer));
+  avg->ring_buffer = calloc(size, sizeof(*avg->ring_buffer));
   if (avg->ring_buffer == NULL) {
     ERROR("barometer: averaging_create - ring buffer allocation of size %d "
           "failed",
@@ -1306,8 +1309,8 @@ static int collectd_barometer_config(const char *key, const char *value) {
   } else if (strcasecmp(key, "Normalization") == 0) {
     int normalize_tmp = atoi(value);
     if (normalize_tmp < 0 || normalize_tmp > 2) {
-      WARNING("barometer: collectd_barometer_config: invalid normalization: %d",
-              normalize_tmp);
+      ERROR("barometer: collectd_barometer_config: invalid normalization: %d",
+            normalize_tmp);
       return 1;
     }
     config_normalize = normalize_tmp;