]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
*_unref: Always expect a valid pointer
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 15 Aug 2022 18:42:45 +0000 (18:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 15 Aug 2022 18:42:45 +0000 (18:42 +0000)
Those functions have been very inconsistent in that way that some
happily accepted a NULL pointer and others didn't.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/country-list.c
src/libloc.c
src/network-list.c
src/network.c
src/test-network.c

index 0ed7ef1a53fe49016eb294d53a02404126cc5478..3f4ea4e8a6ecd357619e92dbd26a55147cfd5549 100644 (file)
@@ -81,9 +81,6 @@ static void loc_country_list_free(struct loc_country_list* list) {
 }
 
 LOC_EXPORT struct loc_country_list* loc_country_list_unref(struct loc_country_list* list) {
-       if (!list)
-               return NULL;
-
        if (--list->refcount > 0)
                return list;
 
index fb89b562e7fe7f826d5abc999ae0a927af371d7a..450c5e6fb4df341ac61e72f20ee956bc72b01e75 100644 (file)
@@ -103,9 +103,6 @@ LOC_EXPORT struct loc_ctx* loc_ref(struct loc_ctx* ctx) {
 }
 
 LOC_EXPORT struct loc_ctx* loc_unref(struct loc_ctx* ctx) {
-       if (!ctx)
-               return NULL;
-
        if (--ctx->refcount > 0)
                return NULL;
 
index 9aeafb5879a02b39c7922a4c7cf57753b57156c6..1b64a7ef8aa7c7690729630b1fad3e9b87472a59 100644 (file)
@@ -83,9 +83,6 @@ static void loc_network_list_free(struct loc_network_list* list) {
 }
 
 LOC_EXPORT struct loc_network_list* loc_network_list_unref(struct loc_network_list* list) {
-       if (!list)
-               return NULL;
-
        if (--list->refcount > 0)
                return list;
 
index 12e78e782c65b15819e9f1f2408f24f9607f7456..10af51ad69ed6c6e60a7211d575b0902cc5ce196 100644 (file)
@@ -116,9 +116,6 @@ static void loc_network_free(struct loc_network* network) {
 }
 
 LOC_EXPORT struct loc_network* loc_network_unref(struct loc_network* network) {
-       if (!network)
-               return NULL;
-
        if (--network->refcount > 0)
                return network;
 
@@ -856,9 +853,6 @@ static void loc_network_tree_node_free(struct loc_network_tree_node* node) {
 }
 
 struct loc_network_tree_node* loc_network_tree_node_unref(struct loc_network_tree_node* node) {
-       if (!node)
-               return NULL;
-
        if (--node->refcount > 0)
                return node;
 
index 866f49361955d905caa41154afb3206c5a826c1f..717ad3abd92a332bc744f1cb378fcbf904961e07 100644 (file)
@@ -302,7 +302,6 @@ int main(int argc, char** argv) {
                fprintf(stderr, "Could look up 2001:db8:fffe:1::, but I shouldn't\n");
                exit(EXIT_FAILURE);
        }
-       loc_network_unref(network1);
 
        const struct bit_length_test {
                const char* network;