URL: <https://savannah.gnu.org/bugs/?66414>
Summary: couple of compilation warnings for uninitialized variables Group: GNU Screen Submitter: themusicgod1 Submitted: Wed 06 Nov 2024 10:53:34 AM CST Category: None Severity: 3 - Normal Priority: 5 - Normal Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any Release: 5.0.0 Fixed Release: None Planned Release: None Work Required: None _______________________________________________________ Follow-up Comments: ------------------------------------------------------- Date: Wed 06 Nov 2024 10:53:34 AM CST By: Jeffrey Cliff <themusicgod1> gcc gcc (GCC) 15.0.0 20240509 (experimental) + CFLAGS=" -std=gnu23 -Oz -march=native " compiling screen: 5.0.0 (but also valid for master branch commit 9d8b0ff) is complaining two variables are left potentially uninitialized. gcc -c -iquote. -DSCREENENCODINGS='"/usr/share/screen/utf8encodings"' -DBUILD_DATE='"2024-11-06 10:11:03"' -std=gnu23 -Oz -march=native -Wall -Wextra -std=c17 socket.c -o socket.o sched.c: In function ‘sched’: sched.c:159:21: warning: ‘timeout’ may be used uninitialized [-Wmaybe-uninitialized] 159 | n = poll(pfd, i, timeoutev ? timeout : 1000); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sched.c:127:13: note: ‘timeout’ was declared here 127 | int timeout; | ^~~~~~~ gcc -c -iquote. -DSCREENENCODINGS='"/usr/share/screen/utf8encodings"' -DBUILD_DATE='"2024-11-06 10:11:03"' -std=gnu23 -Oz -march=native -Wall -Wextra -std=c17 winmsgbuf.c -o winmsgbuf.o process.c: In function ‘DoCommandAt’: process.c:1372:36: warning: ‘i’ may be used uninitialized [-Wmaybe-uninitialized] 1372 | if (i < 0) | ^ process.c:1340:29: note: ‘i’ was declared here 1340 | int i; | ^ The following two patches fix this: # diff -Naur screen-5.0.0/sched.c screen-compiles/sched.c --- screen-5.0.0/sched.c 2024-08-28 13:55:03.000000000 -0600 +++ screen-compiles/sched.c 2024-11-06 10:31:40.331375731 -0600 @@ -124,7 +124,7 @@ { Event *ev; Event *timeoutev = NULL; - int timeout; + int timeout=0; int i, n; for (;;) { --- screen-5.0.0/process.c 2024-08-28 13:55:03.000000000 -0600 +++ screen-compiles/process.c 2024-11-06 10:31:01.989378635 -0600 @@ -1337,7 +1337,7 @@ default: { int ch; - int i; + int i=0; n++; ch = args[0][n]; _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?66414> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
signature.asc
Description: PGP signature