-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the code -Wall compliant on gcc 12.2 & 13.2 and clang 14.0.0
@kloczek writes: > Just summary stats using gcc 13.x > > [tkloczko@pers-jacek SPECS]$ rpmbuild -ba ksh.spec 2>&1 | > grep -- \\[-W | sed 's/.*\[//; s/\]//' | > sort | uniq -c | sort -nr > 2034 -Wunknown-pragmas > 1226 -Wparentheses > 283 -Wmissing-braces > 179 -Wunused-value > 25 -Wchar-subscripts > 19 -Wlto-type-mismatch > 9 -Wunused-variable > 9 -Wunused-const-variable= > 2 -Waddress > 1 -Wuse-after-free > 1 -Wunused-function > 1 -Wunused-but-set-variable > 1 -Wsequence-point > 1 -Wdangling-pointer= Cause: build system uses -Wall to turn on ALL the warnings. Some users want a clean compile with -Wall, so here it is. -Wunknown-pragmas was fixed by adding preprocessor directives that hid them from inapplicable compilers. (AFAIK the standard says unknown pragmas are ignored, so this was pretty obnoxious.) -Wparentheses and -Wmissing-braces complain about perfectly valid C90 syntax, and I am not going to change it. Instead, these warnings have been disabled in src/lib/libast/features/common. On my own gcc tests I also had a lot of -Wmaybe-unitialized warnings. In most cases it was obvious from reading the code that the variables will not be used uninitialised, so those warnings are likely false positives. But a few of those did look like actual problems, and the overhead of variable initialisers is negligible, so this fixes them all. The rest of the warnings were fixed with appropriate code tweaks, too many to list here. Resolves: #699
- Loading branch information
Showing
78 changed files
with
335 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* * | ||
* This software is part of the ast package * | ||
* Copyright (c) 1990-2013 AT&T Intellectual Property * | ||
* Copyright (c) 2020-2023 Contributors to ksh 93u+m * | ||
* Copyright (c) 2020-2024 Contributors to ksh 93u+m * | ||
* and is licensed under the * | ||
* Eclipse Public License, Version 2.0 * | ||
* * | ||
|
@@ -15,7 +15,11 @@ | |
* Johnothan King <[email protected]> * | ||
* * | ||
***********************************************************************/ | ||
#if __clang__ | ||
#pragma clang diagnostic ignored "-Wparentheses" | ||
#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) | ||
#pragma GCC diagnostic ignored "-Wparentheses" | ||
#endif | ||
|
||
/* | ||
* mamake -- MAM make | ||
|
@@ -36,7 +40,7 @@ static const char usage[] = | |
"[-author?Glenn Fowler <[email protected]>]" | ||
"[-author?Contributors to https://github.com/ksh93/ksh]" | ||
"[-copyright?(c) 1994-2012 AT&T Intellectual Property]" | ||
"[-copyright?(c) 2020-2023 Contributors to ksh 93u+m]" | ||
"[-copyright?(c) 2020-2024 Contributors to ksh 93u+m]" | ||
"[-license?https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html]" | ||
"[+NAME?mamake - make abstract machine make]" | ||
"[+DESCRIPTION?\bmamake\b reads \amake abstract machine\a target and" | ||
|
@@ -589,7 +593,10 @@ search(Dict_t* dict, char* name, void* value) | |
else if (value) | ||
{ | ||
if (!(root = newof(0, Dict_item_t, 1, strlen(name)))) | ||
{ | ||
report(3, "out of memory [dictionary]", name, 0); | ||
abort(); | ||
} | ||
strcpy(root->name, name); | ||
} | ||
if (root) | ||
|
@@ -727,7 +734,8 @@ view(void) | |
} | ||
if ((s = (char*)search(state.vars, "VPATH", NULL)) && *s) | ||
{ | ||
zp = 0; | ||
p = NULL; | ||
zp = NULL; | ||
for (;;) | ||
{ | ||
for (t = s; *t && *t != ':'; t++); | ||
|
@@ -770,6 +778,8 @@ view(void) | |
} | ||
} | ||
n = strlen(s); | ||
if(!p) | ||
abort(); | ||
if (!(vp = newof(0, View_t, 1, strlen(p) + n + 1))) | ||
report(3, "out of memory [view]", s, 0); | ||
vp->node = n + 1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* * | ||
* This software is part of the ast package * | ||
* Copyright (c) 1982-2011 AT&T Intellectual Property * | ||
* Copyright (c) 2020-2023 Contributors to ksh 93u+m * | ||
* Copyright (c) 2020-2024 Contributors to ksh 93u+m * | ||
* and is licensed under the * | ||
* Eclipse Public License, Version 2.0 * | ||
* * | ||
|
@@ -14,7 +14,11 @@ | |
* Martijn Dekker <[email protected]> * | ||
* * | ||
***********************************************************************/ | ||
#if __clang__ | ||
#pragma clang diagnostic ignored "-Wparentheses" | ||
#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) | ||
#pragma GCC diagnostic ignored "-Wparentheses" | ||
#endif | ||
/* | ||
* AT&T Bell Laboratories | ||
* make abstract machine file state support | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.