]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
netfilter: nf_conncount: fix wrong variable type
authorYunjian Wang <wangyunjian@huawei.com>
Fri, 31 May 2024 03:48:47 +0000 (11:48 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 25 Jun 2024 22:54:53 +0000 (00:54 +0200)
Now there is a issue is that code checks reports a warning: implicit
narrowing conversion from type 'unsigned int' to small type 'u8' (the
'keylen' variable). Fix it by removing the 'keylen' variable.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_conncount.c

index 8715617b02fe674ea11fc284f83409ae77bac164..34ba14e59e95a81ff6b6c6c64f12b70ebc907b9d 100644 (file)
@@ -321,7 +321,6 @@ insert_tree(struct net *net,
        struct nf_conncount_rb *rbconn;
        struct nf_conncount_tuple *conn;
        unsigned int count = 0, gc_count = 0;
-       u8 keylen = data->keylen;
        bool do_gc = true;
 
        spin_lock_bh(&nf_conncount_locks[hash]);
@@ -333,7 +332,7 @@ restart:
                rbconn = rb_entry(*rbnode, struct nf_conncount_rb, node);
 
                parent = *rbnode;
-               diff = key_diff(key, rbconn->key, keylen);
+               diff = key_diff(key, rbconn->key, data->keylen);
                if (diff < 0) {
                        rbnode = &((*rbnode)->rb_left);
                } else if (diff > 0) {
@@ -378,7 +377,7 @@ restart:
 
        conn->tuple = *tuple;
        conn->zone = *zone;
-       memcpy(rbconn->key, key, sizeof(u32) * keylen);
+       memcpy(rbconn->key, key, sizeof(u32) * data->keylen);
 
        nf_conncount_list_init(&rbconn->list);
        list_add(&conn->node, &rbconn->list.head);
@@ -403,7 +402,6 @@ count_tree(struct net *net,
        struct rb_node *parent;
        struct nf_conncount_rb *rbconn;
        unsigned int hash;
-       u8 keylen = data->keylen;
 
        hash = jhash2(key, data->keylen, conncount_rnd) % CONNCOUNT_SLOTS;
        root = &data->root[hash];
@@ -414,7 +412,7 @@ count_tree(struct net *net,
 
                rbconn = rb_entry(parent, struct nf_conncount_rb, node);
 
-               diff = key_diff(key, rbconn->key, keylen);
+               diff = key_diff(key, rbconn->key, data->keylen);
                if (diff < 0) {
                        parent = rcu_dereference_raw(parent->rb_left);
                } else if (diff > 0) {