Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit afff715

Browse files
authored
Merge pull request #328 from afcidk/fix-warnings
cleanup: fix warnings in accelerator_mqtt
2 parents d88de93 + e6bbf0b commit afff715

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ $ make && bazel run //accelerator:push_docker --host_force_python=PY2
132132
MQTT connectivity is an optional feature allowing IoT endpoint devices to collaborate with `Tangle-Accelerator`.
133133

134134
```
135-
make MQTT && bazel run //accelerator_mqtt
135+
make MQTT && bazel run //accelerator:accelerator_mqtt
136136
```
137137

138138
Note you may need to set up the `MQTT_HOST` and `TOPIC_ROOT` in `config.h` to connect to a MQTT broker.

accelerator/config.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ status_t ta_config_default_init(ta_config_t* const info, iota_config_t* const ic
131131
iconf->milestone_depth = MILESTONE_DEPTH;
132132
iconf->mwm = MWM;
133133
iconf->seed = SEED;
134-
iconf->mam_file_path = tempnam(MAM_FILE_DIR, MAM_FILE_PREFIX);
134+
char mam_file_path[] = MAM_FILE_PREFIX;
135+
mkstemp(mam_file_path);
136+
iconf->mam_file_path = mam_file_path;
135137

136138
ta_log_info("Initializing IRI connection\n");
137139
service->http.path = "/";

accelerator/config.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ extern "C" {
4646
#define SEED \
4747
"AMRWQP9BUMJALJHBXUCHOD9HFFD9LGTGEAWMJWWXSDVOF9PI9YGJAPBQLQUOMNYEQCZPGCTHGV" \
4848
"NNAPGHA"
49-
#define MAM_FILE_DIR "/tmp"
50-
#define MAM_FILE_PREFIX "mam_bin_"
49+
#define MAM_FILE_PREFIX "/tmp/mam_bin_XXXXXX"
5150

5251
/** @name Redis connection config */
5352
/** @{ */

connectivity/mqtt/duplex_callback.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static status_t mqtt_request_handler(mosq_config_t *cfg, char *subscribe_topic,
4747
char *p;
4848
if (!strncmp(api_sub_topic, "address", 7)) {
4949
ret = api_generate_address(&ta_core.iconf, &ta_core.service, &json_result);
50-
} else if (p = strstr(api_sub_topic, "tag")) {
50+
} else if ((p = strstr(api_sub_topic, "tag"))) {
5151
if (!strncmp(p + 4, "hashes", 6)) {
5252
char tag[NUM_TRYTES_TAG + 1];
5353
mqtt_tag_req_deserialize(req, tag);
@@ -57,15 +57,15 @@ static status_t mqtt_request_handler(mosq_config_t *cfg, char *subscribe_topic,
5757
mqtt_tag_req_deserialize(req, tag);
5858
ret = api_find_transactions_obj_by_tag(&ta_core.service, tag, &json_result);
5959
}
60-
} else if (p = strstr(api_sub_topic, "transaction")) {
60+
} else if ((p = strstr(api_sub_topic, "transaction"))) {
6161
if (!strncmp(p + 12, "object", 6)) {
6262
char hash[NUM_TRYTES_HASH + 1];
6363
mqtt_transaction_hash_req_deserialize(req, hash);
6464
ret = api_find_transaction_object_single(&ta_core.service, hash, &json_result);
6565
} else if (!strncmp(p + 12, "send", 4)) {
6666
ret = api_send_transfer(&ta_core.iconf, &ta_core.service, req, &json_result);
6767
}
68-
} else if (p = strstr(api_sub_topic, "tips")) {
68+
} else if ((p = strstr(api_sub_topic, "tips"))) {
6969
if (!strncmp(p + 5, "all", 3)) {
7070
ret = api_get_tips(&ta_core.service, &json_result);
7171
} else if (!strncmp(p + 5, "pair", 4)) {
@@ -129,6 +129,10 @@ static void connect_callback_duplex_func(struct mosquitto *mosq, void *obj, int
129129

130130
static void disconnect_callback_duplex_func(struct mosquitto *mosq, void *obj, mosq_retcode_t ret,
131131
const mosquitto_property *properties) {
132+
UNUSED(mosq);
133+
UNUSED(obj);
134+
UNUSED(ret);
135+
UNUSED(properties);
132136
// TODO we may necessitate doing something here after client is disconnected.
133137
}
134138

@@ -138,6 +142,9 @@ static void subscribe_callback_duplex_func(struct mosquitto *mosq, void *obj, in
138142
}
139143

140144
static void log_callback_duplex_func(struct mosquitto *mosq, void *obj, int level, const char *str) {
145+
UNUSED(mosq);
146+
UNUSED(obj);
147+
UNUSED(level);
141148
log_info(logger_id, "log: %s\n", str);
142149
}
143150

connectivity/mqtt/pub_utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#define PUB_UTILS_H
1111

1212
#include "client_common.h"
13+
#undef uthash_free
14+
#undef uthash_malloc
1315
#include "third_party/mosquitto/config.h"
1416
#include "third_party/mosquitto/lib/mqtt_protocol.h"
1517

connectivity/mqtt/sub_utils.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void publish_callback_sub_func(struct mosquitto *mosq, void *obj, int mid, int r
5151
void message_callback_sub_func(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message,
5252
const mosquitto_property *properties) {
5353
mosq_config_t *cfg = (mosq_config_t *)obj;
54+
UNUSED(properties);
5455

5556
if (cfg->sub_config->remove_retained && message->retain) {
5657
mosquitto_publish(mosq, &cfg->general_config->last_mid, message->topic, 0, NULL, 1, true);
@@ -99,6 +100,8 @@ void connect_callback_sub_func(struct mosquitto *mosq, void *obj, int result, in
99100
}
100101

101102
void subscribe_callback_sub_func(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos) {
103+
UNUSED(mosq);
104+
UNUSED(obj);
102105
char *qos_str = (char *)calloc(qos_count, 3);
103106
char qos_digit[4];
104107
for (int i = 1; i < qos_count; i++) {

0 commit comments

Comments
 (0)