aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-devtools/lshw/files/0001-Fix-musl-build.patch
blob: fa90aa1211a18b5cdbccf8fa27069c62129602ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
From a5a4bb4254b2109bd3e272174946f0bb36ee99a8 Mon Sep 17 00:00:00 2001
From: Leon Anavi <leon.anavi@konsulko.com>
Date: Tue, 25 Aug 2020 11:45:45 +0300
Subject: [PATCH] Fix musl build

Apply the following fixes for musl:

- Fix basename() is in libgen.h
- Fix wrong usage of LONG_BIT

Same fixes have been submitted to the upstream of lshw by Sergio
Prado but they have not been merged yet.

Upstream-Status: Submitted

Co-Authored-By: Sergio Prado <sergio.prado@e-labworks.com>
Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
---
 src/core/abi.cc   |  4 +---
 src/core/sysfs.cc | 19 ++++++++++---------
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/core/abi.cc b/src/core/abi.cc
index adff7b5..76c664c 100644
--- a/src/core/abi.cc
+++ b/src/core/abi.cc
@@ -20,9 +20,7 @@ __ID("@(#) $Id: mem.cc 1352 2006-05-27 23:54:13Z ezix $");
 bool scan_abi(hwNode & system)
 {
   // are we compiled as 32- or 64-bit process ?
-  long sc = sysconf(LONG_BIT);
-  if(sc==-1) sc = sysconf(_SC_LONG_BIT);
-  if(sc!=-1) system.setWidth(sc);
+  system.setWidth(LONG_BIT);
 
   pushd(PROC_SYS);
 
diff --git a/src/core/sysfs.cc b/src/core/sysfs.cc
index 32d6564..c2fa84f 100644
--- a/src/core/sysfs.cc
+++ b/src/core/sysfs.cc
@@ -16,6 +16,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/mount.h>
+#include <libgen.h>
 
 
 __ID("@(#) $Id$");
@@ -100,7 +101,7 @@ static string sysfs_getbustype(const string & path)
   {
     devname =
       string(fs.path + "/bus/") + string(namelist[i]->d_name) +
-      "/devices/" + basename(path.c_str());
+      "/devices/" + basename(const_cast<char*>(path.c_str()));
 
     if (samefile(devname, path))
       return string(namelist[i]->d_name);
@@ -140,7 +141,7 @@ static string sysfstobusinfo(const string & path)
 
   if (bustype == "usb")
   {
-    string name = basename(path.c_str());
+    string name = basename(const_cast<char*>(path.c_str()));
     if (matches(name, "^[0-9]+-[0-9]+(\\.[0-9]+)*:[0-9]+\\.[0-9]+$"))
     {
       size_t colon = name.rfind(":");
@@ -151,7 +152,7 @@ static string sysfstobusinfo(const string & path)
 
   if (bustype == "virtio")
   {
-    string name = basename(path.c_str());
+    string name = basename(const_cast<char*>(path.c_str()));
     if (name.compare(0, 6, "virtio") == 0)
       return "virtio@" + name.substr(6);
     else
@@ -159,10 +160,10 @@ static string sysfstobusinfo(const string & path)
   }
 
   if (bustype == "vio")
-    return string("vio@") + basename(path.c_str());
+    return string("vio@") + basename(const_cast<char*>(path.c_str()));
 
   if (bustype == "ccw")
-    return string("ccw@") + basename(path.c_str());
+    return string("ccw@") + basename(const_cast<char*>(path.c_str()));
 
   if (bustype == "ccwgroup")
   {
@@ -240,7 +241,7 @@ string entry::driver() const
   string driverlink = This->devpath + "/driver";
   if (!exists(driverlink))
     return "";
-  return basename(readlink(driverlink).c_str());
+  return basename(const_cast<char*>(readlink(driverlink).c_str()));
 }
 
 
@@ -328,7 +329,7 @@ string entry::name_in_class(const string & classname) const
 
 string entry::name() const
 {
-  return basename(This->devpath.c_str());
+  return basename(const_cast<char*>(This->devpath.c_str()));
 }
 
 
@@ -340,12 +341,12 @@ entry entry::parent() const
 
 string entry::classname() const
 {
-  return basename(dirname(This->devpath).c_str());
+  return basename(const_cast<char*>(dirname(This->devpath).c_str()));
 }
 
 bool entry::isvirtual() const
 {
-  return string(basename(dirname(dirname(This->devpath)).c_str())) == "virtual";
+  return string(basename(const_cast<char*>(dirname(dirname(This->devpath)).c_str()))) == "virtual";
 }
 
 string entry::string_attr(const string & name, const string & def) const
-- 
2.17.1