projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1646 from rubenk/cleanup-malloc-calls
[collectd.git]
/
src
/
sensors.c
diff --git
a/src/sensors.c
b/src/sensors.c
index
209482e
..
6125d0b
100644
(file)
--- a/
src/sensors.c
+++ b/
src/sensors.c
@@
-17,7
+17,7
@@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at
verplant
.org>
+ * Florian octo Forster <octo at
collectd
.org>
*
* Lubos Stanek <lubek at users.sourceforge.net> Wed Oct 27, 2006
* - config ExtendedSensorNaming option
*
* Lubos Stanek <lubek at users.sourceforge.net> Wed Oct 27, 2006
* - config ExtendedSensorNaming option
@@
-62,7
+62,9
@@
static char *sensor_type_name_map[] =
"fanspeed",
# define SENSOR_TYPE_TEMPERATURE 2
"temperature",
"fanspeed",
# define SENSOR_TYPE_TEMPERATURE 2
"temperature",
-# define SENSOR_TYPE_UNKNOWN 3
+# define SENSOR_TYPE_POWER 3
+ "power",
+# define SENSOR_TYPE_UNKNOWN 4
NULL
};
NULL
};
@@
-127,7
+129,8
@@
static sensors_labeltypes_t known_features[] =
{ "3.3V", SENSOR_TYPE_VOLTAGE },
{ "2.5V", SENSOR_TYPE_VOLTAGE },
{ "2.0V", SENSOR_TYPE_VOLTAGE },
{ "3.3V", SENSOR_TYPE_VOLTAGE },
{ "2.5V", SENSOR_TYPE_VOLTAGE },
{ "2.0V", SENSOR_TYPE_VOLTAGE },
- { "12V", SENSOR_TYPE_VOLTAGE }
+ { "12V", SENSOR_TYPE_VOLTAGE },
+ { "power1", SENSOR_TYPE_POWER }
};
static int known_features_num = STATIC_ARRAY_SIZE (known_features);
/* end new naming */
};
static int known_features_num = STATIC_ARRAY_SIZE (known_features);
/* end new naming */
@@
-173,7
+176,7
@@
static char *conffile = NULL;
"as bug."
#endif
"as bug."
#endif
-featurelist_t *first_feature = NULL;
+
static
featurelist_t *first_feature = NULL;
static ignorelist_t *sensor_list;
#if SENSORS_API_VERSION < 0x400
static ignorelist_t *sensor_list;
#if SENSORS_API_VERSION < 0x400
@@
-262,7
+265,7
@@
static int sensors_config (const char *key, const char *value)
return (0);
}
return (0);
}
-void sensors_free_features (void)
+
static
void sensors_free_features (void)
{
featurelist_t *thisft;
featurelist_t *nextft;
{
featurelist_t *thisft;
featurelist_t *nextft;
@@
-375,13
+378,12
@@
static int sensors_load_conf (void)
continue;
}
continue;
}
- fl =
(featurelist_t *) malloc (sizeof (featurelist_t
));
+ fl =
calloc (1, sizeof (*fl
));
if (fl == NULL)
{
if (fl == NULL)
{
- ERROR ("sensors plugin:
m
alloc failed.");
+ ERROR ("sensors plugin:
c
alloc failed.");
continue;
}
continue;
}
- memset (fl, '\0', sizeof (featurelist_t));
fl->chip = chip;
fl->data = feature;
fl->chip = chip;
fl->data = feature;
@@
-411,7
+413,8
@@
static int sensors_load_conf (void)
/* Only handle voltage, fanspeeds and temperatures */
if ((feature->type != SENSORS_FEATURE_IN)
&& (feature->type != SENSORS_FEATURE_FAN)
/* Only handle voltage, fanspeeds and temperatures */
if ((feature->type != SENSORS_FEATURE_IN)
&& (feature->type != SENSORS_FEATURE_FAN)
- && (feature->type != SENSORS_FEATURE_TEMP))
+ && (feature->type != SENSORS_FEATURE_TEMP)
+ && (feature->type != SENSORS_FEATURE_POWER))
{
DEBUG ("sensors plugin: sensors_load_conf: "
"Ignoring feature `%s', "
{
DEBUG ("sensors plugin: sensors_load_conf: "
"Ignoring feature `%s', "
@@
-427,16
+430,16
@@
static int sensors_load_conf (void)
if ((subfeature->type != SENSORS_SUBFEATURE_IN_INPUT)
&& (subfeature->type != SENSORS_SUBFEATURE_FAN_INPUT)
if ((subfeature->type != SENSORS_SUBFEATURE_IN_INPUT)
&& (subfeature->type != SENSORS_SUBFEATURE_FAN_INPUT)
- && (subfeature->type != SENSORS_SUBFEATURE_TEMP_INPUT))
+ && (subfeature->type != SENSORS_SUBFEATURE_TEMP_INPUT)
+ && (subfeature->type != SENSORS_SUBFEATURE_POWER_INPUT))
continue;
continue;
- fl =
(featurelist_t *) malloc (sizeof (featurelist_t
));
+ fl =
calloc (1, sizeof (*fl
));
if (fl == NULL)
{
if (fl == NULL)
{
- ERROR ("sensors plugin:
m
alloc failed.");
+ ERROR ("sensors plugin:
c
alloc failed.");
continue;
}
continue;
}
- memset (fl, '\0', sizeof (featurelist_t));
fl->chip = chip;
fl->feature = feature;
fl->chip = chip;
fl->feature = feature;
@@
-573,6
+576,9
@@
static int sensors_read (void)
else if (fl->feature->type
== SENSORS_FEATURE_TEMP)
type = "temperature";
else if (fl->feature->type
== SENSORS_FEATURE_TEMP)
type = "temperature";
+ else if (fl->feature->type
+ == SENSORS_FEATURE_POWER)
+ type = "power";
else
continue;
else
continue;