diff mbox series

[meta-python,1/7] python3-netifaces: Fix build with python3 and musl

Message ID 20220829065649.808556-1-raj.khem@gmail.com
State New
Headers show
Series [meta-python,1/7] python3-netifaces: Fix build with python3 and musl | expand

Commit Message

Khem Raj Aug. 29, 2022, 6:56 a.m. UTC
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...-initialize-msghdr-in-a-portable-way.patch | 49 +++++++++++++++++++
 .../python/python3-netifaces_0.11.0.bb        |  6 ++-
 2 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 meta-python/recipes-devtools/python/python3-netifaces/0001-netifaces-initialize-msghdr-in-a-portable-way.patch
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-netifaces/0001-netifaces-initialize-msghdr-in-a-portable-way.patch b/meta-python/recipes-devtools/python/python3-netifaces/0001-netifaces-initialize-msghdr-in-a-portable-way.patch
new file mode 100644
index 0000000000..7ff86cc8be
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-netifaces/0001-netifaces-initialize-msghdr-in-a-portable-way.patch
@@ -0,0 +1,49 @@ 
+From cbcd19f38ae4b31c57c57ce3619b8d2674defb68 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 28 Aug 2022 08:11:27 -0700
+Subject: [PATCH] netifaces: initialize msghdr in a portable way
+
+musl has padding bytes inside the msghdr struct which means initializing
+full structure will cause wrong assignments, doing partial assignment is
+more portable and assign the elements after that
+
+Fixes
+netifaces.c:1808:9: error: incompatible pointer to integer conversion initializing 'int' with an expression of type 'void *' [-Wint-conversion]
+        NULL,
+        ^~~~
+
+Upstream-Status: Inappropriate [Upstream Repo is read-only]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ netifaces.c | 15 ++++++---------
+ 1 file changed, 6 insertions(+), 9 deletions(-)
+
+diff --git a/netifaces.c b/netifaces.c
+index 839c42c..7da78e7 100644
+--- a/netifaces.c
++++ b/netifaces.c
+@@ -1800,15 +1800,12 @@ gateways (PyObject *self)
+     do {
+       struct sockaddr_nl sanl_from;
+       struct iovec iov = { msgbuf, bufsize };
+-      struct msghdr msghdr = {
+-        &sanl_from,
+-        sizeof(sanl_from),
+-        &iov,
+-        1,
+-        NULL,
+-        0,
+-        0
+-      };
++      struct msghdr msghdr = { 0 };
++
++      msghdr.msg_name = &sanl_from;
++      msghdr.msg_namelen = sizeof(sanl_from);
++      msghdr.msg_iov = &iov;
++      msghdr.msg_iovlen = 1;
+       int nllen;
+ 
+       ret = recvmsg (s, &msghdr, 0);
+-- 
+2.37.2
+
diff --git a/meta-python/recipes-devtools/python/python3-netifaces_0.11.0.bb b/meta-python/recipes-devtools/python/python3-netifaces_0.11.0.bb
index 09e54b0baa..f211c69543 100644
--- a/meta-python/recipes-devtools/python/python3-netifaces_0.11.0.bb
+++ b/meta-python/recipes-devtools/python/python3-netifaces_0.11.0.bb
@@ -4,6 +4,8 @@  SECTION = "devel/python"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=a53cbc7cb75660694e138ba973c148df"
 
-SRC_URI[sha256sum] = "043a79146eb2907edf439899f262b3dfe41717d34124298ed281139a8b93ca32"
-
 inherit pypi setuptools3
+
+SRC_URI += "file://0001-netifaces-initialize-msghdr-in-a-portable-way.patch"
+
+SRC_URI[sha256sum] = "043a79146eb2907edf439899f262b3dfe41717d34124298ed281139a8b93ca32"