aboutsummaryrefslogtreecommitdiff
path: root/gcc/m2
diff options
context:
space:
mode:
authorGaius Mulley <gaiusmod2@gmail.com>2023-01-20 23:39:35 +0000
committerGaius Mulley <gaiusmod2@gmail.com>2023-01-20 23:39:35 +0000
commit5c4122be854c135a1f66f2db68ec9cde6d5993dc (patch)
treeb6c3b98597b6314a7349e750d8817c570d4a50e0 /gcc/m2
parent0c193cabe1d8f209359f3ccb8e74cf87b38fc4bc (diff)
downloadgcc-5c4122be854c135a1f66f2db68ec9cde6d5993dc.zip
gcc-5c4122be854c135a1f66f2db68ec9cde6d5993dc.tar.gz
gcc-5c4122be854c135a1f66f2db68ec9cde6d5993dc.tar.bz2
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 <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc/m2')
-rw-r--r--gcc/m2/gm2-libs/Args.mod2
-rw-r--r--gcc/m2/gm2-libs/M2Dependent.mod2
-rw-r--r--gcc/m2/mc-boot/GArgs.c2
-rw-r--r--gcc/m2/mc-boot/GM2Dependent.c2
-rw-r--r--gcc/m2/mc-boot/Gkeyc.c4
-rw-r--r--gcc/m2/mc/keyc.mod6
-rw-r--r--gcc/m2/pge-boot/GArgs.c2
-rw-r--r--gcc/m2/pge-boot/GM2Dependent.c2
8 files changed, 9 insertions, 13 deletions
diff --git a/gcc/m2/gm2-libs/Args.mod b/gcc/m2/gm2-libs/Args.mod
index 30f76c6..fa14f8c 100644
--- a/gcc/m2/gm2-libs/Args.mod
+++ b/gcc/m2/gm2-libs/Args.mod
@@ -62,7 +62,7 @@ BEGIN
IF i < GetArgC ()
THEN
Source := GetArgV () ;
- WHILE (Source^[i]^[j]#nul) AND (j<High) DO
+ WHILE (j<High) AND (Source^[i]^[j]#nul) DO
a[j] := Source^[i]^[j] ;
INC(j)
END
diff --git a/gcc/m2/gm2-libs/M2Dependent.mod b/gcc/m2/gm2-libs/M2Dependent.mod
index 72675eb..f343ac3 100644
--- a/gcc/m2/gm2-libs/M2Dependent.mod
+++ b/gcc/m2/gm2-libs/M2Dependent.mod
@@ -203,7 +203,7 @@ BEGIN
i := 0 ;
high := HIGH (str) ;
WHILE i < high DO
- IF (str[i] = "\") AND (i < high)
+ IF (i < high) AND (str[i] = "\")
THEN
IF str[i+1] = "n"
THEN
diff --git a/gcc/m2/mc-boot/GArgs.c b/gcc/m2/mc-boot/GArgs.c
index 81955e8..bcb1b13 100644
--- a/gcc/m2/mc-boot/GArgs.c
+++ b/gcc/m2/mc-boot/GArgs.c
@@ -83,7 +83,7 @@ extern "C" unsigned int Args_GetArg (char *a, unsigned int _a_high, unsigned int
if (i < (UnixArgs_GetArgC ()))
{
Source = static_cast<Args__T1> (UnixArgs_GetArgV ());
- while (((*(*Source).array[i]).array[j] != ASCII_nul) && (j < High))
+ while ((j < High) && ((*(*Source).array[i]).array[j] != ASCII_nul))
{
a[j] = (*(*Source).array[i]).array[j];
j += 1;
diff --git a/gcc/m2/mc-boot/GM2Dependent.c b/gcc/m2/mc-boot/GM2Dependent.c
index b9c59cc..fb22f1b 100644
--- a/gcc/m2/mc-boot/GM2Dependent.c
+++ b/gcc/m2/mc-boot/GM2Dependent.c
@@ -457,7 +457,7 @@ static void toCString (char *str, unsigned int _str_high)
high = _str_high;
while (i < high)
{
- if ((str[i] == '\\') && (i < high))
+ if ((i < high) && (str[i] == '\\'))
{
if (str[i+1] == 'n')
{
diff --git a/gcc/m2/mc-boot/Gkeyc.c b/gcc/m2/mc-boot/Gkeyc.c
index 6f17ca5..e000bfe 100644
--- a/gcc/m2/mc-boot/Gkeyc.c
+++ b/gcc/m2/mc-boot/Gkeyc.c
@@ -600,7 +600,7 @@ static void checkAbs (mcPretty_pretty p)
static void checkLimits (mcPretty_pretty p)
{
- if ((((((((((((((seenMemcpy || seenIntMin) || seenUIntMin) || seenLongMin) || seenULongMin) || seenCharMin) || seenUCharMin) || seenUIntMin) || seenIntMax) || seenUIntMax) || seenLongMax) || seenULongMax) || seenCharMax) || seenUCharMax) || seenUIntMax)
+ if ((((((((((((seenMemcpy || seenIntMin) || seenUIntMin) || seenLongMin) || seenULongMin) || seenCharMin) || seenUCharMin) || seenIntMax) || seenUIntMax) || seenLongMax) || seenULongMax) || seenCharMax) || seenUCharMax) /* OR seenUIntMax */
{
checkGccConfigSystem (p);
if (! (mcOptions_getGccConfigSystem ()))
@@ -1067,14 +1067,12 @@ static void init (void)
seenULongMin = FALSE;
seenCharMin = FALSE;
seenUCharMin = FALSE;
- seenUIntMin = FALSE;
seenIntMax = FALSE;
seenUIntMax = FALSE;
seenLongMax = FALSE;
seenULongMax = FALSE;
seenCharMax = FALSE;
seenUCharMax = FALSE;
- seenUIntMax = FALSE;
seenLabs = FALSE;
seenAbs = FALSE;
seenFabs = FALSE;
diff --git a/gcc/m2/mc/keyc.mod b/gcc/m2/mc/keyc.mod
index 5e1016d..a57103b 100644
--- a/gcc/m2/mc/keyc.mod
+++ b/gcc/m2/mc/keyc.mod
@@ -457,9 +457,9 @@ PROCEDURE checkLimits (p: pretty) ;
BEGIN
IF seenMemcpy OR seenIntMin OR seenUIntMin OR
seenLongMin OR seenULongMin OR seenCharMin OR
- seenUCharMin OR seenUIntMin OR seenIntMax OR
+ seenUCharMin OR (* seenUIntMin OR *) seenIntMax OR
seenUIntMax OR seenLongMax OR seenULongMax OR
- seenCharMax OR seenUCharMax OR seenUIntMax
+ seenCharMax OR seenUCharMax (* OR seenUIntMax *)
THEN
checkGccConfigSystem (p);
IF NOT getGccConfigSystem ()
@@ -1118,14 +1118,12 @@ BEGIN
seenULongMin := FALSE ;
seenCharMin := FALSE ;
seenUCharMin := FALSE ;
- seenUIntMin := FALSE ;
seenIntMax := FALSE ;
seenUIntMax := FALSE ;
seenLongMax := FALSE ;
seenULongMax := FALSE ;
seenCharMax := FALSE ;
seenUCharMax := FALSE ;
- seenUIntMax := FALSE ;
seenLabs := FALSE ;
seenAbs := FALSE ;
seenFabs := FALSE ;
diff --git a/gcc/m2/pge-boot/GArgs.c b/gcc/m2/pge-boot/GArgs.c
index 3c3f95b..69fbdd0 100644
--- a/gcc/m2/pge-boot/GArgs.c
+++ b/gcc/m2/pge-boot/GArgs.c
@@ -81,7 +81,7 @@ extern "C" unsigned int Args_GetArg (char *a, unsigned int _a_high, unsigned int
if (i < (UnixArgs_GetArgC ()))
{
Source = static_cast<Args__T1> (UnixArgs_GetArgV ());
- while (((*(*Source).array[i]).array[j] != ASCII_nul) && (j < High))
+ while ((j < High) && ((*(*Source).array[i]).array[j] != ASCII_nul))
{
a[j] = (*(*Source).array[i]).array[j];
j += 1;
diff --git a/gcc/m2/pge-boot/GM2Dependent.c b/gcc/m2/pge-boot/GM2Dependent.c
index 368cf33..32c777c 100644
--- a/gcc/m2/pge-boot/GM2Dependent.c
+++ b/gcc/m2/pge-boot/GM2Dependent.c
@@ -458,7 +458,7 @@ static void toCString (char *str, unsigned int _str_high)
high = _str_high;
while (i < high)
{
- if ((str[i] == '\\') && (i < high))
+ if ((i < high) && (str[i] == '\\'))
{
if (str[i+1] == 'n')
{