]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix warnings in dlz_mysqldyn_mod.c
authorMichal Nowak <mnowak@isc.org>
Mon, 30 May 2022 12:36:49 +0000 (14:36 +0200)
committerMichal Nowak <mnowak@isc.org>
Wed, 23 Nov 2022 16:17:15 +0000 (17:17 +0100)
    dlz_mysqldyn_mod.c: In function ‘dlz_findzonedb’:
    dlz_mysqldyn_mod.c:1079:73: warning: unused parameter ‘methods’ [-Wunused-parameter]
     1079 | dlz_findzonedb(void *dbdata, const char *name, dns_clientinfomethods_t *methods,
          |                                                ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
    dlz_mysqldyn_mod.c:1080:34: warning: unused parameter ‘clientinfo’ [-Wunused-parameter]
     1080 |                dns_clientinfo_t *clientinfo) {
          |                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
    dlz_mysqldyn_mod.c: In function ‘dlz_lookup’:
    dlz_mysqldyn_mod.c:1111:63: warning: unused parameter ‘methods’ [-Wunused-parameter]
     1111 |            dns_sdlzlookup_t *lookup, dns_clientinfomethods_t *methods,
          |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
    dlz_mysqldyn_mod.c: In function ‘build_query’:
    dlz_mysqldyn_mod.c:465:19: warning: pointer ‘item’ used after ‘free’ [-Wuse-after-free]
      465 |              item = DLZ_LIST_NEXT(item, link))
    dlz_mysqldyn_mod.c:470:17: note: call to ‘free’ here
      470 |                 free(item);
          |                 ^~~~~~~~~~

contrib/dlz/modules/include/dlz_list.h
contrib/dlz/modules/mysqldyn/dlz_mysqldyn_mod.c

index 202bc0690ac3806d269cac25cb2a21081db8c750..077ae89a73bb8dcebc2a4c906c4ccce11d3557e4 100644 (file)
 
 #define DLZ_LIST_PREV(elt, link) ((elt)->link.prev)
 #define DLZ_LIST_NEXT(elt, link) ((elt)->link.next)
+
+#define DLZ_LIST_UNLINK(list, elt, link)                                \
+       do {                                                            \
+               if ((elt)->link.next != NULL)                           \
+                       (elt)->link.next->link.prev = (elt)->link.prev; \
+               else                                                    \
+                       (list).tail = (elt)->link.prev;                 \
+               if ((elt)->link.prev != NULL)                           \
+                       (elt)->link.prev->link.next = (elt)->link.next; \
+               else                                                    \
+                       (list).head = (elt)->link.next;                 \
+               (elt)->link.prev = (void *)(-1);                        \
+               (elt)->link.next = (void *)(-1);                        \
+       } while (0)
index 9af5a7e6929fe7457de882f349f7b98bb9826eac..bdd0bccdc65619dc6d1143f6eea27d39b7eeda6c 100644 (file)
@@ -461,9 +461,8 @@ build_query(mysql_data_t *state, mysql_instance_t *dbi, const char *command,
 fail:
        va_end(ap1);
 
-       for (item = DLZ_LIST_HEAD(arglist); item != NULL;
-            item = DLZ_LIST_NEXT(item, link))
-       {
+       while ((item = DLZ_LIST_HEAD(arglist)) != NULL) {
+               DLZ_LIST_UNLINK(arglist, item, link);
                if (item->arg != NULL) {
                        free(item->arg);
                }
@@ -1078,6 +1077,8 @@ dlz_destroy(void *dbdata) {
 isc_result_t
 dlz_findzonedb(void *dbdata, const char *name, dns_clientinfomethods_t *methods,
               dns_clientinfo_t *clientinfo) {
+       UNUSED(methods);
+       UNUSED(clientinfo);
        isc_result_t result = ISC_R_SUCCESS;
        mysql_data_t *state = (mysql_data_t *)dbdata;
        MYSQL_RES *res;
@@ -1110,6 +1111,8 @@ isc_result_t
 dlz_lookup(const char *zone, const char *name, void *dbdata,
           dns_sdlzlookup_t *lookup, dns_clientinfomethods_t *methods,
           dns_clientinfo_t *clientinfo) {
+       UNUSED(methods);
+       UNUSED(clientinfo);
        isc_result_t result;
        mysql_data_t *state = (mysql_data_t *)dbdata;
        bool found = false;