commit:     f0369a777a35c2692b21c9f78d0673bb2983fa09
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Mon May  3 16:17:47 2021 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Mon May  3 16:18:11 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f0369a77

games-arcade/sdb: fix startup crash on gcc-8+

Crashes happen due to missing 'return' value in non-void functions.

Package-Manager: Portage-3.0.18, Repoman-3.0.3
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 games-arcade/sdb/files/sdb-1.0.2-return-type.patch | 56 ++++++++++++++++++++++
 games-arcade/sdb/sdb-1.0.2-r2.ebuild               | 55 +++++++++++++++++++++
 2 files changed, 111 insertions(+)

diff --git a/games-arcade/sdb/files/sdb-1.0.2-return-type.patch 
b/games-arcade/sdb/files/sdb-1.0.2-return-type.patch
new file mode 100644
index 00000000000..9750eedb991
--- /dev/null
+++ b/games-arcade/sdb/files/sdb-1.0.2-return-type.patch
@@ -0,0 +1,56 @@
+Fix -Werror=return-type warnings to prevent gcc-8+ from
+corrupting caller's stack.
+
+Also detected by -fsanitize=undefined as:
+runtime error: execution reached the end of a value-returning
+function without returning a value
+--- a/src/input.cpp
++++ b/src/input.cpp
+@@ -103,5 +103,6 @@ float InputHandler::bindingState(int key)
+   }
+   else
+     return 0.0;
++  return 0.0;
+ }
+ 
+--- a/src/objects.h
++++ b/src/objects.h
+@@ -545,12 +545,12 @@ class Object : public LevelObject
+     bool Augmented() { return augmented; }
+     void Augment() { model[1].set(MDL_PLAYER_TORSO2); augmented = true; }
+ 
+-    virtual Weapon* Wpn() {}
+-    virtual int CurrWeapon() {}
++    virtual Weapon* Wpn() { return 0; }
++    virtual int CurrWeapon() { return 0; }
+     virtual void selectWeapon(int wp) {}
+-    virtual char weaponState(int wp) {}
+-    virtual char keyState(int wp) {}
+-    virtual Vector2D* WeaponPoint() {}
++    virtual char weaponState(int wp) { return 0; }
++    virtual char keyState(int wp) { return 0; }
++    virtual Vector2D* WeaponPoint() { return 0; }
+     
+     void giveKey(int key) { keys |= 1 << key-1; }
+     virtual void givePowerup(int idx) {}
+--- a/src/sdb.h
++++ b/src/sdb.h
+@@ -370,7 +370,7 @@ class Vector2D
+     void set(float nx, float ny) { c[X] = nx; c[Y] = ny; c[Z] = 0; }
+     void apply() { glVertex3fv(c); }
+     void print() { printf("(%f, %f)\n", c[X], c[Y]); }
+-    Vector2D operator = (Vector2D v) { c[X] = v.c[X]; c[Y] = v.c[Y]; }
++    Vector2D operator = (Vector2D v) { c[X] = v.c[X]; c[Y] = v.c[Y]; return 
*this; }
+     void operator += (Vector2D v) { c[X] += v.c[X]; c[Y] += v.c[Y]; }
+     void operator -= (Vector2D v) { c[X] -= v.c[X]; c[Y] -= v.c[Y]; }
+     void operator += (float s) { c[X] += s; c[Y] += s; }
+--- a/src/weapons.cpp
++++ b/src/weapons.cpp
+@@ -135,6 +135,7 @@ bool Weapon::fire(float x, float y, float head, float h)
+   }
+   else
+     return false;
++  return false;
+ }
+ 
+ void Weapon::releaseTrigger(float x, float y, float head, float h)

diff --git a/games-arcade/sdb/sdb-1.0.2-r2.ebuild 
b/games-arcade/sdb/sdb-1.0.2-r2.ebuild
new file mode 100644
index 00000000000..842841e9cbd
--- /dev/null
+++ b/games-arcade/sdb/sdb-1.0.2-r2.ebuild
@@ -0,0 +1,55 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+inherit desktop toolchain-funcs
+
+DESCRIPTION="A 2D top-down action game; escape a facility full of walking 
death machines"
+HOMEPAGE="http://sdb.gamecreation.org/";
+SRC_URI="http://gcsociety.sp.cs.cmu.edu/~frenzy/${P}.tar.gz";
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE=""
+
+DEPEND="virtual/opengl
+       media-libs/libsdl
+       media-libs/sdl-image[png]
+       media-libs/sdl-mixer"
+RDEPEND="${DEPEND}"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-endian.patch
+       "${FILESDIR}"/${P}-gcc43.patch
+       "${FILESDIR}"/${P}-ldflags.patch
+       "${FILESDIR}"/${P}-gcc-11.patch
+       "${FILESDIR}"/${P}-return-type.patch
+)
+
+src_prepare() {
+       default
+       sed -i \
+               -e "s:models/:/usr/share/${PN}/models/:" \
+               -e "s:snd/:/usr/share/${PN}/snd/:" \
+               -e "s:sprites/:/usr/share/${PN}/sprites/:" \
+               -e "s:levels/:/usr/share/${PN}/levels/:" \
+               src/sdb.h src/game.cpp || die "setting game paths"
+}
+
+src_compile() {
+       emake \
+               -C src \
+               CXXFLAGS="${CXXFLAGS} $(sdl-config --cflags)" \
+               CC=$(tc-getCC) \
+               CPP=$(tc-getCXX)
+}
+
+src_install() {
+       dobin src/sdb
+       insinto /usr/share/${PN}
+       doins -r levels models snd sprites
+       newicon sprites/barrel.png ${PN}.png
+       make_desktop_entry sdb "Shotgun Debugger"
+       einstalldocs
+}

Reply via email to