Your message dated Thu, 13 Nov 2008 13:44:33 -0500
with message-id <[EMAIL PROTECTED]>
has caused the report #234448,
regarding trek: spins, forcing user to abort game
to be marked as having been forwarded to the upstream software
author(s) [EMAIL PROTECTED]
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [EMAIL PROTECTED]
immediately.)
--
234448: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=234448
Debian Bug Tracking System
Contact [EMAIL PROTECTED] with problems
--- Begin Message ---
I think you'll want to apply this. The bug is that trek can spin on some
architectures.
----- Forwarded message from Wouter Verhelst <[EMAIL PROTECTED]> -----
From: Wouter Verhelst <[EMAIL PROTECTED]>
Date: Thu, 13 Nov 2008 14:39:15 +0100
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Bug#234448: this is an incorrect assumption about char signedness
Reply-To: Wouter Verhelst <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Organization: The Debian Project, http://www.debian.org/
User-Agent: Mutt/1.5.18 (2008-05-17)
tags 234448 + patch
thanks
Hi,
I hit this bug too, today, and spent a few hours tracking it down.
It's simple, really. The file trek.h contains:
struct quad /* definition for each quadrant */
{
unsigned char bases; /* number of bases in this quadrant */
char klings; /* number of Klingons in this quadrant */
char holes; /* number of black holes in this quadrant */
int scanned; /* star chart entry (see below) */
short stars; /* number of stars in this quadrant */
char qsystemname; /* starsystem name (see below) */
};
And then in setup.c, the following line is found:
q->stars = ranf(9) + 1;
q->holes = ranf(3) - q->stars / 5;
This assumes char is signed, which it isn't on powerpc (and s390). As a
result, q->holes may end up being negative (if ranf(3) returns 0, for
example) which gets turned into either 255 or 254. Having that much
black holes in a quadrant will result in trek looping in initquad() when
it tries to find an empty spot to put the black hole.
The following patch should fix that:
--- setup.c 2003-12-17 03:47:37.000000000 +0100
+++ setup.c-fixed 2008-11-13 14:33:32.000000000 +0100
@@ -234,11 +234,14 @@
for (i = 0; i < NQUADS; i++)
for (j = 0; j < NQUADS; j++)
{
+ signed char tmp;
q = &Quad[i][j];
q->klings = q->bases = 0;
q->scanned = -1;
q->stars = ranf(9) + 1;
- q->holes = ranf(3) - q->stars / 5;
+ tmp = ranf(3) - q->stars / 5;
+ tmp = tmp < 0 ? 0 : tmp;
+ q->holes = tmp;
q->qsystemname = 0;
}
Not tested, but trivial enough. Alternatively, the definition could be
made explicit so that the "char" definition of the "holes" member of
struct quad is a signed char everywhere.
--
<Lo-lan-do> Home is where you have to wash the dishes.
-- #debian-devel, Freenode, 2004-09-22
----- End forwarded message -----
--
see shy jo
signature.asc
Description: Digital signature
--- End Message ---