[openjk] 02/02: d/p/Avoid-compiler-warning-when-sscanf-writes-qboolean-throug.patch, d/p/Suppress-compiler-warning-for-unused-BufferToHexString.patch, d/p/Use-same-mechanism-to-say-no-servers-found-as-to-say-how-.patch, d/p/botlib-print-long-int-correctly.patch: silence some compiler warnings

Simon McVittie smcv at debian.org
Sat Sep 24 21:43:02 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository openjk.

commit 27ceaee8c0d68913e346cb4b945d0a316c6af505
Author: Simon McVittie <smcv at debian.org>
Date:   Thu Sep 22 08:46:42 2016 +0100

    d/p/Avoid-compiler-warning-when-sscanf-writes-qboolean-throug.patch, d/p/Suppress-compiler-warning-for-unused-BufferToHexString.patch, d/p/Use-same-mechanism-to-say-no-servers-found-as-to-say-how-.patch, d/p/botlib-print-long-int-correctly.patch: silence some compiler warnings
---
 debian/changelog                                   |   5 +
 ...arning-when-sscanf-writes-qboolean-throug.patch | 102 +++++++++++++++++++++
 ...iler-warning-for-unused-BufferToHexString.patch |  29 ++++++
 ...sm-to-say-no-servers-found-as-to-say-how-.patch |  26 ++++++
 .../patches/botlib-print-long-int-correctly.patch  |  33 +++++++
 debian/patches/series                              |   4 +
 6 files changed, 199 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 2fb3d02..bfa7191 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,11 @@
 openjk (0~20160911+dfsg1-2) UNRELEASED; urgency=medium
 
   * Correct `date` invocation for $SOURCE_DATE_EPOCH
+  * d/p/Avoid-compiler-warning-when-sscanf-writes-qboolean-throug.patch,
+    d/p/Suppress-compiler-warning-for-unused-BufferToHexString.patch,
+    d/p/Use-same-mechanism-to-say-no-servers-found-as-to-say-how-.patch,
+    d/p/botlib-print-long-int-correctly.patch:
+    silence some compiler warnings
 
  -- Simon McVittie <smcv at debian.org>  Thu, 22 Sep 2016 08:18:53 +0100
 
diff --git a/debian/patches/Avoid-compiler-warning-when-sscanf-writes-qboolean-throug.patch b/debian/patches/Avoid-compiler-warning-when-sscanf-writes-qboolean-throug.patch
new file mode 100644
index 0000000..8eefb68
--- /dev/null
+++ b/debian/patches/Avoid-compiler-warning-when-sscanf-writes-qboolean-throug.patch
@@ -0,0 +1,102 @@
+From: Simon McVittie <smcv at debian.org>
+Date: Thu, 22 Sep 2016 08:29:35 +0100
+Subject: Avoid compiler warning when sscanf writes qboolean through %i
+
+.../code/game/g_client.cpp:760:6: warning: format '%i' expects argument of type 'int*', but argument 26 has type 'qboolean*' [-Wformat=]
+---
+ code/game/g_client.cpp  | 36 ++++++++++++++++++++----------------
+ code/game/g_session.cpp |  4 +++-
+ 2 files changed, 23 insertions(+), 17 deletions(-)
+
+diff --git a/code/game/g_client.cpp b/code/game/g_client.cpp
+index 278645f..9c05053 100644
+--- a/code/game/g_client.cpp
++++ b/code/game/g_client.cpp
+@@ -696,6 +696,8 @@ static void Player_RestoreFromPrevLevel(gentity_t *ent, SavedGameJustLoaded_e eS
+ 
+ 		if (strlen(s))	// actually this would be safe anyway because of the way sscanf() works, but this is clearer
+ 		{//				|general info				  |-force powers |-saber 1										   |-saber 2										  |-general saber
++			int saber1BladeActive[8];
++			int saber2BladeActive[8];
+ 			unsigned int saber1BladeColor[8];
+ 			unsigned int saber2BladeColor[8];
+ 
+@@ -718,14 +720,14 @@ static void Player_RestoreFromPrevLevel(gentity_t *ent, SavedGameJustLoaded_e eS
+ 								&client->ps.forcePowerRegenAmount,
+ 								//saber 1 data
+ 								saber0Name,
+-								&client->ps.saber[0].blade[0].active,
+-								&client->ps.saber[0].blade[1].active,
+-								&client->ps.saber[0].blade[2].active,
+-								&client->ps.saber[0].blade[3].active,
+-								&client->ps.saber[0].blade[4].active,
+-								&client->ps.saber[0].blade[5].active,
+-								&client->ps.saber[0].blade[6].active,
+-								&client->ps.saber[0].blade[7].active,
++								&saber1BladeActive[0],
++								&saber1BladeActive[1],
++								&saber1BladeActive[2],
++								&saber1BladeActive[3],
++								&saber1BladeActive[4],
++								&saber1BladeActive[5],
++								&saber1BladeActive[6],
++								&saber1BladeActive[7],
+ 								&saber1BladeColor[0],
+ 								&saber1BladeColor[1],
+ 								&saber1BladeColor[2],
+@@ -736,14 +738,14 @@ static void Player_RestoreFromPrevLevel(gentity_t *ent, SavedGameJustLoaded_e eS
+ 								&saber1BladeColor[7],
+ 								//saber 2 data
+ 								saber1Name,
+-								&client->ps.saber[1].blade[0].active,
+-								&client->ps.saber[1].blade[1].active,
+-								&client->ps.saber[1].blade[2].active,
+-								&client->ps.saber[1].blade[3].active,
+-								&client->ps.saber[1].blade[4].active,
+-								&client->ps.saber[1].blade[5].active,
+-								&client->ps.saber[1].blade[6].active,
+-								&client->ps.saber[1].blade[7].active,
++								&saber2BladeActive[0],
++								&saber2BladeActive[1],
++								&saber2BladeActive[2],
++								&saber2BladeActive[3],
++								&saber2BladeActive[4],
++								&saber2BladeActive[5],
++								&saber2BladeActive[6],
++								&saber2BladeActive[7],
+ 								&saber2BladeColor[0],
+ 								&saber2BladeColor[1],
+ 								&saber2BladeColor[2],
+@@ -760,7 +762,9 @@ static void Player_RestoreFromPrevLevel(gentity_t *ent, SavedGameJustLoaded_e eS
+ 					);
+ 			for (int j = 0; j < 8; j++)
+ 			{
++				client->ps.saber[0].blade[j].active = saber1BladeActive[j] ? qtrue : qfalse;
+ 				client->ps.saber[0].blade[j].color = (saber_colors_t)saber1BladeColor[j];
++				client->ps.saber[1].blade[j].active = saber2BladeActive[j] ? qtrue : qfalse;
+ 				client->ps.saber[1].blade[j].color = (saber_colors_t)saber2BladeColor[j];
+ 			}
+ 
+diff --git a/code/game/g_session.cpp b/code/game/g_session.cpp
+index 09f6f60..6cde682 100644
+--- a/code/game/g_session.cpp
++++ b/code/game/g_session.cpp
+@@ -116,6 +116,7 @@ void G_ReadSessionData( gclient_t *client ) {
+ 	char	s[MAX_STRING_CHARS];
+ 	const char	*var;
+ 	int		i;
++	int		lightsideDisplay;
+ 
+ 	var = va( "session%i", client - level.clients );
+ 	gi.Cvar_VariableStringBuffer( var, s, sizeof(s) );
+@@ -145,8 +146,9 @@ void G_ReadSessionData( gclient_t *client ) {
+ 
+ 	// Now load the LIGHTSIDE objective. That's the only cross level objective.
+ 	sscanf( var, "%i %i",
+-		&client->sess.mission_objectives[LIGHTSIDE_OBJ].display,
++		&lightsideDisplay,
+ 		&client->sess.mission_objectives[LIGHTSIDE_OBJ].status);
++	client->sess.mission_objectives[LIGHTSIDE_OBJ].display = lightsideDisplay ? qtrue : qfalse;
+ 
+ 	var = va( "missionstats%i", client - level.clients );
+ 	gi.Cvar_VariableStringBuffer( var, s, sizeof(s) );
diff --git a/debian/patches/Suppress-compiler-warning-for-unused-BufferToHexString.patch b/debian/patches/Suppress-compiler-warning-for-unused-BufferToHexString.patch
new file mode 100644
index 0000000..74ac031
--- /dev/null
+++ b/debian/patches/Suppress-compiler-warning-for-unused-BufferToHexString.patch
@@ -0,0 +1,29 @@
+From: Simon McVittie <smcv at debian.org>
+Date: Thu, 22 Sep 2016 08:43:34 +0100
+Subject: Suppress compiler warning for unused BufferToHexString
+
+This function is only called when debugging challenges.
+---
+ codemp/server/sv_challenge.cpp | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/codemp/server/sv_challenge.cpp b/codemp/server/sv_challenge.cpp
+index 3bca98b..1331af8 100644
+--- a/codemp/server/sv_challenge.cpp
++++ b/codemp/server/sv_challenge.cpp
+@@ -30,6 +30,7 @@ static const size_t SECRET_KEY_LENGTH = MD5_DIGEST_SIZE; // Key length equal to
+ static qboolean challengerInitialized = qfalse;
+ static hmacMD5Context_t challenger;
+ 
++#ifdef DEBUG_SV_CHALLENGE
+ /*
+ ====================
+ BufferToHexString
+@@ -52,6 +53,7 @@ static const char *BufferToHexString(byte *buffer, size_t bufferLen)
+ 	hexString[bufferLen * 2] = '\0';
+ 	return hexString;
+ }
++#endif
+ 
+ /*
+ ====================
diff --git a/debian/patches/Use-same-mechanism-to-say-no-servers-found-as-to-say-how-.patch b/debian/patches/Use-same-mechanism-to-say-no-servers-found-as-to-say-how-.patch
new file mode 100644
index 0000000..44eaa48
--- /dev/null
+++ b/debian/patches/Use-same-mechanism-to-say-no-servers-found-as-to-say-how-.patch
@@ -0,0 +1,26 @@
+From: Simon McVittie <smcv at debian.org>
+Date: Thu, 22 Sep 2016 08:40:39 +0100
+Subject: Use same mechanism to say "no servers found" as to say how many we
+ found
+
+This avoids an array underflow: if no servers were found, we would
+write to foundPlayerServerNames[-1], which is undefined behaviour, but
+with a reasonable assumption of the stack layout is likely to result
+in a write to foundPlayerServerAddresses[MAX - 1].
+---
+ codemp/ui/ui_main.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/codemp/ui/ui_main.c b/codemp/ui/ui_main.c
+index 862da52..1f17346 100644
+--- a/codemp/ui/ui_main.c
++++ b/codemp/ui/ui_main.c
+@@ -7830,7 +7830,7 @@ static void UI_BuildFindPlayerList(qboolean force) {
+ 		// add a line that shows the number of servers found
+ 		if (!uiInfo.numFoundPlayerServers)
+ 		{
+-			Com_sprintf(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1], sizeof(uiInfo.foundPlayerServerAddresses[0]), "no servers found");
++			trap->Cvar_Set( "ui_playerServersFound", "no servers found" );
+ 		}
+ 		else
+ 		{
diff --git a/debian/patches/botlib-print-long-int-correctly.patch b/debian/patches/botlib-print-long-int-correctly.patch
new file mode 100644
index 0000000..153cec7
--- /dev/null
+++ b/debian/patches/botlib-print-long-int-correctly.patch
@@ -0,0 +1,33 @@
+From: Simon McVittie <smcv at debian.org>
+Date: Thu, 22 Sep 2016 08:32:54 +0100
+Subject: botlib: print long int correctly
+
+value has type long, or equivalently signed long int. In C,
+abs(some_long) returns int (to get a long result you would have to use
+labs(some_long) due to lack of overloading), but in C++ it returns long.
+---
+ codemp/botlib/l_precomp.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/codemp/botlib/l_precomp.cpp b/codemp/botlib/l_precomp.cpp
+index 9560f97..34c094f 100644
+--- a/codemp/botlib/l_precomp.cpp
++++ b/codemp/botlib/l_precomp.cpp
+@@ -2510,7 +2510,7 @@ int PC_Directive_eval(source_t *source)
+ 	token.whitespace_p = source->scriptstack->script_p;
+ 	token.endwhitespace_p = source->scriptstack->script_p;
+ 	token.linescrossed = 0;
+-	sprintf(token.string, "%d", abs(value));
++	sprintf(token.string, "%ld", abs(value));
+ 	token.type = TT_NUMBER;
+ 	token.subtype = TT_INTEGER|TT_LONG|TT_DECIMAL;
+ 	PC_UnreadSourceToken(source, &token);
+@@ -2615,7 +2615,7 @@ int PC_DollarDirective_evalint(source_t *source)
+ 	token.whitespace_p = source->scriptstack->script_p;
+ 	token.endwhitespace_p = source->scriptstack->script_p;
+ 	token.linescrossed = 0;
+-	sprintf(token.string, "%d", abs(value));
++	sprintf(token.string, "%ld", abs(value));
+ 	token.type = TT_NUMBER;
+ 	token.subtype = TT_INTEGER|TT_LONG|TT_DECIMAL;
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 9111d9a..84851d2 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,4 +1,8 @@
 g_utils-disarm-debug-code-that-writes-to-c-nofreeent.patch
 Fix-a-typo-in-Siege-mode-attemtping-attempting.patch
 Declare-platform-independent-byteswapping-functions-QINLI.patch
+Avoid-compiler-warning-when-sscanf-writes-qboolean-throug.patch
+botlib-print-long-int-correctly.patch
+Use-same-mechanism-to-say-no-servers-found-as-to-say-how-.patch
+Suppress-compiler-warning-for-unused-BufferToHexString.patch
 Allow-__DATE__-to-be-overridden-for-reproducible-builds.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git



More information about the Pkg-games-commits mailing list