Skip to content

Commit 5c4122b

Browse files
author
Gaius Mulley
committed
PR-108136 modula-2 meets cppcheck part 2
R-108136 modula-2 meets cppcheck part 2 This patch addresses the style warnings mentioned in the PR. The array high style fixes to mc/keyc.mod and gm2-libs/M2Dependent.mod provoke a rebuild of pge and mc. gcc/m2/ChangeLog: * gm2-libs/Args.mod (GetArg): Check index before accessing array. * gm2-libs/M2Dependent.mod (toCString): Check index before accessing array. * mc-boot/GArgs.c: Rebuilt. * mc-boot/GM2Dependent.c: Rebuilt. * mc-boot/Gkeyc.c: Rebuilt. * mc/keyc.mod (seenUIntMin): Initialize once. (seenUIntMax): Initialize once. (checkLimits): Only test seenUIntMin and seenUIntMax once. * pge-boot/GArgs.c: Rebuilt. * pge-boot/GM2Dependent.c: Rebuilt. Signed-off-by: Gaius Mulley <[email protected]>
1 parent 0c193ca commit 5c4122b

File tree

8 files changed

+9
-13
lines changed

8 files changed

+9
-13
lines changed

gcc/m2/gm2-libs/Args.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ BEGIN
6262
IF i < GetArgC ()
6363
THEN
6464
Source := GetArgV () ;
65-
WHILE (Source^[i]^[j]#nul) AND (j<High) DO
65+
WHILE (j<High) AND (Source^[i]^[j]#nul) DO
6666
a[j] := Source^[i]^[j] ;
6767
INC(j)
6868
END

gcc/m2/gm2-libs/M2Dependent.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ BEGIN
203203
i := 0 ;
204204
high := HIGH (str) ;
205205
WHILE i < high DO
206-
IF (str[i] = "\") AND (i < high)
206+
IF (i < high) AND (str[i] = "\")
207207
THEN
208208
IF str[i+1] = "n"
209209
THEN

gcc/m2/mc-boot/GArgs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ extern "C" unsigned int Args_GetArg (char *a, unsigned int _a_high, unsigned int
8383
if (i < (UnixArgs_GetArgC ()))
8484
{
8585
Source = static_cast<Args__T1> (UnixArgs_GetArgV ());
86-
while (((*(*Source).array[i]).array[j] != ASCII_nul) && (j < High))
86+
while ((j < High) && ((*(*Source).array[i]).array[j] != ASCII_nul))
8787
{
8888
a[j] = (*(*Source).array[i]).array[j];
8989
j += 1;

gcc/m2/mc-boot/GM2Dependent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ static void toCString (char *str, unsigned int _str_high)
457457
high = _str_high;
458458
while (i < high)
459459
{
460-
if ((str[i] == '\\') && (i < high))
460+
if ((i < high) && (str[i] == '\\'))
461461
{
462462
if (str[i+1] == 'n')
463463
{

gcc/m2/mc-boot/Gkeyc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ static void checkAbs (mcPretty_pretty p)
600600

601601
static void checkLimits (mcPretty_pretty p)
602602
{
603-
if ((((((((((((((seenMemcpy || seenIntMin) || seenUIntMin) || seenLongMin) || seenULongMin) || seenCharMin) || seenUCharMin) || seenUIntMin) || seenIntMax) || seenUIntMax) || seenLongMax) || seenULongMax) || seenCharMax) || seenUCharMax) || seenUIntMax)
603+
if ((((((((((((seenMemcpy || seenIntMin) || seenUIntMin) || seenLongMin) || seenULongMin) || seenCharMin) || seenUCharMin) || seenIntMax) || seenUIntMax) || seenLongMax) || seenULongMax) || seenCharMax) || seenUCharMax) /* OR seenUIntMax */
604604
{
605605
checkGccConfigSystem (p);
606606
if (! (mcOptions_getGccConfigSystem ()))
@@ -1067,14 +1067,12 @@ static void init (void)
10671067
seenULongMin = FALSE;
10681068
seenCharMin = FALSE;
10691069
seenUCharMin = FALSE;
1070-
seenUIntMin = FALSE;
10711070
seenIntMax = FALSE;
10721071
seenUIntMax = FALSE;
10731072
seenLongMax = FALSE;
10741073
seenULongMax = FALSE;
10751074
seenCharMax = FALSE;
10761075
seenUCharMax = FALSE;
1077-
seenUIntMax = FALSE;
10781076
seenLabs = FALSE;
10791077
seenAbs = FALSE;
10801078
seenFabs = FALSE;

gcc/m2/mc/keyc.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,9 @@ PROCEDURE checkLimits (p: pretty) ;
457457
BEGIN
458458
IF seenMemcpy OR seenIntMin OR seenUIntMin OR
459459
seenLongMin OR seenULongMin OR seenCharMin OR
460-
seenUCharMin OR seenUIntMin OR seenIntMax OR
460+
seenUCharMin OR (* seenUIntMin OR *) seenIntMax OR
461461
seenUIntMax OR seenLongMax OR seenULongMax OR
462-
seenCharMax OR seenUCharMax OR seenUIntMax
462+
seenCharMax OR seenUCharMax (* OR seenUIntMax *)
463463
THEN
464464
checkGccConfigSystem (p);
465465
IF NOT getGccConfigSystem ()
@@ -1118,14 +1118,12 @@ BEGIN
11181118
seenULongMin := FALSE ;
11191119
seenCharMin := FALSE ;
11201120
seenUCharMin := FALSE ;
1121-
seenUIntMin := FALSE ;
11221121
seenIntMax := FALSE ;
11231122
seenUIntMax := FALSE ;
11241123
seenLongMax := FALSE ;
11251124
seenULongMax := FALSE ;
11261125
seenCharMax := FALSE ;
11271126
seenUCharMax := FALSE ;
1128-
seenUIntMax := FALSE ;
11291127
seenLabs := FALSE ;
11301128
seenAbs := FALSE ;
11311129
seenFabs := FALSE ;

gcc/m2/pge-boot/GArgs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ extern "C" unsigned int Args_GetArg (char *a, unsigned int _a_high, unsigned int
8181
if (i < (UnixArgs_GetArgC ()))
8282
{
8383
Source = static_cast<Args__T1> (UnixArgs_GetArgV ());
84-
while (((*(*Source).array[i]).array[j] != ASCII_nul) && (j < High))
84+
while ((j < High) && ((*(*Source).array[i]).array[j] != ASCII_nul))
8585
{
8686
a[j] = (*(*Source).array[i]).array[j];
8787
j += 1;

gcc/m2/pge-boot/GM2Dependent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ static void toCString (char *str, unsigned int _str_high)
458458
high = _str_high;
459459
while (i < high)
460460
{
461-
if ((str[i] == '\\') && (i < high))
461+
if ((i < high) && (str[i] == '\\'))
462462
{
463463
if (str[i+1] == 'n')
464464
{

0 commit comments

Comments
 (0)