projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-5.5' into collectd-5.6
[collectd.git]
/
src
/
nut.c
diff --git
a/src/nut.c
b/src/nut.c
index
d5ecc98
..
b5c6b41
100644
(file)
--- a/
src/nut.c
+++ b/
src/nut.c
@@
-25,10
+25,10
@@
**/
#include "collectd.h"
**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "common.h"
#include "plugin.h"
-#include <pthread.h>
#include <upsclient.h>
#if HAVE_UPSCONN_T
#include <upsclient.h>
#if HAVE_UPSCONN_T
@@
-80,13
+80,12
@@
static int nut_add_ups (const char *name)
DEBUG ("nut plugin: nut_add_ups (name = %s);", name);
DEBUG ("nut plugin: nut_add_ups (name = %s);", name);
- ups =
(nut_ups_t *) malloc (sizeof (nut_ups_t
));
+ ups =
calloc (1, sizeof (*ups
));
if (ups == NULL)
{
if (ups == NULL)
{
- ERROR ("nut plugin: nut_add_ups:
m
alloc failed.");
+ ERROR ("nut plugin: nut_add_ups:
c
alloc failed.");
return (1);
}
return (1);
}
- memset (ups, '\0', sizeof (nut_ups_t));
status = upscli_splitname (name, &ups->upsname, &ups->hostname,
&ups->port);
status = upscli_splitname (name, &ups->upsname, &ups->hostname,
&ups->port);
@@
-152,7
+151,7
@@
static int nut_read_one (nut_ups_t *ups)
/* (Re-)Connect if we have no connection */
if (ups->conn == NULL)
{
/* (Re-)Connect if we have no connection */
if (ups->conn == NULL)
{
- ups->conn =
(collectd_upsconn_t *) malloc (sizeof (collectd_upsconn_t
));
+ ups->conn =
malloc (sizeof (*ups->conn
));
if (ups->conn == NULL)
{
ERROR ("nut plugin: malloc failed.");
if (ups->conn == NULL)
{
ERROR ("nut plugin: malloc failed.");
@@
-249,7
+248,6
@@
static int nut_read_one (nut_ups_t *ups)
static int nut_read (void)
{
static int nut_read (void)
{
- nut_ups_t *ups;
int success = 0;
pthread_mutex_lock (&read_lock);
int success = 0;
pthread_mutex_lock (&read_lock);
@@
-260,7
+258,7
@@
static int nut_read (void)
if (success != 0)
return (0);
if (success != 0)
return (0);
- for (ups = upslist_head; ups != NULL; ups = ups->next)
+ for (
nut_ups_t *
ups = upslist_head; ups != NULL; ups = ups->next)
if (nut_read_one (ups) == 0)
success++;
if (nut_read_one (ups) == 0)
success++;