Fix 1994/ldb for clang in linux

It objected to the incompatible pointer type passed to time(2) as what
was passed to time(2) was an int, not a time_t *. One way would be to
disable the warning but I chose to cast the parameter to a time_t * to
get rid of the warning wanting to be triggered at all.
This commit is contained in:
Cody Boone Ferguson committed 2023-07-07 10:38:29 -07:00
1 parent 76b7f121d5
commit 29889fe686
3 files changed
+15 -10

No files matched your search

+1 -1
View File
@@ -38,7 +38,7 @@ include ../../var.mk
# Common C compiler warnings to silence
#
CSILENCE= -Wno-trigraphs
CSILENCE= -Wno-trigraphs -Wno-int-conversion
# Common C compiler warning flags
#
+1 -1
View File
@@ -1 +1 @@
int _,O,__??('}'??);main(){while(O?(fgets((rand()%O++?':':_)+__,232,stdin))||puts(&__??(_??))&_:(srand(time((O+++_))),0)||O);}
int _,O,__??('}'??);main(){while(O?(fgets((rand()%O++?':':_)+__,232,stdin))||puts(&__??(_??))&_:(srand(time((time_t *)(O+++_))),0)||O);}
+13 -8
View File
@@ -604,14 +604,19 @@ which main() calls with the right parameters.
Cody fixed this so it would compile and work with modern compilers. The problem
was that `srand()` returns void but it was used in a `||` expression. Thus the
comma operator was needed. Cody also changed the entry to use `fgets()` instead
of `gets()` to make it safe for lines greater than 231 in length and to prevent
a warning at linking or at runtime, the latter of which can be interspersed with
output of the program. Note that this now prints a newline after the output but
this seems like a worthy compromise for making the output incorrect in macOS and
at the same time it's safer (fixing it to not have the extra newline is more
problematic than it's worth and in macOS another line of output would be shown
anyway).
comma operator was needed.
Cody also fixed it for clang under linux which objected to incompatible pointer
type (because `time(2)` takes a `time_t *` which in some systems is a `long *`
but what was being passed to it is an `int`).
Cody also changed the entry to use `fgets()` instead of `gets()` to make it safe
for lines greater than 231 in length and to prevent a warning at linking or at
runtime, the latter of which can be interspersed with output of the program.
Note that this now prints a newline after the output but this seems like a
worthy compromise for making the output incorrect in macOS and at the same time
it's safer (fixing it to not have the extra newline is more problematic than
it's worth and in macOS another line of output would be shown anyway).
A subtlety about this fix: if a line is greater than 231 in length if the
program chooses that line it might print the first 231 characters or it might