X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fceph.c;h=8048f5ddcfce7e7eb57460f54b90da4d75e1d8bf;hp=394719d53ae95265a1c786f5dd57051c30d5aa9a;hb=a59c14adfa86c823efff87ca797c4d6e6ce32913;hpb=24cc8f5c9ad5961fcb0d163d4279d835aa3dd5cb diff --git a/src/ceph.c b/src/ceph.c index 394719d5..8048f5dd 100644 --- a/src/ceph.c +++ b/src/ceph.c @@ -28,8 +28,8 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" #include #include @@ -251,7 +251,7 @@ static int ceph_cb_boolean(void *ctx, int bool_val) { return CEPH_CB_CONTINUE; } if (dest_size > dest_len) { \ sstrncpy((dest) + dest_len, (src), dest_size - dest_len); \ } \ - (dest)[dest_size - 1] = 0; \ + (dest)[dest_size - 1] = '\0'; \ } while (0) static int ceph_cb_number(void *ctx, const char *number_val, @@ -350,7 +350,7 @@ static int ceph_cb_map_key(void *ctx, const unsigned char *key, } memmove(state->key, key, sz - 1); - state->key[sz - 1] = 0; + state->key[sz - 1] = '\0'; return CEPH_CB_CONTINUE; } @@ -990,7 +990,7 @@ static int cconn_connect(struct cconn *io) { return err; } address.sun_family = AF_UNIX; - snprintf(address.sun_path, sizeof(address.sun_path), "%s", io->d->asok_path); + ssnprintf(address.sun_path, sizeof(address.sun_path), "%s", io->d->asok_path); RETRY_ON_EINTR(err, connect(fd, (struct sockaddr *)&address, sizeof(struct sockaddr_un))); if (err < 0) { @@ -1032,7 +1032,7 @@ static void cconn_close(struct cconn *io) { static int cconn_process_data(struct cconn *io, yajl_struct *yajl, yajl_handle hand) { int ret; - struct values_tmp *vtmp = calloc(1, sizeof(struct values_tmp) * 1); + struct values_tmp *vtmp = calloc(1, sizeof(*vtmp)); if (!vtmp) { return -ENOMEM; } @@ -1153,12 +1153,12 @@ static ssize_t cconn_handle_event(struct cconn *io) { return -EDOM; case CSTATE_WRITE_REQUEST: { char cmd[32]; - snprintf(cmd, sizeof(cmd), "%s%d%s", "{ \"prefix\": \"", io->request_type, - "\" }\n"); + ssnprintf(cmd, sizeof(cmd), "%s%d%s", "{ \"prefix\": \"", io->request_type, + "\" }\n"); size_t cmd_len = strlen(cmd); RETRY_ON_EINTR( ret, write(io->asok, ((char *)&cmd) + io->amt, cmd_len - io->amt)); - DEBUG("ceph plugin: cconn_handle_event(name=%s,state=%d,amt=%d,ret=%d)", + DEBUG("ceph plugin: cconn_handle_event(name=%s,state=%d,amt=%d,ret=%zd)", io->d->name, io->state, io->amt, ret); if (ret < 0) { return ret; @@ -1180,7 +1180,7 @@ static ssize_t cconn_handle_event(struct cconn *io) { case CSTATE_READ_VERSION: { RETRY_ON_EINTR(ret, read(io->asok, ((char *)(&io->d->version)) + io->amt, sizeof(io->d->version) - io->amt)); - DEBUG("ceph plugin: cconn_handle_event(name=%s,state=%d,ret=%d)", + DEBUG("ceph plugin: cconn_handle_event(name=%s,state=%d,ret=%zd)", io->d->name, io->state, ret); if (ret < 0) { return ret; @@ -1206,7 +1206,7 @@ static ssize_t cconn_handle_event(struct cconn *io) { case CSTATE_READ_AMT: { RETRY_ON_EINTR(ret, read(io->asok, ((char *)(&io->json_len)) + io->amt, sizeof(io->json_len) - io->amt)); - DEBUG("ceph plugin: cconn_handle_event(name=%s,state=%d,ret=%d)", + DEBUG("ceph plugin: cconn_handle_event(name=%s,state=%d,ret=%zd)", io->d->name, io->state, ret); if (ret < 0) { return ret; @@ -1227,7 +1227,7 @@ static ssize_t cconn_handle_event(struct cconn *io) { case CSTATE_READ_JSON: { RETRY_ON_EINTR(ret, read(io->asok, io->json + io->amt, io->json_len - io->amt)); - DEBUG("ceph plugin: cconn_handle_event(name=%s,state=%d,ret=%d)", + DEBUG("ceph plugin: cconn_handle_event(name=%s,state=%d,ret=%zd)", io->d->name, io->state, ret); if (ret < 0) { return ret;