X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmqtt.c;h=4977f6841e72454c46ecbb35f5c995254dd48e3f;hb=5c2993e4121feae745551be182221b31bc23ff97;hp=c7581e9a823e720bf7d4b22694e3608ba0223bf3;hpb=1efab2edcc7078c698eba7cb9c8326bd6f271dde;p=collectd.git diff --git a/src/mqtt.c b/src/mqtt.c index c7581e9a..4977f684 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -700,11 +700,11 @@ static int mqtt_config_subscriber (oconfig_item_t *ci) cf_util_get_string (child, &conf->host); else if (strcasecmp ("Port", child->key) == 0) { - int tmp = cf_util_get_port_number (child); - if (tmp < 0) + status = cf_util_get_port_number (child); + if (status < 0) ERROR ("mqtt plugin: Invalid port number."); else - conf->port = tmp; + conf->port = status; } else if (strcasecmp ("ClientId", child->key) == 0) cf_util_get_string (child, &conf->client_id); @@ -714,12 +714,12 @@ static int mqtt_config_subscriber (oconfig_item_t *ci) cf_util_get_string (child, &conf->password); else if (strcasecmp ("QoS", child->key) == 0) { - int tmp = -1; - status = cf_util_get_int (child, &tmp); - if ((status != 0) || (tmp < 0) || (tmp > 2)) + int qos = -1; + status = cf_util_get_int (child, &qos); + if ((status != 0) || (qos < 0) || (qos > 2)) ERROR ("mqtt plugin: Not a valid QoS setting."); else - conf->qos = tmp; + conf->qos = qos; } else if (strcasecmp ("Topic", child->key) == 0) cf_util_get_string (child, &conf->topic); @@ -729,7 +729,7 @@ static int mqtt_config_subscriber (oconfig_item_t *ci) ERROR ("mqtt plugin: Unknown config option: %s", child->key); } - tmp = realloc (subscribers, sizeof (*subscribers) * subscribers_num); + tmp = realloc (subscribers, sizeof (*subscribers) * (subscribers_num + 1) ); if (tmp == NULL) { ERROR ("mqtt plugin: realloc failed.");