1
0
mirror of https://github.com/eclipse/mosquitto.git synced 2025-05-08 16:52:13 +08:00

Remove superfluous function arguments.

This commit is contained in:
Roger A. Light 2024-06-08 08:50:35 +01:00
parent 9a5c2bc14d
commit 3bb6c9ad51
10 changed files with 15 additions and 21 deletions

View File

@ -101,14 +101,13 @@ int retain__store(const char *topic, struct mosquitto_msg_store *stored, char **
return 0;
}
int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options, struct mosquitto__subhier **root)
int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options)
{
UNUSED(context);
UNUSED(sub);
UNUSED(qos);
UNUSED(identifier);
UNUSED(options);
UNUSED(root);
return 0;
}

View File

@ -388,8 +388,7 @@ int bridge__connect(struct mosquitto *context)
context->bridge->topics[i].local_topic,
qos,
0,
MQTT_SUB_OPT_NO_LOCAL | MQTT_SUB_OPT_RETAIN_AS_PUBLISHED,
&db.subs) > 0){
MQTT_SUB_OPT_NO_LOCAL | MQTT_SUB_OPT_RETAIN_AS_PUBLISHED) > 0){
return 1;
}

View File

@ -188,7 +188,7 @@ int handle__subscribe(struct mosquitto *context)
}
if(allowed){
rc2 = sub__add(context, sub, qos, subscription_identifier, subscription_options, &db.subs);
rc2 = sub__add(context, sub, qos, subscription_identifier, subscription_options);
if(rc2 > 0){
mosquitto__free(sub);
return rc2;

View File

@ -129,7 +129,7 @@ int handle__unsubscribe(struct mosquitto *context)
log__printf(NULL, MOSQ_LOG_DEBUG, "\t%s", sub);
if(allowed){
rc = sub__remove(context, sub, db.subs, &reason);
rc = sub__remove(context, sub, &reason);
}else{
rc = MOSQ_ERR_SUCCESS;
}

View File

@ -675,9 +675,9 @@ void db__expire_all_messages(struct mosquitto *context);
/* ============================================================
* Subscription functions
* ============================================================ */
int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options, struct mosquitto__subhier **root);
int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options);
struct mosquitto__subhier *sub__add_hier_entry(struct mosquitto__subhier *parent, struct mosquitto__subhier **sibling, const char *topic, uint16_t len);
int sub__remove(struct mosquitto *context, const char *sub, struct mosquitto__subhier *root, uint8_t *reason);
int sub__remove(struct mosquitto *context, const char *sub, uint8_t *reason);
void sub__tree_print(struct mosquitto__subhier *root, int level);
int sub__clean_session(struct mosquitto *context);
int sub__messages_queue(const char *source_id, const char *topic, uint8_t qos, int retain, struct mosquitto_msg_store **stored);

View File

@ -558,7 +558,7 @@ static int persist__restore_sub(const char *client_id, const char *sub, uint8_t
context = persist__find_or_add_context(client_id, 0);
if(!context) return 1;
return sub__add(context, sub, qos, identifier, options, &db.subs);
return sub__add(context, sub, qos, identifier, options);
}
#endif

View File

@ -288,7 +288,7 @@ static void check_subscription_acls(struct mosquitto *context)
MOSQ_ACL_SUBSCRIBE);
if(rc != MOSQ_ERR_SUCCESS){
sub__remove(context, context->subs[i]->topic_filter, db.subs, &reason);
sub__remove(context, context->subs[i]->topic_filter, &reason);
}
}
}

View File

@ -575,7 +575,7 @@ struct mosquitto__subhier *sub__add_hier_entry(struct mosquitto__subhier *parent
}
int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options, struct mosquitto__subhier **root)
int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options)
{
int rc = 0;
struct mosquitto__subhier *subhier;
@ -584,8 +584,6 @@ int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t i
char **topics;
size_t topiclen;
assert(root);
assert(*root);
assert(sub);
rc = sub__topic_tokenise(sub, &local_sub, &topics, &sharename);
@ -597,9 +595,9 @@ int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t i
mosquitto__free(topics);
return MOSQ_ERR_INVAL;
}
HASH_FIND(hh, *root, topics[0], topiclen, subhier);
HASH_FIND(hh, db.subs, topics[0], topiclen, subhier);
if(!subhier){
subhier = sub__add_hier_entry(NULL, root, topics[0], (uint16_t)topiclen);
subhier = sub__add_hier_entry(NULL, &db.subs, topics[0], (uint16_t)topiclen);
if(!subhier){
mosquitto__free(local_sub);
mosquitto__free(topics);
@ -616,7 +614,7 @@ int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t i
return rc;
}
int sub__remove(struct mosquitto *context, const char *sub, struct mosquitto__subhier *root, uint8_t *reason)
int sub__remove(struct mosquitto *context, const char *sub, uint8_t *reason)
{
int rc = 0;
struct mosquitto__subhier *subhier;
@ -624,13 +622,12 @@ int sub__remove(struct mosquitto *context, const char *sub, struct mosquitto__su
char *local_sub = NULL;
char **topics = NULL;
assert(root);
assert(sub);
rc = sub__topic_tokenise(sub, &local_sub, &topics, &sharename);
if(rc) return rc;
HASH_FIND(hh, root, topics[0], strlen(topics[0]), subhier);
HASH_FIND(hh, db.subs, topics[0], strlen(topics[0]), subhier);
if(subhier){
*reason = MQTT_RC_NO_SUBSCRIPTION_EXISTED;
rc = sub__remove_recurse(context, subhier, topics, reason, sharename);

View File

@ -149,11 +149,10 @@ int acl__find_acls(struct mosquitto *context)
}
int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options, struct mosquitto__subhier **root)
int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options)
{
UNUSED(context);
UNUSED(options);
UNUSED(root);
last_sub = strdup(sub);
last_qos = qos;

View File

@ -58,7 +58,7 @@ static void TEST_sub_add_single(void)
db__open(&config);
rc = sub__add(&context, "a/b/c/d/e", 0, 0, 0, &db.subs);
rc = sub__add(&context, "a/b/c/d/e", 0, 0, 0);
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
CU_ASSERT_PTR_NOT_NULL(db.subs);
if(db.subs){