From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Cc: Cole Helbling <cole.e.helbling@outlook.com>
Subject: [PATCH ucspi-vsock 2/2] vsockserver: fix uninitialized variable
Date: Sun, 21 Mar 2021 14:54:40 +0000 [thread overview]
Message-ID: <20210321145440.28563-1-hi@alyssa.is> (raw)
In-Reply-To: <20210321145118.27783-1-hi@alyssa.is>
Identified by clang-tidy:
vsockserver.c:105:17: warning: 3rd function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
while ((opt = argz_next(binder_opts, binder_opts_len, opt)))
^
vsockserver.c:44:3: note: Assuming the condition is false
argz_add(&binder_opts, &binder_opts_len, BINDIR "/vsockserver-socketbinder") ||
^
vsockserver.c:44:3: note: Left side of '||' is false
vsockserver.c:47:9: note: Assuming the condition is false
while ((opt = getopt(argc, argv, "+1qQv")) != -1) {
^
vsockserver.c:47:2: note: Loop condition is false. Execution continues on line 68
while ((opt = getopt(argc, argv, "+1qQv")) != -1) {
^
vsockserver.c:68:6: note: Assuming 'alloc_failed' is false
if (alloc_failed)
^
vsockserver.c:68:2: note: Taking false branch
if (alloc_failed)
^
vsockserver.c:77:6: note: Assuming the condition is false
if (optind > argc - 3)
^
vsockserver.c:77:2: note: Taking false branch
if (optind > argc - 3)
^
vsockserver.c:81:6: note: Assuming the condition is false
if (argz_add(&binder_opts, &binder_opts_len, "--") ||
^
vsockserver.c:81:6: note: Left side of '||' is false
vsockserver.c:82:6: note: Assuming the condition is false
argz_add(&binder_opts, &binder_opts_len, argv[optind++]) ||
^
vsockserver.c:81:6: note: Left side of '||' is false
if (argz_add(&binder_opts, &binder_opts_len, "--") ||
^
vsockserver.c:83:6: note: Assuming the condition is false
argz_add(&binder_opts, &binder_opts_len, argv[optind++]))
^
vsockserver.c:81:2: note: Taking false branch
if (argz_add(&binder_opts, &binder_opts_len, "--") ||
^
vsockserver.c:89:6: note: Assuming the condition is false
if (argz_append(&binder_opts, &binder_opts_len, daemon_opts, daemon_opts_len))
^
vsockserver.c:89:2: note: Taking false branch
if (argz_append(&binder_opts, &binder_opts_len, daemon_opts, daemon_opts_len))
^
vsockserver.c:96:23: note: Assuming 'i' is >= 'argc'
for (int i = optind; i < argc; i++)
^
vsockserver.c:96:2: note: Loop condition is false. Execution continues on line 100
for (int i = optind; i < argc; i++)
^
vsockserver.c:100:6: note: Assuming 'verbosity' is equal to all
if (verbosity == all) {
^
vsockserver.c:100:2: note: Taking true branch
if (verbosity == all) {
^
vsockserver.c:101:3: note: 'opt' declared without an initial value
char *opt;
^
vsockserver.c:105:17: note: 3rd function call argument is an uninitialized value
while ((opt = argz_next(binder_opts, binder_opts_len, opt)))
---
vsockserver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/vsockserver.c b/vsockserver.c
index f740a8a..b717eee 100644
--- a/vsockserver.c
+++ b/vsockserver.c
@@ -98,7 +98,7 @@ int main(int argc, char *argv[])
diee(EX_OSERR, "malloc");
if (verbosity == all) {
- char *opt;
+ char *opt = 0;
// Log the full argv before we exec it.
fprintf(stderr, "%s: executing", program_invocation_short_name);
--
2.30.0
next prev parent reply other threads:[~2021-03-21 14:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-21 14:46 [PATCH ucspi-vsock 0/2] Fix clang-tidy warnings Alyssa Ross
2021-03-21 14:51 ` [PATCH ucspi-vsock 1/2] exec: free argv if exec fails Alyssa Ross
2021-03-21 14:54 ` Alyssa Ross [this message]
2021-03-21 16:30 ` [PATCH ucspi-vsock 0/2] Fix clang-tidy warnings Cole Helbling
2021-03-21 19:37 ` Alyssa Ross
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=20210321145440.28563-1-hi@alyssa.is \
--to=hi@alyssa.is \
--cc=cole.e.helbling@outlook.com \
--cc=devel@spectrum-os.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
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 NNTP newsgroup(s).