From 393d7dbc03cc233bc1ff065b9b33a3e243b02566 Mon Sep 17 00:00:00 2001 From: Niklas Fiekas Date: Sat, 11 Jan 2025 17:52:32 +0100 Subject: [PATCH] More precise constness for topics in mosquitto_subscribe_multiple mosquitto_subscribe_multiple and mosquitto_unsubscribe_multiple do not need to change the characters in the list of topics. Make the signature more precise to reflect that. Now works without cast array of const char*, particularly useful for C++ or Rust bindings. Signed-off-by: Niklas Fiekas --- client/sub_client.c | 2 +- include/mosquitto.h | 4 ++-- lib/actions.c | 12 ++++++------ lib/send_mosq.h | 4 ++-- lib/send_subscribe.c | 2 +- lib/send_unsubscribe.c | 2 +- src/bridge.c | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/client/sub_client.c b/client/sub_client.c index 6e2a1fb4d9..48cb78b52f 100644 --- a/client/sub_client.c +++ b/client/sub_client.c @@ -122,7 +122,7 @@ static void my_connect_callback(struct mosquitto *mosq, void *obj, int result, i connack_result = result; if(!result){ - mosquitto_subscribe_multiple(mosq, NULL, cfg.topic_count, cfg.topics, cfg.qos, cfg.sub_opts, cfg.subscribe_props); + mosquitto_subscribe_multiple(mosq, NULL, cfg.topic_count, (const char* const*)cfg.topics, cfg.qos, cfg.sub_opts, cfg.subscribe_props); for(i=0; ibridge->topics[i].remote_topic, sub_opts, NULL)){ + if(send__subscribe(context, NULL, 1, (const char* const*)&context->bridge->topics[i].remote_topic, sub_opts, NULL)){ return 1; } }else{ if(context->bridge->attempt_unsubscribe){ - if(send__unsubscribe(context, NULL, 1, &context->bridge->topics[i].remote_topic, NULL)){ + if(send__unsubscribe(context, NULL, 1, (const char* const*)&context->bridge->topics[i].remote_topic, NULL)){ /* direction = inwards only. This means we should not be subscribed * to the topic. It is possible that we used to be subscribed to * this topic so unsubscribe. */