projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix double declaration
[collectd.git]
/
src
/
memcached.c
diff --git
a/src/memcached.c
b/src/memcached.c
index
2c01a57
..
faff579
100644
(file)
--- a/
src/memcached.c
+++ b/
src/memcached.c
@@
-52,8
+52,9
@@
typedef struct memcached_s memcached_t;
static _Bool memcached_have_instances = 0;
static _Bool memcached_have_instances = 0;
-static void memcached_free (
memcached_t *st
)
+static void memcached_free (
void *arg
)
{
{
+ memcached_t *st = arg;
if (st == NULL)
return;
if (st == NULL)
return;
@@
-66,10
+67,9
@@
static void memcached_free (memcached_t *st)
static int memcached_connect_unix (memcached_t *st)
{
static int memcached_connect_unix (memcached_t *st)
{
- struct sockaddr_un serv_addr;
+ struct sockaddr_un serv_addr
= { 0 }
;
int fd;
int fd;
- memset (&serv_addr, 0, sizeof (serv_addr));
serv_addr.sun_family = AF_UNIX;
sstrncpy (serv_addr.sun_path, st->socket,
sizeof (serv_addr.sun_path));
serv_addr.sun_family = AF_UNIX;
sstrncpy (serv_addr.sun_path, st->socket,
sizeof (serv_addr.sun_path));
@@
-101,13
+101,11
@@
static int memcached_connect_inet (memcached_t *st)
const char *host;
const char *port;
const char *host;
const char *port;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints
= { 0 }
;
struct addrinfo *ai_list, *ai_ptr;
int status;
int fd = -1;
struct addrinfo *ai_list, *ai_ptr;
int status;
int fd = -1;
- memset (&ai_hints, 0, sizeof (ai_hints));
- ai_hints.ai_flags = 0;
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
@@
-173,8
+171,7
@@
static int memcached_connect (memcached_t *st)
static int memcached_query_daemon (char *buffer, size_t buffer_size, memcached_t *st)
{
static int memcached_query_daemon (char *buffer, size_t buffer_size, memcached_t *st)
{
- int fd = -1;
- int status;
+ int fd, status;
size_t buffer_fill;
fd = memcached_connect (st);
size_t buffer_fill;
fd = memcached_connect (st);
@@
-551,13
+548,12
@@
static int memcached_read (user_data_t *user_data)
static int memcached_add_read_callback (memcached_t *st)
{
static int memcached_add_read_callback (memcached_t *st)
{
- user_data_t ud;
+ user_data_t ud
= { 0 }
;
char callback_name[3*DATA_MAX_NAME_LEN];
int status;
char callback_name[3*DATA_MAX_NAME_LEN];
int status;
- memset (&ud, 0, sizeof (ud));
ud.data = st;
ud.data = st;
- ud.free_func =
(void *)
memcached_free;
+ ud.free_func = memcached_free;
assert (st->name != NULL);
ssnprintf (callback_name, sizeof (callback_name), "memcached/%s", st->name);
assert (st->name != NULL);
ssnprintf (callback_name, sizeof (callback_name), "memcached/%s", st->name);
@@
-587,14
+583,13
@@
static int config_add_instance(oconfig_item_t *ci)
/* Disable automatic generation of default instance in the init callback. */
memcached_have_instances = 1;
/* Disable automatic generation of default instance in the init callback. */
memcached_have_instances = 1;
- st =
malloc (
sizeof (*st));
+ st =
calloc (1,
sizeof (*st));
if (st == NULL)
{
if (st == NULL)
{
- ERROR ("memcached plugin:
m
alloc failed.");
+ ERROR ("memcached plugin:
c
alloc failed.");
return (-1);
}
return (-1);
}
- memset (st, 0, sizeof (*st));
st->name = NULL;
st->socket = NULL;
st->host = NULL;
st->name = NULL;
st->socket = NULL;
st->host = NULL;
@@
-685,10
+680,9
@@
static int memcached_init (void)
return (0);
/* No instances were configured, lets start a default instance. */
return (0);
/* No instances were configured, lets start a default instance. */
- st =
malloc (
sizeof (*st));
+ st =
calloc (1,
sizeof (*st));
if (st == NULL)
return (ENOMEM);
if (st == NULL)
return (ENOMEM);
- memset (st, 0, sizeof (*st));
st->name = sstrdup ("__legacy__");
st->socket = NULL;
st->host = NULL;
st->name = sstrdup ("__legacy__");
st->socket = NULL;
st->host = NULL;