Package: biniax2 / 1.30-4

compiler-warnings.patch Patch series | download
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
From: Markus Koschany <apo@debian.org>
Date: Sat, 21 Oct 2017 16:47:03 +0200
Subject: compiler warnings

Fix various compiler warnings. The most serious are
warning: function returns address of local variable in hof.c and biniax.c.
This is undefined behavior and crashes the game.

Forwarded: no
---
 biniax.c      | 5 +++--
 desktop/sys.c | 2 +-
 desktop/sys.h | 2 +-
 hof.c         | 5 +++--
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/biniax.c b/biniax.c
index 06f2500..e12cc0f 100755
--- a/biniax.c
+++ b/biniax.c
@@ -1218,6 +1218,7 @@ static const char *saveFileName()
 {
 #ifndef _WIN32
 	char filename[1024];
+	static char* autosave_path;
 	char *home;
 	struct passwd *passwd;
 	if (!getuid())
@@ -1262,8 +1263,8 @@ static const char *saveFileName()
 			return BNX_FALSE;
 		}
 	}
-	strncat(filename, "/autosave", sizeof(filename)-1);
-	return filename;
+	autosave_path = strncat(filename, "/autosave", sizeof(filename)-1);
+	return autosave_path;
 #else
 	return "./autosave.bnx2";
 #endif
diff --git a/desktop/sys.c b/desktop/sys.c
index 20528c0..1af436b 100755
--- a/desktop/sys.c
+++ b/desktop/sys.c
@@ -73,7 +73,7 @@ void sysUpdate()
 FILE FUNCTIONS
 ******************************************************************************/
 
-BNX_UINT32 sysGetFileLen( char *file )
+BNX_UINT32 sysGetFileLen( const char *file )
 {
 	BNX_UINT32 len = 0;
 	FILE *f;
diff --git a/desktop/sys.h b/desktop/sys.h
index 5a266c7..2dfe7c3 100755
--- a/desktop/sys.h
+++ b/desktop/sys.h
@@ -65,7 +65,7 @@ void sysUpdate();
 FILE FUNCIONS
 ******************************************************************************/
 
-BNX_UINT32 sysGetFileLen( char *file );
+BNX_UINT32 sysGetFileLen( const char *file );
 
 void sysFPut8( BNX_UINT8 n, FILE *f );
 void sysFPut16( BNX_UINT16 n, FILE *f );
diff --git a/hof.c b/hof.c
index d0c6efb..34c5d49 100755
--- a/hof.c
+++ b/hof.c
@@ -106,6 +106,7 @@ static const char *hofFileName()
 {
 #ifndef _WIN32
 	char filename[1024];
+	static char* hof_path;
 	char *home;
 	struct passwd *passwd;
 	if (!getuid())
@@ -150,8 +151,8 @@ static const char *hofFileName()
 			return BNX_FALSE;
 		}
 	}
-	strncat(filename, "/hof", sizeof(filename)-1);
-	return filename;
+	hof_path = strncat(filename, "/hof", sizeof(filename)-1);
+	return hof_path;
 #else
 	return "./hof.bnx2";
 #endif