public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Gaius Mulley <gaius@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5272] PR-108136 modula-2 meets cppcheck part 2 Date: Fri, 20 Jan 2023 23:40:09 +0000 (GMT) [thread overview] Message-ID: <20230120234009.E3D373858D1E@sourceware.org> (raw) https://gcc.gnu.org/g:5c4122be854c135a1f66f2db68ec9cde6d5993dc commit r13-5272-g5c4122be854c135a1f66f2db68ec9cde6d5993dc Author: Gaius Mulley <gaiusmod2@gmail.com> Date: Fri Jan 20 23:39:35 2023 +0000 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> Diff: --- gcc/m2/gm2-libs/Args.mod | 2 +- gcc/m2/gm2-libs/M2Dependent.mod | 2 +- gcc/m2/mc-boot/GArgs.c | 2 +- gcc/m2/mc-boot/GM2Dependent.c | 2 +- gcc/m2/mc-boot/Gkeyc.c | 4 +--- gcc/m2/mc/keyc.mod | 6 ++---- gcc/m2/pge-boot/GArgs.c | 2 +- gcc/m2/pge-boot/GM2Dependent.c | 2 +- 8 files changed, 9 insertions(+), 13 deletions(-) diff --git a/gcc/m2/gm2-libs/Args.mod b/gcc/m2/gm2-libs/Args.mod index 30f76c60fe9..fa14f8cedfb 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 72675eb0dfe..f343ac3f185 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 81955e81605..bcb1b132365 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 b9c59cc9fac..fb22f1b9145 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 6f17ca5d3a1..e000bfe60f0 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 5e1016d4d4d..a57103b42a7 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 3c3f95b5882..69fbdd00633 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 368cf339ad6..32c777c2402 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') {
reply other threads:[~2023-01-20 23:40 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230120234009.E3D373858D1E@sourceware.org \ --to=gaius@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).