~alpine/devel

unmaintained/lshw: fix build v1 PROPOSED

Isaac Dunham: 1
 unmaintained/lshw: fix build

 3 files changed, 205 insertions(+), 5 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.alpinelinux.org/~alpine/devel/patches/87/mbox | git am -3
Learn more about email & git

[alpine-devel] [PATCH] unmaintained/lshw: fix build Export this patch

s/__\(u*int\)/\1/g
add headers
replace sysconf(_SC_LONG_BITS) with 8*sizeof(long)
make basename() usage conform to POSIX
---
 unmaintained/lshw/APKBUILD                        |  19 +++-
 unmaintained/lshw/basename-limits-long-bits.patch |  68 ++++++++++++
 unmaintained/lshw/no-private-uint.patch           | 123 ++++++++++++++++++++++
 3 files changed, 205 insertions(+), 5 deletions(-)
 create mode 100644 unmaintained/lshw/basename-limits-long-bits.patch
 create mode 100644 unmaintained/lshw/no-private-uint.patch

diff --git a/unmaintained/lshw/APKBUILD b/unmaintained/lshw/APKBUILD
index e26bbb7..fd4d5b7 100644
--- a/unmaintained/lshw/APKBUILD
+++ b/unmaintained/lshw/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Paul Kilar <pkilar@gmail.com>
pkgname=lshw
pkgver='02.17'
pkgrel=0
pkgrel=1
pkgdesc="Hardware Lister"
url="http://ezix.org/project/wiki/HardwareLiSter"
arch="all"
@@ -12,7 +12,10 @@ depends_dev=""
makedepends="sqlite-dev"
install=""
subpackages="$pkgname-doc $pkgname-lang"
source="http://ezix.org/software/files/lshw-B.$pkgver.tar.gz"
source="http://ezix.org/software/files/lshw-B.$pkgver.tar.gz
	no-private-uint.patch
	basename-limits-long-bits.patch
	"

_builddir="$srcdir"/$pkgname-B.$pkgver
prepare() {
@@ -35,6 +38,12 @@ package() {
	make -j1 DESTDIR="$pkgdir" install
}

md5sums="a5feb796cb302850eaf5b4530888e3ed  lshw-B.02.17.tar.gz"
sha256sums="eb9cc053fa0f1e78685cb695596e73931bfb55d2377e3bc3b8b94aff4c5a489c  lshw-B.02.17.tar.gz"
sha512sums="868899dce98e786a08a2134d6e132c388d71ab0f03fa6e10881e14d7a882c1882b46bbc6bd6ddb021cfab87ad6c9fd369453c3916f0b3353027eb2d470e55d9b  lshw-B.02.17.tar.gz"
md5sums="a5feb796cb302850eaf5b4530888e3ed  lshw-B.02.17.tar.gz
4ed02e5d2246bf66c6420ca007555cfa  no-private-uint.patch
4c5aa7c045adf03577448cc59168a691  basename-limits-long-bits.patch"
sha256sums="eb9cc053fa0f1e78685cb695596e73931bfb55d2377e3bc3b8b94aff4c5a489c  lshw-B.02.17.tar.gz
2e5a3d63da8475db17fd90969bcb1930cf19d2b8da7be41edeea5c2a53878382  no-private-uint.patch
c8365f7ac8fc7a751c78d89ab446111bb1a235bc977a1b21e1b826c2e62361d1  basename-limits-long-bits.patch"
sha512sums="868899dce98e786a08a2134d6e132c388d71ab0f03fa6e10881e14d7a882c1882b46bbc6bd6ddb021cfab87ad6c9fd369453c3916f0b3353027eb2d470e55d9b  lshw-B.02.17.tar.gz
6cd1e4e1e5972bfff2dd159ffc4a1a38157598f993ad927afc70f067496e461c2a25d9721c4773bda6465750b9125f9eb3d89e0b83b1842fafcf552262276da8  no-private-uint.patch
50005efd1f9a77495f5acb36e4d6bbec0a2e22cf8ce3b17f28e6be738bfc1d6943fb9adf38a2414a719df0b8ccb4be2b0f4313e441d77e3e3043b73d30566190  basename-limits-long-bits.patch"
diff --git a/unmaintained/lshw/basename-limits-long-bits.patch b/unmaintained/lshw/basename-limits-long-bits.patch
new file mode 100644
index 0000000..68c9cf9
--- /dev/null
+++ b/unmaintained/lshw/basename-limits-long-bits.patch
@@ -0,0 +1,68 @@
commit 9389deed8b49a4845c51d5e7177d143cbb96718a
Author: Isaac Dunham <ibid.ag@gmail.com>
Date:   Fri Sep 12 21:45:32 2014 -0700

    Numerous less obvious fixes
    
    -sysconf(_SC_LONG_BIT) is 8*sizeof(long)
    -POSIX basename() requires a char *, not const char*
    -limits.h is necessary for PATH_MAX

diff --git a/src/core/abi.cc b/src/core/abi.cc
index 5fdd8e3..7f78d4b 100644
--- a/src/core/abi.cc
+++ b/src/core/abi.cc
@@ -19,7 +19,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 ?
-  system.setWidth(sysconf(_SC_LONG_BIT));
+  system.setWidth(8*sizeof(long));
 
   pushd(PROC_SYS);
 
diff --git a/src/core/cpufreq.cc b/src/core/cpufreq.cc
index da3960f..aa0df00 100644
--- a/src/core/cpufreq.cc
+++ b/src/core/cpufreq.cc
@@ -17,6 +17,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <dirent.h>
+#include <limits.h>
 
 __ID("@(#) $Id: cpufreq.cc 2470 2012-01-19 12:04:26Z lyonel $");
 
diff --git a/src/core/pci.cc b/src/core/pci.cc
index aaa257c..b8a7917 100644
--- a/src/core/pci.cc
+++ b/src/core/pci.cc
@@ -12,6 +12,8 @@
 #include <string.h>
 #include <stdlib.h>
 #include <dirent.h>
+#include <libgen.h>
+#include <limits.h>
 
 __ID("@(#) $Id: pci.cc 2496 2012-05-15 08:00:13Z lyonel $");
 
@@ -1127,10 +1129,16 @@ bool scan_pci(hwNode & n)
         {
           string drivername = readlink(string(devices[i]->d_name)+"/driver");
           string modulename = readlink(string(devices[i]->d_name)+"/driver/module");
-
-          device->setConfig("driver", basename(drivername.c_str()));
+	  char driver_c[PATH_MAX];
+	  char module_c[PATH_MAX];
+	  bzero(driver_c,PATH_MAX);
+	  bzero(module_c,PATH_MAX);
+	  strncpy(driver_c, drivername.c_str(),PATH_MAX);
+	  strncpy(module_c, modulename.c_str(),PATH_MAX);
+
+          device->setConfig("driver", basename(driver_c));
           if(exists(modulename))
-            device->setConfig("module", basename(modulename.c_str()));
+            device->setConfig("module", basename(module_c));
 
           if(exists(string(devices[i]->d_name)+"/rom"))
           {
diff --git a/unmaintained/lshw/no-private-uint.patch b/unmaintained/lshw/no-private-uint.patch
new file mode 100644
index 0000000..1c67d57
--- /dev/null
+++ b/unmaintained/lshw/no-private-uint.patch
@@ -0,0 +1,123 @@
commit 4928bab9086d6e9610413f15675babdf5566c5ce
Author: Isaac Dunham <ibid.ag@gmail.com>
Date:   Fri Sep 12 21:19:19 2014 -0700

    Uncruftify: remove __ from uint*_t

diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
index 5c3d654..fd38b2f 100644
--- a/src/core/device-tree.cc
+++ b/src/core/device-tree.cc
@@ -24,13 +24,13 @@
 __ID("@(#) $Id: device-tree.cc 2521 2013-05-08 13:43:30Z lyonel $");
 
 #define DIMMINFOSIZE 0x80
-typedef __uint8_t dimminfo_buf[DIMMINFOSIZE];
+typedef uint8_t dimminfo_buf[DIMMINFOSIZE];
 
 struct dimminfo
 {
-  __uint8_t version3;
+  uint8_t version3;
   char serial[16];
-  __uint16_t version1, version2;
+  uint16_t version1, version2;
 };
 
 #define DEVICETREE "/proc/device-tree"
diff --git a/src/core/network.cc b/src/core/network.cc
index 134c887..a298d35 100644
--- a/src/core/network.cc
+++ b/src/core/network.cc
@@ -49,9 +49,9 @@ __ID("@(#) $Id: network.cc 2516 2013-02-03 16:43:25Z lyonel $");
 #define SIOCETHTOOL     0x8946
 #endif
 typedef unsigned long long u64;
-typedef __uint32_t u32;
-typedef __uint16_t u16;
-typedef __uint8_t u8;
+typedef uint32_t u32;
+typedef uint16_t u16;
+typedef uint8_t u8;
 
 struct ethtool_cmd
 {
diff --git a/src/core/osutils.cc b/src/core/osutils.cc
index fd19288..f9ce76c 100644
--- a/src/core/osutils.cc
+++ b/src/core/osutils.cc
@@ -496,48 +496,48 @@ string escapecomment(const string & s)
 
 unsigned short be_short(const void * from)
 {
-  __uint8_t *p = (__uint8_t*)from;
+  uint8_t *p = (uint8_t*)from;
 
-  return ((__uint16_t)(p[0]) << 8) +
-    (__uint16_t)p[1];
+  return ((uint16_t)(p[0]) << 8) +
+    (uint16_t)p[1];
 }
 
 
 unsigned short le_short(const void * from)
 {
-  __uint8_t *p = (__uint8_t*)from;
+  uint8_t *p = (uint8_t*)from;
 
-  return ((__uint16_t)(p[1]) << 8) +
-    (__uint16_t)p[0];
+  return ((uint16_t)(p[1]) << 8) +
+    (uint16_t)p[0];
 }
 
 
 unsigned long be_long(const void * from)
 {
-  __uint8_t *p = (__uint8_t*)from;
+  uint8_t *p = (uint8_t*)from;
 
-  return ((__uint32_t)(p[0]) << 24) +
-    ((__uint32_t)(p[1]) << 16) +
-    ((__uint32_t)(p[2]) << 8) +
-    (__uint32_t)p[3];
+  return ((uint32_t)(p[0]) << 24) +
+    ((uint32_t)(p[1]) << 16) +
+    ((uint32_t)(p[2]) << 8) +
+    (uint32_t)p[3];
 }
 
 
 unsigned long le_long(const void * from)
 {
-  __uint8_t *p = (__uint8_t*)from;
+  uint8_t *p = (uint8_t*)from;
 
-  return ((__uint32_t)(p[3]) << 24) +
-    ((__uint32_t)(p[2]) << 16) +
-    ((__uint32_t)(p[1]) << 8) +
-    (__uint32_t)p[0];
+  return ((uint32_t)(p[3]) << 24) +
+    ((uint32_t)(p[2]) << 16) +
+    ((uint32_t)(p[1]) << 8) +
+    (uint32_t)p[0];
 
 }
 
 
 unsigned long long be_longlong(const void * from)
 {
-  __uint8_t *p = (__uint8_t*)from;
+  uint8_t *p = (uint8_t*)from;
 
   return ((unsigned long long)(p[0]) << 56) +
     ((unsigned long long)(p[1]) << 48) +
@@ -552,7 +552,7 @@ unsigned long long be_longlong(const void * from)
 
 unsigned long long le_longlong(const void * from)
 {
-  __uint8_t *p = (__uint8_t*)from;
+  uint8_t *p = (uint8_t*)from;
 
   return ((unsigned long long)(p[7]) << 56) +
     ((unsigned long long)(p[6]) << 48) +
-- 
2.1.0



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---