X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmqtt.c;h=097302adb9e1b97b20aab1598f7cd88db6f1b98d;hb=61a4ed99b1a5b6d371bb745933d0efc5dff9505c;hp=516448557f94e326f934729193c63cd094a6bd58;hpb=71fb7a5299f307a9261ae69819318f1eda1dd3c7;p=collectd.git diff --git a/src/mqtt.c b/src/mqtt.c index 51644855..097302ad 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -54,11 +54,11 @@ * Data types */ struct mqtt_client_conf { - _Bool publish; + bool publish; char *name; struct mosquitto *mosq; - _Bool connected; + bool connected; char *host; int port; @@ -74,14 +74,14 @@ struct mqtt_client_conf { /* For publishing */ char *topic_prefix; - _Bool store_rates; - _Bool retain; + bool store_rates; + bool retain; /* For subscribing */ pthread_t thread; - _Bool loop; + bool loop; char *topic; - _Bool clean_session; + bool clean_session; c_complain_t complaint_cantpublish; pthread_mutex_t lock; @@ -247,10 +247,8 @@ static int mqtt_reconnect(mqtt_client_conf_t *conf) { status = mosquitto_reconnect(conf->mosq); if (status != MOSQ_ERR_SUCCESS) { - char errbuf[1024]; ERROR("mqtt_connect_broker: mosquitto_connect failed: %s", - (status == MOSQ_ERR_ERRNO) ? sstrerror(errno, errbuf, sizeof(errbuf)) - : mosquitto_strerror(status)); + (status == MOSQ_ERR_ERRNO) ? STRERRNO : mosquitto_strerror(status)); return -1; } @@ -325,11 +323,8 @@ static int mqtt_connect(mqtt_client_conf_t *conf) { status = mosquitto_username_pw_set(conf->mosq, conf->username, conf->password); if (status != MOSQ_ERR_SUCCESS) { - char errbuf[1024]; ERROR("mqtt plugin: mosquitto_username_pw_set failed: %s", - (status == MOSQ_ERR_ERRNO) - ? sstrerror(errno, errbuf, sizeof(errbuf)) - : mosquitto_strerror(status)); + (status == MOSQ_ERR_ERRNO) ? STRERRNO : mosquitto_strerror(status)); mosquitto_destroy(conf->mosq); conf->mosq = NULL; @@ -346,10 +341,8 @@ static int mqtt_connect(mqtt_client_conf_t *conf) { mosquitto_connect(conf->mosq, conf->host, conf->port, MQTT_KEEPALIVE); #endif if (status != MOSQ_ERR_SUCCESS) { - char errbuf[1024]; ERROR("mqtt plugin: mosquitto_connect failed: %s", - (status == MOSQ_ERR_ERRNO) ? sstrerror(errno, errbuf, sizeof(errbuf)) - : mosquitto_strerror(status)); + (status == MOSQ_ERR_ERRNO) ? STRERRNO : mosquitto_strerror(status)); mosquitto_destroy(conf->mosq); conf->mosq = NULL; @@ -438,12 +431,10 @@ static int publish(mqtt_client_conf_t *conf, char const *topic, #endif conf->qos, conf->retain); if (status != MOSQ_ERR_SUCCESS) { - char errbuf[1024]; c_complain(LOG_ERR, &conf->complaint_cantpublish, "mqtt plugin: mosquitto_publish failed: %s", - (status == MOSQ_ERR_ERRNO) - ? sstrerror(errno, errbuf, sizeof(errbuf)) - : mosquitto_strerror(status)); + (status == MOSQ_ERR_ERRNO) ? STRERRNO + : mosquitto_strerror(status)); /* Mark our connection "down" regardless of the error as a safety * measure; we will try to reconnect the next time we have to publish a * message */ @@ -758,9 +749,7 @@ static int mqtt_init(void) { /* args = */ subscribers[i], /* name = */ "mqtt"); if (status != 0) { - char errbuf[1024]; - ERROR("mqtt plugin: pthread_create failed: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("mqtt plugin: pthread_create failed: %s", STRERRNO); continue; } }