X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fsigrok.c;h=d8c65c08d39f6b3d8d25bd9794c3d2e57f506029;hb=f7b3b6b8921c10b61fd2158e446686ef19315ed2;hp=1a0536ad4f3cd6797f198063af3eaf89e02948ca;hpb=c1219a1c9db2e8400e2ee94b87f86ccd441485d5;p=collectd.git diff --git a/src/sigrok.c b/src/sigrok.c index 1a0536ad..d8c65c08 100644 --- a/src/sigrok.c +++ b/src/sigrok.c @@ -1,6 +1,6 @@ /* * collectd - src/sigrok.c - * Copyright (C) 2013 Bert Vermeulen + * Copyright (C) 2013 Bert Vermeulen * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,6 +14,9 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * + * Authors: + * Bert Vermeulen */ #include "collectd.h" @@ -24,7 +27,6 @@ #include #include #include -#include #include #include @@ -69,11 +71,10 @@ static int sigrok_config_device(oconfig_item_t *ci) struct config_device *cfdev; int i; - if (!(cfdev = malloc(sizeof(struct config_device)))) { - ERROR("sigrok plugin: malloc() failed."); + if (!(cfdev = calloc(1, sizeof(*cfdev)))) { + ERROR("sigrok plugin: calloc failed."); return -1; } - memset(cfdev, 0, sizeof(*cfdev)); if (cf_util_get_string(ci, &cfdev->name)) { free(cfdev); WARNING("sigrok plugin: Invalid device name."); @@ -133,9 +134,9 @@ static int sigrok_config(oconfig_item_t *ci) return 0; } -static char *sigrok_value_type(const struct sr_datafeed_analog *analog) +static const char *sigrok_value_type(const struct sr_datafeed_analog *analog) { - char *s; + const char *s; if (analog->mq == SR_MQ_VOLTAGE) s = "voltage"; @@ -233,14 +234,14 @@ static int sigrok_init_driver(struct config_device *cfdev, drvopts = NULL; if (cfdev->conn) { - if (!(src = malloc(sizeof(struct sr_config)))) + if (!(src = malloc(sizeof(*src)))) return -1; src->key = SR_CONF_CONN; src->data = g_variant_new_string(cfdev->conn); drvopts = g_slist_append(drvopts, src); } if (cfdev->serialcomm) { - if (!(src = malloc(sizeof(struct sr_config)))) + if (!(src = malloc(sizeof(*src)))) return -1; src->key = SR_CONF_SERIALCOMM; src->data = g_variant_new_string(cfdev->serialcomm);