Skip to contentSkip to conversation

samhain: fix compile for powerpc

PATCH New kai 1 participant 1 message Mar 11, 2021

lore
Share & tools
lore

kai

author
#0 lore raw

PATCH 1/1 samhain: fix compile for powerpc

From: Kai Kang <[email protected]>

It fails to comile samhain for powerpc(qemuppc):

| x_sh_dbIO.c: In function 'swap_short':
| x_sh_dbIO.c:229:36: error: initializer element is not constant
|   229 |       static unsigned short ooop = *iptr;
|       |                                    ^

Fix it by not use local static variable.

---
 ...-initializer-element-is-not-constant.patch | 32 +++++++++++++++++++
 recipes-ids/samhain/samhain.inc               |  1 +
 2 files changed, 33 insertions(+)
 create mode 100644 recipes-ids/samhain/files/samhain-fix-initializer-element-is-not-constant.patch
recipes-ids/samhain/files/samhain-fix-initializer-element-is-not-constant.patch new file +32 -0
new file mode 100644
index 0000000..846e132
@@ -0,0 +1,32 @@
+Fix error when compile for powerpc:
+
+| x_sh_dbIO.c: In function 'swap_short':
+| x_sh_dbIO.c:229:36: error: initializer element is not constant
+|   229 |       static unsigned short ooop = *iptr;
+|       |                                    ^
+
+Upstream-Status: Pending
+
+Signed-off-by: Kai Kang <[email protected]>
+---
+ src/sh_dbIO.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sh_dbIO.c b/src/sh_dbIO.c
+index b547ac5..7516463 100644
+--- a/src/sh_dbIO.c
++++ b/src/sh_dbIO.c
+@@ -226,11 +226,11 @@ static unsigned short *  swap_short (unsigned short * iptr)
+   else
+     {
+       /* alignment problem */
+-      static unsigned short ooop = *iptr;
++      unsigned short ooop = *iptr;
+       unsigned short hi   = (ooop & 0xff00);
+       unsigned short lo   = (ooop & 0xff);
+       ooop = (lo << 8) | (hi >> 8);
+-      return &ooop;
++      *iptr = ooop;
+     }
+   return iptr;
+ #else
recipes-ids/samhain/samhain.inc +1 -0
index 6a2eb08..0148e46 100644
@@ -18,6 +18,7 @@ SRC_URI = "https://la-samhna.de/archive/samhain_signed-${PV}.tar.gz \
            file://samhain-avoid-searching-host-for-postgresql.patch \
            file://samhain-add-LDFLAGS-variable-for-samhain_setpwd.patch \
            file://fix-build-with-new-version-attr.patch \
+           file://samhain-fix-initializer-element-is-not-constant.patch \
            "
 
 SRC_URI[sha256sum] = "3e57574036d5055e9557ec5095818b419ea6c4365370fc2ccce1e9f87f9fad08"
Signature · 1 line
2.17.1