]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/ferr.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / ferr.c
index e5b6d7552d825fc9b83db70040c1efbbba15dfb8..33bcb075fa5ffb6e2261a1df11d8df77f12b2355 100644 (file)
@@ -1,17 +1,6 @@
+// SPDX-License-Identifier: ISC
 /*
  * Copyright (c) 2015-16  David Lamparter, for NetDEF, Inc.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -84,9 +73,9 @@ void log_ref_add(struct log_ref *ref)
 {
        uint32_t i = 0;
 
-       frr_with_mutex(&refs_mtx) {
+       frr_with_mutex (&refs_mtx) {
                while (ref[i].code != END_FERR) {
-                       hash_get(refs, &ref[i], hash_alloc_intern);
+                       (void)hash_get(refs, &ref[i], hash_alloc_intern);
                        i++;
                }
        }
@@ -98,7 +87,7 @@ struct log_ref *log_ref_get(uint32_t code)
        struct log_ref *ref;
 
        holder.code = code;
-       frr_with_mutex(&refs_mtx) {
+       frr_with_mutex (&refs_mtx) {
                ref = hash_lookup(refs, &holder);
        }
 
@@ -115,7 +104,7 @@ void log_ref_display(struct vty *vty, uint32_t code, bool json)
        if (json)
                top = json_object_new_object();
 
-       frr_with_mutex(&refs_mtx) {
+       frr_with_mutex (&refs_mtx) {
                errlist = code ? list_new() : hash_to_list(refs);
        }
 
@@ -182,7 +171,7 @@ DEFUN_NOSH(show_error_code,
 
 void log_ref_init(void)
 {
-       frr_with_mutex(&refs_mtx) {
+       frr_with_mutex (&refs_mtx) {
                refs = hash_create(ferr_hash_key, ferr_hash_cmp,
                                   "Error Reference Texts");
        }
@@ -190,10 +179,8 @@ void log_ref_init(void)
 
 void log_ref_fini(void)
 {
-       frr_with_mutex(&refs_mtx) {
-               hash_clean(refs, NULL);
-               hash_free(refs);
-               refs = NULL;
+       frr_with_mutex (&refs_mtx) {
+               hash_clean_and_free(&refs, NULL);
        }
 }
 
@@ -219,6 +206,7 @@ ferr_r ferr_clear(void)
        return ferr_ok();
 }
 
+PRINTFRR(7, 0)
 static ferr_r ferr_set_va(const char *file, int line, const char *func,
                          enum ferr_kind kind, const char *pathname,
                          int errno_val, const char *text, va_list va)