From 3a11b7243581fa2878678a956cd3823f733e19b2 Mon Sep 17 00:00:00 2001 From: liyuan Date: Thu, 21 Dec 2023 16:27:38 +0800 Subject: [PATCH] backport Fix two gcc-11 compiler warnings --- ...ort-Fix-two-gcc-11-compiler-warnings.patch | 67 +++++++++++++++++++ fcoe-utils.spec | 6 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 backport-Fix-two-gcc-11-compiler-warnings.patch diff --git a/backport-Fix-two-gcc-11-compiler-warnings.patch b/backport-Fix-two-gcc-11-compiler-warnings.patch new file mode 100644 index 0000000..ba19c8b --- /dev/null +++ b/backport-Fix-two-gcc-11-compiler-warnings.patch @@ -0,0 +1,67 @@ +From 66616e988778c45a316d6b286fda732843f25297 Mon Sep 17 00:00:00 2001 +From: Lee Duncan +Date: Mon, 22 Mar 2021 18:28:33 -0700 +Subject: [PATCH] Fix two gcc-11 compiler warnings. + +Gcc-11 is aggressive about gaurding against array copies. So be +clear about what we want to copy, and where we are copying it. + +Changes from V1: +* simplified both cases based on review comments +* no need to copy the data twice +--- + fcping.c | 8 ++++++-- + fipvlan.c | 11 +++++++++-- + 2 files changed, 15 insertions(+), 4 deletions(-) + +diff --git a/fcping.c b/fcping.c +index bf2bc0f0c78..21830a52524 100644 +--- a/fcping.c ++++ b/fcping.c +@@ -570,6 +570,7 @@ fp_ns_get_id(uint32_t op, fc_wwn_t wwn, char *response, size_t *resp_len) + struct sg_io_v4 sg_io; + size_t actual_len; + int cmd, rc = 0; ++ uint32_t *uct = (uint32_t *)&ct.hdr; + + memset((char *)&cdb, 0, sizeof(cdb)); + memset(&ct, 0, sizeof(ct)); +@@ -584,8 +585,11 @@ fp_ns_get_id(uint32_t op, fc_wwn_t wwn, char *response, size_t *resp_len) + + cdb.msgcode = FC_BSG_HST_CT; + hton24(cdb.rqst_data.h_ct.port_id, 0xfffffc); +- memcpy(&cdb.rqst_data.h_ct.preamble_word0, &ct.hdr, +- 3 * sizeof(uint32_t)); ++ ++ /* copy preamble words one at a time, to make compiler happy */ ++ cdb.rqst_data.h_ct.preamble_word0 = uct[0]; ++ cdb.rqst_data.h_ct.preamble_word1 = uct[1]; ++ cdb.rqst_data.h_ct.preamble_word2 = uct[2]; + + sg_io.guard = 'Q'; + sg_io.protocol = BSG_PROTOCOL_SCSI; +diff --git a/fipvlan.c b/fipvlan.c +index c8a07339314..4433c0abf76 100644 +--- a/fipvlan.c ++++ b/fipvlan.c +@@ -447,8 +447,15 @@ static void rtnl_recv_newlink(struct nlmsghdr *nh) + iff->iflink = *(int *)RTA_DATA(ifla[IFLA_LINK]); + else + iff->iflink = iff->ifindex; +- memcpy(iff->mac_addr, RTA_DATA(ifla[IFLA_ADDRESS]), ETHER_ADDR_LEN); +- strncpy(iff->ifname, RTA_DATA(ifla[IFLA_IFNAME]), IFNAMSIZ); ++ ++ /* ++ * copy MAC address and interface name using intermediate ++ * arrays, so gcc-11 knows we are not overflowing buffers ++ */ ++ if (ifla[IFLA_ADDRESS]) ++ memcpy(iff->mac_addr, RTA_DATA(ifla[IFLA_ADDRESS]), ETHER_ADDR_LEN); ++ if (ifla[IFLA_IFNAME]) ++ memcpy(iff->ifname, RTA_DATA(ifla[IFLA_IFNAME]), IFNAMSIZ); + iff->ifname[IFNAMSIZ - 1] = '\0'; + + if (ifla[IFLA_LINKINFO]) { +-- +2.33.0 + diff --git a/fcoe-utils.spec b/fcoe-utils.spec index d6d3f40..f2e546c 100644 --- a/fcoe-utils.spec +++ b/fcoe-utils.spec @@ -1,6 +1,6 @@ Name: fcoe-utils Version: 1.0.33 -Release: 5 +Release: 6 Summary: Fibre Channel over Ethernet utilities License: GPLv2 URL: https://github.com/morbidrsa/fcoe-utils @@ -14,6 +14,7 @@ Patch3: backport-03-use-of-uninitialized-values-detected-during-LTO. Patch4: backport-Fix-build-error-to-change-char-type.patch Patch5: backport-handle-NIC-names-longer-than-7-characters.patch Patch6: bachport-Fix-GCC-12-warning.patch +Patch7: backport-Fix-two-gcc-11-compiler-warnings.patch BuildRequires: autoconf automake libpciaccess-devel libtool lldpad-devel systemd Requires: lldpad iproute device-mapper-multipath @@ -69,6 +70,9 @@ done %{_mandir}/man8/* %changelog +* Thu Dec 21 2023 liyuanyuan - 1.0.33-6 +- Fix two gcc-11 compiler warnings + * Fri Dec 30 2022 xulei - 1.0.33-5 - Backport upstream patch to fix GCC 12 warning. -- Gitee