forked from gap-system/gap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds `typedef Int BOOL`; the resulting C type `BOOL` can be used to indicate that the return type of a function is supposed to be a boolean. Matching integer constants TRUE=1 and FALSE=0 are also added. The reason we are not using type `bool` from stdbool.h and the constants `true` and `false`, all available in C99, is the following: in C99, a pointer is automatically converted to type bool if necessary. That means that if one by accident writes `return False` instead of `return false` in a function with return type `BOOL`, then no compiler warning is issued. Instead, a bug is introduced, as `False` is a non-NULL pointer, and thus is cast to the `bool` value `true`. With this commit, we get warnings similar to the following if we mix up TRUE/True or FALSE/False; while if using `bool`, we'd only get the latter two warnings, but not the first one. src/objects.c:897:12: error: incompatible pointer to integer conversion returning 'Obj' (aka 'unsigned long **') from a function with result type 'BOOL' (aka 'unsigned char') [-Werror,-Wint-conversion] return False; ^~~~~ src/objects.c:1185:39: error: pointer/integer type mismatch in conditional expression ('int' and 'Obj' (aka 'unsigned long **')) [-Werror,-Wconditional-type-mismatch] return (TNUM_OBJ(obj) == T_COMOBJ ? TRUE : False); ^ ~~~~ ~~~~~ src/objects.c:1337:16: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'Obj' (aka 'unsigned long **') [-Werror,-Wint-conversion] return TRUE; ^~~~ Note that on the long run, it would be better to switch to something like `typedef char BOOL`, but that breaks at least one package (NormalizInterface), so let's postpone that until all affected packages with kernel extensions have switched to using BOOL.
- Loading branch information
Showing
64 changed files
with
379 additions
and
389 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
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
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
Oops, something went wrong.