All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - cov: hide reports from optarg being NULL
Date: Mon, 20 Sep 2021 13:30:17 +0000 (GMT)	[thread overview]
Message-ID: <20210920133017.BEDD13858C60@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=548c69f58174b3cb3997c0fcff09276bd7502796
Commit:        548c69f58174b3cb3997c0fcff09276bd7502796
Parent:        efaab93491751ccf39108d076745c6774b263232
Author:        Zdenek Kabelac <zkabelac@redhat.com>
AuthorDate:    Sun Sep 19 20:19:52 2021 +0200
Committer:     Zdenek Kabelac <zkabelac@redhat.com>
CommitterDate: Mon Sep 20 14:26:09 2021 +0200

cov: hide reports from optarg being NULL

It's basically irrelavant which value we assing to optarg,
since it's set by getopt() function, but Coverity tool
is incorrectly reporting possibly dereference of NULL.
---
 libdm/dm-tools/dmsetup.c | 4 ++--
 tools/lvmcmdline.c       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index f6d1ecf90..0f260b3f4 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -6680,7 +6680,7 @@ static int _process_losetup_switches(const char *base, int *argcp, char ***argvp
 	};
 #endif
 
-	optarg = 0;
+	optarg = (char*) "";
 	optind = OPTIND_INIT;
 	while ((c = GETOPTLONG_FN(*argcp, *argvp, "ade:fo:v",
 				  long_options, NULL)) != -1 ) {
@@ -6976,7 +6976,7 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
 		return r;
 	}
 
-	optarg = 0;
+	optarg = (char*) "";
 	optind = OPTIND_INIT;
 	while ((ind = -1, c = GETOPTLONG_FN(*argcp, *argvp, "cCfG:hj:m:M:no:O:rS:u:U:vy",
 					    long_options, NULL)) != -1) {
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index de70e63c9..7c5930006 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -2236,7 +2236,7 @@ static int _process_command_line(struct cmd_context *cmd, int *argc, char ***arg
 	*ptr = '\0';
 	memset(o, 0, sizeof(*o));
 
-	optarg = 0;
+	optarg = (char*) "";
 	optind = OPTIND_INIT;
 	while ((goval = GETOPTLONG_FN(*argc, *argv, str, opts, NULL)) >= 0) {
 



                 reply	other threads:[~2021-09-20 13:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210920133017.BEDD13858C60@sourceware.org \
    --to=zkabelac@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.