Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
From 3bb6c9ad51f712864dea63529e0b55661c2a9e84 Mon Sep 17 00:00:00 2001
From: "Roger A. Light" <roger@atchoo.org>
Date: Sat, 8 Jun 2024 08:50:35 +0100
Subject: [PATCH] Remove superfluous function arguments.
---
apps/db_dump/stubs.c | 3 +--
src/bridge.c | 3 +--
src/handle_subscribe.c | 2 +-
src/handle_unsubscribe.c | 2 +-
src/mosquitto_broker_internal.h | 4 ++--
src/persist_read.c | 2 +-
src/plugin_public.c | 2 +-
src/subs.c | 13 +++++--------
test/unit/persist_read_stubs.c | 3 +--
test/unit/subs_test.c | 2 +-
10 files changed, 15 insertions(+), 21 deletions(-)
Index: mosquitto-2.0.18/apps/db_dump/stubs.c
===================================================================
--- mosquitto-2.0.18.orig/apps/db_dump/stubs.c
+++ mosquitto-2.0.18/apps/db_dump/stubs.c
@@ -101,14 +101,13 @@ int retain__store(const char *topic, str
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;
}
Index: mosquitto-2.0.18/src/bridge.c
===================================================================
--- mosquitto-2.0.18.orig/src/bridge.c
+++ mosquitto-2.0.18/src/bridge.c
@@ -383,8 +383,7 @@ int bridge__connect(struct mosquitto *co
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;
}
Index: mosquitto-2.0.18/src/handle_subscribe.c
===================================================================
--- mosquitto-2.0.18.orig/src/handle_subscribe.c
+++ mosquitto-2.0.18/src/handle_subscribe.c
@@ -188,7 +188,7 @@ int handle__subscribe(struct mosquitto *
}
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;
Index: mosquitto-2.0.18/src/handle_unsubscribe.c
===================================================================
--- mosquitto-2.0.18.orig/src/handle_unsubscribe.c
+++ mosquitto-2.0.18/src/handle_unsubscribe.c
@@ -129,7 +129,7 @@ int handle__unsubscribe(struct mosquitto
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;
}
Index: mosquitto-2.0.18/src/mosquitto_broker_internal.h
===================================================================
--- mosquitto-2.0.18.orig/src/mosquitto_broker_internal.h
+++ mosquitto-2.0.18/src/mosquitto_broker_internal.h
@@ -675,9 +675,9 @@ void db__expire_all_messages(struct mosq
/* ============================================================
* 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);
Index: mosquitto-2.0.18/src/persist_read.c
===================================================================
--- mosquitto-2.0.18.orig/src/persist_read.c
+++ mosquitto-2.0.18/src/persist_read.c
@@ -552,7 +552,7 @@ static int persist__restore_sub(const ch
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
Index: mosquitto-2.0.18/src/plugin_public.c
===================================================================
--- mosquitto-2.0.18.orig/src/plugin_public.c
+++ mosquitto-2.0.18/src/plugin_public.c
@@ -288,7 +288,7 @@ static void check_subscription_acls(stru
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);
}
}
}
Index: mosquitto-2.0.18/src/subs.c
===================================================================
--- mosquitto-2.0.18.orig/src/subs.c
+++ mosquitto-2.0.18/src/subs.c
@@ -575,7 +575,7 @@ struct mosquitto__subhier *sub__add_hier
}
-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,
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,
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,
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 *contex
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);
Index: mosquitto-2.0.18/test/unit/persist_read_stubs.c
===================================================================
--- mosquitto-2.0.18.orig/test/unit/persist_read_stubs.c
+++ mosquitto-2.0.18/test/unit/persist_read_stubs.c
@@ -149,11 +149,10 @@ int acl__find_acls(struct mosquitto *con
}
-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;
Index: mosquitto-2.0.18/test/unit/subs_test.c
===================================================================
--- mosquitto-2.0.18.orig/test/unit/subs_test.c
+++ mosquitto-2.0.18/test/unit/subs_test.c
@@ -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){