Skip to content

Commit 91f99fc

Browse files
BeckmaRfabiobaltieri
authored andcommitted
net: mqtt-sn: Rename internal 'find' functions
Add word 'by' to function names to clarify which is the thing that is found and which is the thing that is searched for. For example, mqtt_sn_topic_find_name was renamed to mqtt_sn_topic_find_by_name because the function does not find the name but finds a topic by its name. Signed-off-by: Rene Beckmann <rene.bckmnn@gmail.com>
1 parent bbebef3 commit 91f99fc

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

subsys/net/lib/mqtt_sn/mqtt_sn.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ static struct mqtt_sn_publish *mqtt_sn_publish_create(struct mqtt_sn_data *data)
197197
return pub;
198198
}
199199

200-
static struct mqtt_sn_publish *mqtt_sn_publish_find_msg_id(struct mqtt_sn_client *client,
201-
uint16_t msg_id)
200+
static struct mqtt_sn_publish *mqtt_sn_publish_find_by_msg_id(struct mqtt_sn_client *client,
201+
uint16_t msg_id)
202202
{
203203
struct mqtt_sn_publish *pub;
204204

@@ -211,8 +211,8 @@ static struct mqtt_sn_publish *mqtt_sn_publish_find_msg_id(struct mqtt_sn_client
211211
return NULL;
212212
}
213213

214-
static struct mqtt_sn_publish *mqtt_sn_publish_find_topic(struct mqtt_sn_client *client,
215-
struct mqtt_sn_topic *topic)
214+
static struct mqtt_sn_publish *mqtt_sn_publish_find_by_topic(struct mqtt_sn_client *client,
215+
struct mqtt_sn_topic *topic)
216216
{
217217
struct mqtt_sn_publish *pub;
218218

@@ -254,8 +254,8 @@ static struct mqtt_sn_topic *mqtt_sn_topic_create(struct mqtt_sn_data *name)
254254
return topic;
255255
}
256256

257-
static struct mqtt_sn_topic *mqtt_sn_topic_find_name(struct mqtt_sn_client *client,
258-
struct mqtt_sn_data *topic_name)
257+
static struct mqtt_sn_topic *mqtt_sn_topic_find_by_name(struct mqtt_sn_client *client,
258+
struct mqtt_sn_data *topic_name)
259259
{
260260
struct mqtt_sn_topic *topic;
261261

@@ -269,8 +269,8 @@ static struct mqtt_sn_topic *mqtt_sn_topic_find_name(struct mqtt_sn_client *clie
269269
return NULL;
270270
}
271271

272-
static struct mqtt_sn_topic *mqtt_sn_topic_find_msg_id(struct mqtt_sn_client *client,
273-
uint16_t msg_id)
272+
static struct mqtt_sn_topic *mqtt_sn_topic_find_by_msg_id(struct mqtt_sn_client *client,
273+
uint16_t msg_id)
274274
{
275275
struct mqtt_sn_topic *topic;
276276

@@ -288,7 +288,7 @@ static void mqtt_sn_topic_destroy(struct mqtt_sn_client *client, struct mqtt_sn_
288288
struct mqtt_sn_publish *pub;
289289

290290
/* Destroy all pubs referencing this topic */
291-
while ((pub = mqtt_sn_publish_find_topic(client, topic)) != NULL) {
291+
while ((pub = mqtt_sn_publish_find_by_topic(client, topic)) != NULL) {
292292
LOG_WRN("Destroying publish msg_id %d", pub->con.msg_id);
293293
mqtt_sn_publish_destroy(client, pub);
294294
}
@@ -305,7 +305,7 @@ static void mqtt_sn_topic_destroy_all(struct mqtt_sn_client *client)
305305
while ((next = sys_slist_get(&client->topic)) != NULL) {
306306
topic = SYS_SLIST_CONTAINER(next, topic, next);
307307
/* Destroy all pubs referencing this topic */
308-
while ((pub = mqtt_sn_publish_find_topic(client, topic)) != NULL) {
308+
while ((pub = mqtt_sn_publish_find_by_topic(client, topic)) != NULL) {
309309
LOG_WRN("Destroying publish msg_id %d", pub->con.msg_id);
310310
mqtt_sn_publish_destroy(client, pub);
311311
}
@@ -361,7 +361,7 @@ static struct mqtt_sn_gateway *mqtt_sn_gw_create(uint8_t gw_id, short duration,
361361
return gw;
362362
}
363363

364-
static struct mqtt_sn_gateway *mqtt_sn_gw_find_id(struct mqtt_sn_client *client, uint16_t gw_id)
364+
static struct mqtt_sn_gateway *mqtt_sn_gw_find_by_id(struct mqtt_sn_client *client, uint16_t gw_id)
365365
{
366366
struct mqtt_sn_gateway *gw;
367367

@@ -897,7 +897,7 @@ int mqtt_sn_add_gw(struct mqtt_sn_client *client, uint8_t gw_id, struct mqtt_sn_
897897
{
898898
struct mqtt_sn_gateway *gw;
899899

900-
gw = mqtt_sn_gw_find_id(client, gw_id);
900+
gw = mqtt_sn_gw_find_by_id(client, gw_id);
901901

902902
if (gw != NULL) {
903903
mqtt_sn_gw_destroy(client, gw);
@@ -1004,7 +1004,7 @@ int mqtt_sn_subscribe(struct mqtt_sn_client *client, enum mqtt_sn_qos qos,
10041004
return -ENOTCONN;
10051005
}
10061006

1007-
topic = mqtt_sn_topic_find_name(client, topic_name);
1007+
topic = mqtt_sn_topic_find_by_name(client, topic_name);
10081008
if (!topic) {
10091009
topic = mqtt_sn_topic_create(topic_name);
10101010
if (!topic) {
@@ -1039,7 +1039,7 @@ int mqtt_sn_unsubscribe(struct mqtt_sn_client *client, enum mqtt_sn_qos qos,
10391039
return -ENOTCONN;
10401040
}
10411041

1042-
topic = mqtt_sn_topic_find_name(client, topic_name);
1042+
topic = mqtt_sn_topic_find_by_name(client, topic_name);
10431043
if (!topic) {
10441044
LOG_HEXDUMP_ERR(topic_name->data, topic_name->size, "Topic not found");
10451045
return -ENOENT;
@@ -1077,7 +1077,7 @@ int mqtt_sn_publish(struct mqtt_sn_client *client, enum mqtt_sn_qos qos,
10771077
return -ENOTCONN;
10781078
}
10791079

1080-
topic = mqtt_sn_topic_find_name(client, topic_name);
1080+
topic = mqtt_sn_topic_find_by_name(client, topic_name);
10811081
if (!topic) {
10821082
topic = mqtt_sn_topic_create(topic_name);
10831083
if (!topic) {
@@ -1115,7 +1115,7 @@ static void handle_advertise(struct mqtt_sn_client *client, struct mqtt_sn_param
11151115
struct mqtt_sn_evt evt = {.type = MQTT_SN_EVT_ADVERTISE};
11161116
struct mqtt_sn_gateway *gw;
11171117

1118-
gw = mqtt_sn_gw_find_id(client, p->gw_id);
1118+
gw = mqtt_sn_gw_find_by_id(client, p->gw_id);
11191119

11201120
if (gw == NULL) {
11211121
LOG_DBG("Creating GW 0x%02x with duration %d", p->gw_id, p->duration);
@@ -1262,7 +1262,7 @@ static void handle_register(struct mqtt_sn_client *client, struct mqtt_sn_param_
12621262

12631263
static void handle_regack(struct mqtt_sn_client *client, struct mqtt_sn_param_regack *p)
12641264
{
1265-
struct mqtt_sn_topic *topic = mqtt_sn_topic_find_msg_id(client, p->msg_id);
1265+
struct mqtt_sn_topic *topic = mqtt_sn_topic_find_by_msg_id(client, p->msg_id);
12661266

12671267
if (!topic) {
12681268
LOG_ERR("Can't REGACK, no topic found");
@@ -1307,7 +1307,7 @@ static void handle_publish(struct mqtt_sn_client *client, struct mqtt_sn_param_p
13071307

13081308
static void handle_puback(struct mqtt_sn_client *client, struct mqtt_sn_param_puback *p)
13091309
{
1310-
struct mqtt_sn_publish *pub = mqtt_sn_publish_find_msg_id(client, p->msg_id);
1310+
struct mqtt_sn_publish *pub = mqtt_sn_publish_find_by_msg_id(client, p->msg_id);
13111311

13121312
if (!pub) {
13131313
LOG_ERR("No matching PUBLISH found for msg id %u", p->msg_id);
@@ -1320,7 +1320,7 @@ static void handle_puback(struct mqtt_sn_client *client, struct mqtt_sn_param_pu
13201320
static void handle_pubrec(struct mqtt_sn_client *client, struct mqtt_sn_param_pubrec *p)
13211321
{
13221322
struct mqtt_sn_param response = {.type = MQTT_SN_MSG_TYPE_PUBREL};
1323-
struct mqtt_sn_publish *pub = mqtt_sn_publish_find_msg_id(client, p->msg_id);
1323+
struct mqtt_sn_publish *pub = mqtt_sn_publish_find_by_msg_id(client, p->msg_id);
13241324

13251325
if (!pub) {
13261326
LOG_ERR("No matching PUBLISH found for msg id %u", p->msg_id);
@@ -1346,7 +1346,7 @@ static void handle_pubrel(struct mqtt_sn_client *client, struct mqtt_sn_param_pu
13461346

13471347
static void handle_pubcomp(struct mqtt_sn_client *client, struct mqtt_sn_param_pubcomp *p)
13481348
{
1349-
struct mqtt_sn_publish *pub = mqtt_sn_publish_find_msg_id(client, p->msg_id);
1349+
struct mqtt_sn_publish *pub = mqtt_sn_publish_find_by_msg_id(client, p->msg_id);
13501350

13511351
if (!pub) {
13521352
LOG_ERR("No matching PUBLISH found for msg id %u", p->msg_id);
@@ -1358,7 +1358,7 @@ static void handle_pubcomp(struct mqtt_sn_client *client, struct mqtt_sn_param_p
13581358

13591359
static void handle_suback(struct mqtt_sn_client *client, struct mqtt_sn_param_suback *p)
13601360
{
1361-
struct mqtt_sn_topic *topic = mqtt_sn_topic_find_msg_id(client, p->msg_id);
1361+
struct mqtt_sn_topic *topic = mqtt_sn_topic_find_by_msg_id(client, p->msg_id);
13621362

13631363
if (!topic) {
13641364
LOG_ERR("No matching SUBSCRIBE found for msg id %u", p->msg_id);
@@ -1376,7 +1376,7 @@ static void handle_suback(struct mqtt_sn_client *client, struct mqtt_sn_param_su
13761376

13771377
static void handle_unsuback(struct mqtt_sn_client *client, struct mqtt_sn_param_unsuback *p)
13781378
{
1379-
struct mqtt_sn_topic *topic = mqtt_sn_topic_find_msg_id(client, p->msg_id);
1379+
struct mqtt_sn_topic *topic = mqtt_sn_topic_find_by_msg_id(client, p->msg_id);
13801380

13811381
if (!topic || topic->state != MQTT_SN_TOPIC_STATE_UNSUBSCRIBING) {
13821382
LOG_ERR("No matching UNSUBSCRIBE found for msg id %u", p->msg_id);

0 commit comments

Comments
 (0)