Skip to contentSkip to conversation

mdadm: Drop redundant patches and fix build with clang

PATCH Superseded Khem Raj 2 participants 4 messages Dec 8, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 mdadm: Drop redundant patches and fix build with clang

Several patches were being applied unnecessarily, the purpose they served at one point has either been fixed differently, or accepted upstream.

Add a new patch to make clang's diagnostics happy

---
 ...abs-diff-in-a-standard-compliant-way.patch |  31 ++++
 .../files/0001-Disable-gcc8-warnings.patch    | 152 ------------------
 ...smacros.h-for-major-minor-defintions.patch |  44 -----
 ...h-Undefine-dprintf-before-redefining.patch |  39 -----
 ...omment-to-indicate-valid-fallthrough.patch | 124 --------------
 .../mdadm/files/gcc-4.9.patch                 |  31 ----
 .../files/mdadm-fix-ptest-build-errors.patch  |  43 -----
 meta/recipes-extended/mdadm/mdadm_4.1.bb      |  20 +--
 8 files changed, 39 insertions(+), 445 deletions(-)
 create mode 100644 meta/recipes-extended/mdadm/files/0001-Compute-abs-diff-in-a-standard-compliant-way.patch
 delete mode 100644 meta/recipes-extended/mdadm/files/0001-Disable-gcc8-warnings.patch
 delete mode 100644 meta/recipes-extended/mdadm/files/0001-include-sys-sysmacros.h-for-major-minor-defintions.patch
 delete mode 100644 meta/recipes-extended/mdadm/files/0001-mdadm.h-Undefine-dprintf-before-redefining.patch
 delete mode 100644 meta/recipes-extended/mdadm/files/0005-Add-a-comment-to-indicate-valid-fallthrough.patch
 delete mode 100644 meta/recipes-extended/mdadm/files/gcc-4.9.patch
 delete mode 100644 meta/recipes-extended/mdadm/files/mdadm-fix-ptest-build-errors.patch
meta/recipes-extended/mdadm/files/0001-Compute-abs-diff-in-a-standard-compliant-way.patch new file +31 -0
new file mode 100644
index 0000000000..803a59b3ec
@@ -0,0 +1,31 @@
+From b273e892bd6aaafe448f84356abb78a6d463e784 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Fri, 7 Dec 2018 17:22:39 -0800
+Subject: [PATCH] Compute abs diff in a standard compliant way
+
+This make it a bit less implementation defined and silences clang
+warning -Wabsolute-value
+
+| super-intel.c:2822:20: error: taking the absolute value of unsigned type 'unsi
+gned long long' has no effect [-Werror,-Wabsolute-value]
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ super-intel.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/super-intel.c b/super-intel.c
+index 6438987..10d7218 100644
+--- a/super-intel.c
++++ b/super-intel.c
+@@ -2819,7 +2819,7 @@ static unsigned long long calc_component_size(struct imsm_map *map,
+ 	 * 2048 blocks per each device. If the difference is higher it means
+ 	 * that array size was expanded and num_data_stripes was not updated.
+ 	 */
+-	if ((unsigned int)abs(calc_dev_size - dev_size) >
++	if ((unsigned int)abs((int)calc_dev_size - (int)dev_size) >
+ 	    (1 << SECT_PER_MB_SHIFT) * member_disks) {
+ 		component_size = dev_size / member_disks;
+ 		dprintf("Invalid num_data_stripes in metadata; expected=%llu, found=%llu\n",
meta/recipes-extended/mdadm/files/0001-Disable-gcc8-warnings.patch deleted +0 -152

152 lines not on this page · raw message

meta/recipes-extended/mdadm/files/0001-include-sys-sysmacros.h-for-major-minor-defintions.patch deleted +0 -44

44 lines not on this page · raw message

meta/recipes-extended/mdadm/files/0001-mdadm.h-Undefine-dprintf-before-redefining.patch deleted +0 -39
deleted file mode 100644
index a1e7e59323..0000000000
@@ -1,39 +0,0 @@
-From b431cb4e1ed060122fa300dc0008f74080d38f73 Mon Sep 17 00:00:00 2001
-From: Khem Raj <[email protected]>
-Date: Mon, 9 May 2016 22:03:57 +0000
-Subject: [PATCH] mdadm.h: Undefine dprintf before redefining
-
-dprintf is also defined in libc see
-usr/include/bits/stdio2.h, this comes into
-play especially when fortify sources is enabled
-and compilers like clang reports the override
-
-In file included from policy.c:25:
-./mdadm.h:1562:9: error: 'dprintf' macro redefined [-Werror,-Wmacro-redefined]
-        ^
-/mnt/oe/openembedded-core/build/tmp-glibc/sysroots/qemux86/usr/include/bits/stdio2.h:145:12: note: previous definition is here
-
-Signed-off-by: Khem Raj <[email protected]>
-Upstream-Status: Pending
----
- mdadm.h | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/mdadm.h b/mdadm.h
-index 387e681..bb943bf 100644
---- a/mdadm.h
-+++ b/mdadm.h
-@@ -1649,11 +1649,13 @@ static inline char *to_subarray(struct mdstat_ent *ent, char *container)
- }
- 
- #ifdef DEBUG
-+#undef dprintf
- #define dprintf(fmt, arg...) \
- 	fprintf(stderr, "%s: %s: "fmt, Name, __func__, ##arg)
- #define dprintf_cont(fmt, arg...) \
- 	fprintf(stderr, fmt, ##arg)
- #else
-+#undef dprintf
- #define dprintf(fmt, arg...) \
-         ({ if (0) fprintf(stderr, "%s: %s: " fmt, Name, __func__, ##arg); 0; })
- #define dprintf_cont(fmt, arg...) \
meta/recipes-extended/mdadm/files/0005-Add-a-comment-to-indicate-valid-fallthrough.patch deleted +0 -124

124 lines not on this page · raw message

meta/recipes-extended/mdadm/files/gcc-4.9.patch deleted +0 -31
deleted file mode 100644
index 473fd7821b..0000000000
@@ -1,31 +0,0 @@
-From 8804bca3de1b79a7c579783b7e3a7603f43bbb48 Mon Sep 17 00:00:00 2001
-From: Khem Raj <[email protected]>
-Date: Fri, 2 May 2014 16:31:17 -0700
-Subject: [PATCH] mdadm: Fix build on gcc 4.9
-
-super-intel.c:5063:2: error: right-hand operand of comma expression has no effect [-Werror=unused-value]
-  snprintf((char *) spare->sig, MAX_SIGNATURE_LENGTH,
-  ^
-cc1: all warnings being treated as errors
-make: *** [super-intel.o] Error 1
-
-Signed-off-by: Khem Raj <[email protected]>
-Upstream-Status: Pending
-
----
- super-intel.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/super-intel.c b/super-intel.c
-index 6438987..e726987 100644
---- a/super-intel.c
-+++ b/super-intel.c
-@@ -5941,7 +5941,7 @@ static int write_super_imsm_spares(struct intel_super *super, int doclose)
- 	spare->cache_size = mpb->cache_size;
- 	spare->pwr_cycle_count = __cpu_to_le32(1);
- 
--	snprintf((char *) spare->sig, MAX_SIGNATURE_LENGTH,
-+	(void)snprintf((char *) spare->sig, MAX_SIGNATURE_LENGTH,
- 		 MPB_SIGNATURE MPB_VERSION_RAID0);
- 
- 	for (d = super->disks; d; d = d->next) {
meta/recipes-extended/mdadm/files/mdadm-fix-ptest-build-errors.patch deleted +0 -43

43 lines not on this page · raw message

meta/recipes-extended/mdadm/mdadm_4.1.bb +8 -12
index b9f55841cb..f4a2581308 100644
@@ -9,24 +9,19 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
 
 
 SRC_URI = "${KERNELORG_MIRROR}/linux/utils/raid/mdadm/${BPN}-${PV}.tar.xz \
-           file://gcc-4.9.patch \
+           file://run-ptest \
            file://mdadm-3.3.2_x32_abi_time_t.patch \
-           file://mdadm-fix-ptest-build-errors.patch \
            file://0001-Fix-the-path-of-corosync-and-dlm-header-files-check.patch \
-           file://run-ptest \
-           file://0001-mdadm.h-Undefine-dprintf-before-redefining.patch \
-           file://0001-include-sys-sysmacros.h-for-major-minor-defintions.patch \
-           file://0005-Add-a-comment-to-indicate-valid-fallthrough.patch \
            file://0001-Use-CC-to-check-for-implicit-fallthrough-warning-sup.patch \
-           file://0001-Disable-gcc8-warnings.patch \
+           file://0001-Compute-abs-diff-in-a-standard-compliant-way.patch \
            "
 SRC_URI[md5sum] = "51bf3651bd73a06c413a2f964f299598"
 SRC_URI[sha256sum] = "ab7688842908d3583a704d491956f31324c3a5fc9f6a04653cb75d19f1934f4a"
 
-CFLAGS += "-fno-strict-aliasing"
-inherit autotools-brokensep
+inherit autotools-brokensep ptest
+
+CFLAGS_append_toolchain-clang = " -Wno-error=address-of-packed-member"
 
-EXTRA_OEMAKE = 'CHECK_RUN_DIR=0 CXFLAGS="${CFLAGS}"'
 # PPC64 and MIPS64 uses long long for u64 in the kernel, but powerpc's asm/types.h
 # prevents 64-bit userland from seeing this definition, instead defaulting
 # to u64 == long in userspace. Define __SANE_USERSPACE_TYPES__ to get
@@ -35,6 +30,8 @@ CFLAGS_append_powerpc64 = ' -D__SANE_USERSPACE_TYPES__'
 CFLAGS_append_mipsarchn64 = ' -D__SANE_USERSPACE_TYPES__'
 CFLAGS_append_mipsarchn32 = ' -D__SANE_USERSPACE_TYPES__'
 
+EXTRA_OEMAKE = 'CHECK_RUN_DIR=0 CXFLAGS="${CFLAGS}"'
+
 do_compile() {
 	# Point to right sbindir
 	sed -i -e "s;BINDIR  = /sbin;BINDIR = $base_sbindir;" -e "s;UDEVDIR = /lib;UDEVDIR = $nonarch_base_libdir;" ${S}/Makefile
@@ -46,8 +43,6 @@ do_install() {
 	autotools_do_install
 }
 
-inherit ptest
-
 do_compile_ptest() {
 	oe_runmake test
 }
@@ -62,6 +57,7 @@ do_install_ptest() {
 		install -D -m 755 $prg ${D}${PTEST_PATH}/
 	done
 }
+
 RDEPENDS_${PN}-ptest += "bash"
 RRECOMMENDS_${PN}-ptest += " \
     coreutils \
Signature · 1 line
2.19.2
author
#1 lore raw

PATCH 2/2 nfs-utils: Fix build with clang

---
 .../nfs-utils/clang-format-string.patch       | 183 ++++++++++++++++++
 .../nfs-utils/nfs-utils_2.3.3.bb              |   2 +-
 2 files changed, 184 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/clang-format-string.patch
meta/recipes-connectivity/nfs-utils/nfs-utils/clang-format-string.patch new file +183 -0
new file mode 100644
index 0000000000..1d693e4142
@@ -0,0 +1,183 @@
+Clang comes up with more printf format warnings
+Correcting “format string is not a string literal” warning
+requires us to declare that parameter is a printf style 
+format using the attribute flag
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <[email protected]>
+
+Index: nfs-utils-2.3.3/support/include/xcommon.h
+===================================================================
+--- nfs-utils-2.3.3.orig/support/include/xcommon.h
++++ nfs-utils-2.3.3/support/include/xcommon.h
+@@ -27,7 +27,7 @@
+ 
+ /* Functions in sundries.c that are used in mount.c and umount.c  */ 
+ char *canonicalize (const char *path);
+-void nfs_error (const char *fmt, ...);
++void nfs_error (const char *fmt, ...) __attribute__((__format__ (__printf__, 1, 2)));
+ void *xmalloc (size_t size);
+ void *xrealloc(void *p, size_t size);
+ void xfree(void *);
+@@ -36,9 +36,9 @@ char *xstrndup (const char *s, int n);
+ char *xstrconcat2 (const char *, const char *);
+ char *xstrconcat3 (const char *, const char *, const char *);
+ char *xstrconcat4 (const char *, const char *, const char *, const char *);
+-void die (int errcode, const char *fmt, ...);
++void die (int errcode, const char *fmt, ...) __attribute__((__format__ (__printf__, 2, 3)));
+ 
+-extern void die(int err, const char *fmt, ...);
++extern void die(int err, const char *fmt, ...) __attribute__((__format__ (__printf__, 2, 3)));
+ extern void (*at_die)(void);
+ 
+ /* exit status - bits below are ORed */
+Index: nfs-utils-2.3.3/support/include/xlog.h
+===================================================================
+--- nfs-utils-2.3.3.orig/support/include/xlog.h
++++ nfs-utils-2.3.3/support/include/xlog.h
+@@ -43,10 +43,10 @@ void			xlog_config(int fac, int on);
+ void			xlog_sconfig(char *, int on);
+ void			xlog_from_conffile(char *);
+ int			xlog_enabled(int fac);
+-void			xlog(int fac, const char *fmt, ...);
+-void			xlog_warn(const char *fmt, ...);
+-void			xlog_err(const char *fmt, ...);
+-void			xlog_errno(int err, const char *fmt, ...);
+-void			xlog_backend(int fac, const char *fmt, va_list args);
++void			xlog(int fac, const char *fmt, ...) __attribute__((__format__ (__printf__, 2, 3)));
++void			xlog_warn(const char *fmt, ...) __attribute__((__format__ (__printf__, 1, 2)));
++void			xlog_err(const char *fmt, ...) __attribute__((__format__ (__printf__, 1, 2)));
++void			xlog_errno(int err, const char *fmt, ...) __attribute__((__format__ (__printf__, 2, 3)));
++void			xlog_backend(int fac, const char *fmt, va_list args) __attribute__((__format__ (__printf__, 2, 0)));
+ 
+ #endif /* XLOG_H */
+Index: nfs-utils-2.3.3/support/nfs/xcommon.c
+===================================================================
+--- nfs-utils-2.3.3.orig/support/nfs/xcommon.c
++++ nfs-utils-2.3.3/support/nfs/xcommon.c
+@@ -93,7 +93,10 @@ nfs_error (const char *fmt, ...) {
+ 
+      fmt2 = xstrconcat2 (fmt, "\n");
+      va_start (args, fmt);
++#pragma clang diagnostic push
++#pragma clang diagnostic ignored "-Wformat-nonliteral"
+      vfprintf (stderr, fmt2, args);
++#pragma clang diagnostic pop
+      va_end (args);
+      free (fmt2);
+ }
+Index: nfs-utils-2.3.3/utils/exportfs/exportfs.c
+===================================================================
+--- nfs-utils-2.3.3.orig/utils/exportfs/exportfs.c
++++ nfs-utils-2.3.3/utils/exportfs/exportfs.c
+@@ -644,6 +644,7 @@ out:
+ 	return result;
+ }
+ 
++__attribute__((__format__ (__printf__, 2, 3)))
+ static char
+ dumpopt(char c, char *fmt, ...)
+ {
+Index: nfs-utils-2.3.3/utils/statd/statd.c
+===================================================================
+--- nfs-utils-2.3.3.orig/utils/statd/statd.c
++++ nfs-utils-2.3.3/utils/statd/statd.c
+@@ -136,7 +136,7 @@ static void log_modes(void)
+ 	strcat(buf, "TI-RPC ");
+ #endif
+ 
+-	xlog_warn(buf);
++	xlog_warn("%s", buf);
+ }
+ 
+ /*
+Index: nfs-utils-2.3.3/support/nfs/svc_create.c
+===================================================================
+--- nfs-utils-2.3.3.orig/support/nfs/svc_create.c
++++ nfs-utils-2.3.3/support/nfs/svc_create.c
+@@ -184,7 +184,7 @@ svc_create_sock(const struct sockaddr *s
+ 		type = SOCK_STREAM;
+ 		break;
+ 	default:
+-		xlog(D_GENERAL, "%s: Unrecognized bind address semantics: %u",
++		xlog(D_GENERAL, "%s: Unrecognized bind address semantics: %lu",
+ 			__func__, nconf->nc_semantics);
+ 		return -1;
+ 	}
+Index: nfs-utils-2.3.3/support/nsm/rpc.c
+===================================================================
+--- nfs-utils-2.3.3.orig/support/nsm/rpc.c
++++ nfs-utils-2.3.3/support/nsm/rpc.c
+@@ -182,7 +182,7 @@ nsm_xmit_getport(const int sock, const s
+ 	uint32_t xid;
+ 	XDR xdr;
+ 
+-	xlog(D_CALL, "Sending PMAP_GETPORT for %u, %u, udp", program, version);
++	xlog(D_CALL, "Sending PMAP_GETPORT for %lu, %lu, udp", program, version);
+ 
+ 	nsm_init_xdrmem(msgbuf, NSM_MAXMSGSIZE, &xdr);
+ 	xid = nsm_init_rpc_header(PMAPPROG, PMAPVERS,
+Index: nfs-utils-2.3.3/utils/mountd/cache.c
+===================================================================
+--- nfs-utils-2.3.3.orig/utils/mountd/cache.c
++++ nfs-utils-2.3.3/utils/mountd/cache.c
+@@ -968,8 +968,7 @@ lookup_export(char *dom, char *path, str
+ 			} else if (found_type == i && found->m_warned == 0) {
+ 				xlog(L_WARNING, "%s exported to both %s and %s, "
+ 				     "arbitrarily choosing options from first",
+-				     path, found->m_client->m_hostname, exp->m_client->m_hostname,
+-				     dom);
++				     path, found->m_client->m_hostname, exp->m_client->m_hostname);
+ 				found->m_warned = 1;
+ 			}
+ 		}
+Index: nfs-utils-2.3.3/utils/mountd/mountd.c
+===================================================================
+--- nfs-utils-2.3.3.orig/utils/mountd/mountd.c
++++ nfs-utils-2.3.3/utils/mountd/mountd.c
+@@ -213,7 +213,7 @@ static void
+ sig_hup (int sig)
+ {
+ 	/* don't exit on SIGHUP */
+-	xlog (L_NOTICE, "Received SIGHUP... Ignoring.\n", sig);
++	xlog (L_NOTICE, "Received SIGHUP(%d)... Ignoring.\n", sig);
+ 	return;
+ }
+ 
+Index: nfs-utils-2.3.3/utils/statd/rmtcall.c
+===================================================================
+--- nfs-utils-2.3.3.orig/utils/statd/rmtcall.c
++++ nfs-utils-2.3.3/utils/statd/rmtcall.c
+@@ -247,7 +247,7 @@ process_reply(FD_SET_TYPE *rfds)
+ 		xlog_warn("%s: service %d not registered on localhost",
+ 			__func__, NL_MY_PROG(lp));
+ 	} else {
+-		xlog(D_GENERAL, "%s: Callback to %s (for %d) succeeded",
++		xlog(D_GENERAL, "%s: Callback to %s (for %s) succeeded",
+ 			__func__, NL_MY_NAME(lp), NL_MON_NAME(lp));
+ 	}
+ 	nlist_free(&notify, lp);
+Index: nfs-utils-2.3.3/utils/statd/svc_run.c
+===================================================================
+--- nfs-utils-2.3.3.orig/utils/statd/svc_run.c
++++ nfs-utils-2.3.3/utils/statd/svc_run.c
+@@ -53,6 +53,7 @@
+ 
+ #include <errno.h>
+ #include <time.h>
++#include <inttypes.h>
+ #include "statd.h"
+ #include "notlist.h"
+ 
+@@ -104,8 +105,8 @@ my_svc_run(int sockfd)
+ 
+ 			tv.tv_sec  = NL_WHEN(notify) - now;
+ 			tv.tv_usec = 0;
+-			xlog(D_GENERAL, "Waiting for reply... (timeo %d)",
+-							tv.tv_sec);
++			xlog(D_GENERAL, "Waiting for reply... (timeo %jd)",
++							(intmax_t)tv.tv_sec);
+ 			selret = select(FD_SETSIZE, &readfds,
+ 				(void *) 0, (void *) 0, &tv);
+ 		} else {
meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb +1 -1
index 572ae3146f..6be2aab47c 100644
@@ -32,8 +32,8 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
            file://nfs-utils-musl-limits.patch \
            file://0001-cacheio-use-intmax_t-for-formatted-IO.patch \
            file://0001-Do-not-pass-null-pointer-to-freeaddrinfo.patch \
+           file://clang-format-string.patch \
 "
-
 SRC_URI_append_libc-musl = " file://nfs-utils-musl-res_querydomain.patch"
 
 SRC_URI[md5sum] = "b6c9c032995af1c08fea9fbcc1ce33e9"
Signature · 1 line
2.19.2
author
#3 lore raw
Quoted 8 lines · Richard Purdie
Quoted 6 lines · Khem Raj

Several patches were being applied unnecessarily, the purpose they served at one point has either been fixed differently, or accepted upstream.

Add a new patch to make clang's diagnostics happy

Quoted 7 lines
Quoted 1 line

Sorry, it doesn't build:

https://autobuilder.yoctoproject.org/typhoon/#/builders/71/builds/45/steps/7/logs/step1b

(and several other errors)

I could see the same failure on my mips builder. We still need to keep the ptest patch. I sent a v2 just now.

Quoted 5 lines

Cheers,

Richard