Skip to content

Commit 6599f9b

Browse files
committed
Removed checks for null on handlers where it cannot occur anymore
1 parent cb74a59 commit 6599f9b

File tree

2 files changed

+0
-11
lines changed

2 files changed

+0
-11
lines changed

src/handlers.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ static int connect_handler(struct io_event *e) {
431431
const char *will_message = (const char *) c->payload.will_message;
432432
// TODO check for will_topic != NULL
433433
struct topic *t = topic_store_get_or_put(server.store, will_topic);
434-
if (!t)
435-
log_fatal("connect_handler failed: Out of memory");
436434
if (!topic_store_contains(server.store, t->name))
437435
topic_store_put(server.store, t);
438436
// I'm sure that the string will be NUL terminated by unpack function
@@ -450,9 +448,6 @@ static int connect_handler(struct io_event *e) {
450448
}
451449
};
452450

453-
if (!cc->session->lwt_msg.publish.topic || !cc->session->lwt_msg.publish.payload)
454-
log_fatal("connect_handler failed: Out of memory");
455-
456451
cc->session->lwt_msg.header.bits.qos = c->bits.will_qos;
457452
// We must store the retained message in the topic
458453
if (c->bits.will_retain == 1) {
@@ -569,8 +564,6 @@ static int subscribe_handler(struct io_event *e) {
569564
}
570565

571566
struct topic *t = topic_store_get_or_put(server.store, topic);
572-
if (!t)
573-
log_fatal("subscribe_handler failed: Out of memory");
574567
/*
575568
* Let's explore two possible scenarios:
576569
* 1. Normal topic (no single level wildcard '+') which can end with
@@ -719,8 +712,6 @@ static int publish_handler(struct io_event *e) {
719712
* create a new one with the name selected
720713
*/
721714
struct topic *t = topic_store_get_or_put(server.store, topic);
722-
if (!t)
723-
log_fatal("publish_handler failed: Out of memory");
724715

725716
/* Check for # wildcards subscriptions */
726717
if (topic_store_wildcards_empty(server.store)) {

src/topic_store.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ struct topic *topic_store_get_or_put(struct topic_store *store,
107107
if (t != NULL)
108108
return t;
109109
t = topic_new(try_strdup(name));
110-
if (!t)
111-
return NULL;
112110
topic_store_put(store, t);
113111
return t;
114112
}

0 commit comments

Comments
 (0)