Address issues in samples detected by new lint checks.

The only actual behavior change is in Ackermann.cc, which previously reported incorrectly high recursion depths for some calculations.
This commit is contained in:
Stephen Heumann 2023-04-23 19:35:16 -05:00
parent ab975b611c
commit 986fe9a65b
5 changed files with 13 additions and 8 deletions

View File

@ -1047,8 +1047,7 @@ printf ("%c%d ", (char) (move % 10 - 1 + 'A'), 9 - move / 10);
****************************************************************/
void DrawMoves (void)
{
GrafPortPtr port, p2; /* graphics ports */
CtlRecHndl ctl; /* for finding scroll bar */
GrafPortPtr port; /* graphics port */
Rect r; /* rectangle for drawing colors */
int i, n; /* index variables */
@ -1437,7 +1436,7 @@ if ((part > 4) && (part < 9)) { /* if the part is not the slide switch... */
if ( ((Even(topMove) + movesInWindow + 1) / 2) >
(Even(movesMade) + 1) / 2 ) {
topMove = Even (movesMade) - movesInWindow;
if (! (topMove >> 16) & 0x0001)
if (! (topMove >> 15) & 0x0001)
topMove++;
}
}
@ -1451,7 +1450,7 @@ if ((part > 4) && (part < 9)) { /* if the part is not the slide switch... */
else if (part == 129) { /* reposition based on new thumb loc. */
topMove = GetCtlValue (vScrollHandle) * 2 / charHeight +1;
if (! (topMove >> 16) & 0x0001)
if (! (topMove >> 15) & 0x0001)
topMove++;
updateMoves = true;
DrawMoves ();

View File

@ -23,7 +23,6 @@ int main (void)
{
float r, theta, rot;
int color = 1;
int stopFlag;
Rect rect;
GetPortRect(&rect);

View File

@ -38,6 +38,8 @@ int a, m, n, depth, maxdepth;
int Ackermann (int m, int n)
{
int result;
depth++;
if (depth > maxdepth)
maxdepth = depth;
@ -45,8 +47,9 @@ if (m == 0)
return (n + 1);
if (n == 0)
return (Ackermann (m-1, 1));
return (Ackermann (m-1, Ackermann (m, n-1)));
result = Ackermann (m-1, Ackermann (m, n-1));
depth--;
return result;
}

View File

@ -54,7 +54,9 @@ static void BadFunction (void)
{
char ch [8000]; /* this array is too large for */
} /* the default run-time stack */
/* the default run-time stack */
(void)ch; /* dummy use of ch to avoid lint msg */
}
/****************************************************************

View File

@ -32,7 +32,9 @@
static void Fail (void)
{
char ch [8000]; /* this array is too large for */
} /* the default run-time stack */
/* the default run-time stack */
(void)ch; /* dummy use of ch to avoid lint msg */
}
/****************************************************************