SHA256
1
0
forked from pool/drbd
drbd/bsc-1206791-02-drbd-fix-static-analysis-warnings.patch
heming zhao 4e5f7cbf78 Accepting request 1056192 from home:hmzhao:branches:network:ha-clustering:Factory
- drbd: fix build error against kernel v6.1.1 (bsc#1206791)
  * update bsc-1201335_06-bdi.patch commit log (no code change)
    + bsc-1201335_06-bdi.patch
  * update bsc-1202600_02-dax-introduce-DAX_RECOVERY_WRITE-dax-access-mode.patch (no code change)
    + bsc-1202600_02-dax-introduce-DAX_RECOVERY_WRITE-dax-access-mode.patch
  * using upstream patch to replace exist patch
    - bsc-1204596_02-drbd-stop-using-bdevname-in-drbd_report_io_error.patch
    + bsc-1204596_02-drbd-remove-usage-of-bdevname.patch
  * add new patches
    + bsc-1206791-01-drbd-add-comments-explaining-removal-of-bdi-congesti.patch
    + bsc-1206791-02-drbd-fix-static-analysis-warnings.patch
    + bsc-1206791-03-drbd-fix-warning-about-initializing-multiple-struct-.patch
    + bsc-1206791-04-blk_queue_split__no_present.patch
    + bsc-1206791-05-prandom_u32_max.patch
    + bsc-1206791-06-write_zeroes__no_capable.patch
    + bsc-1206791-07-drbd-fix-use-after-free-bugs-in-get_initial_state.patch
    + bsc-1206791-08-lib-lru_cache-Fixed-array-overflow-caused-by-incorre.patch
    + bsc-1206791-09-pmem-use-fs_dax_get_by_bdev-instead-of-dax_get_by_ho.patch

OBS-URL: https://build.opensuse.org/request/show/1056192
OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/drbd?expand=0&rev=142
2023-01-05 13:24:33 +00:00

89 lines
3.3 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From f465ef1a70c7b559fcf3924e450bc5e836e448de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?=
<christoph.boehmwalder@linbit.com>
Date: Mon, 3 Oct 2022 15:56:44 +0200
Subject: [PATCH] drbd: fix static analysis warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
GCC now does some pretty impressive static analysis, and it spits out
some warnings when compiling DRBD. Newer kernels "unfortunately" set
-Werror, which forces us to stop sweeping these under the rug.
This commits fixes two distinct classes of warning.
First, if a netlink field is declared with DRBD_GENLA_F_MANDATORY, it
can never be NULL. The compiler catches this and complains:
drbd_nl.c:3490:53: warning: the comparison will always evaluate
as true for the address of integrity_alg
will never be NULL [-Waddress]
3490 | if (!new_net_conf->integrity_alg != !old_net_conf->integrity_alg)
| ^
And similarly for net_conf->name. The fix is simple: just remove the
checks.
The other warning that is fixed is:
drbd_main.c:421:55: warning: unused variable ddm [-Wunused-variable]
421 | DEFINE_DYNAMIC_DEBUG_METADATA(ddm, "Bad barrier ack dump");
| ^~~
Which happens when dynamic debug is not enabled, erasing the
DYNAMIC_DEBUG_BRANCH(ddm) below.
This is easily fixed by "accessing" the declared variable by doing a
dummy cast to void.
Finally, the compiler complains that the DYNAMIC_DEBUG macros are
redefined in drbd_polymorph_printk.h, so #undef them before #defining
them.
---
drbd/drbd_nl.c | 5 +----
drbd/drbd_polymorph_printk.h | 5 ++++-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c
index 6a2afd184ae6..de064215b638 100644
--- a/drbd/drbd_nl.c
+++ b/drbd/drbd_nl.c
@@ -3553,9 +3553,6 @@ _check_net_options(struct drbd_connection *connection, struct net_conf *old_net_
if (new_net_conf->two_primaries != old_net_conf->two_primaries)
return ERR_NEED_APV_100;
- if (!new_net_conf->integrity_alg != !old_net_conf->integrity_alg)
- return ERR_NEED_APV_100;
-
if (strcmp(new_net_conf->integrity_alg, old_net_conf->integrity_alg))
return ERR_NEED_APV_100;
}
@@ -5398,7 +5395,7 @@ static int nla_put_drbd_cfg_context(struct sk_buff *skb,
if (connection) {
nla_put_u32(skb, T_ctx_peer_node_id, connection->peer_node_id);
rcu_read_lock();
- if (connection->transport.net_conf && connection->transport.net_conf->name)
+ if (connection->transport.net_conf)
nla_put_string(skb, T_ctx_conn_name, connection->transport.net_conf->name);
rcu_read_unlock();
}
diff --git a/drbd/drbd_polymorph_printk.h b/drbd/drbd_polymorph_printk.h
index 1ce6cc2e6f74..4e7f2f17014e 100644
--- a/drbd/drbd_polymorph_printk.h
+++ b/drbd/drbd_polymorph_printk.h
@@ -2,7 +2,10 @@
#define DRBD_POLYMORPH_PRINTK_H
#if !defined(CONFIG_DYNAMIC_DEBUG)
-#define DEFINE_DYNAMIC_DEBUG_METADATA(D, F) const char *D = F
+#undef DEFINE_DYNAMIC_DEBUG_METADATA
+#undef __dynamic_pr_debug
+#undef DYNAMIC_DEBUG_BRANCH
+#define DEFINE_DYNAMIC_DEBUG_METADATA(D, F) const char *D = F; ((void)D)
#define __dynamic_pr_debug(D, F, args...) do { (void)(D); if (0) printk(F, ## args); } while(0)
#define DYNAMIC_DEBUG_BRANCH(D) false
#endif
--
2.26.2