From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alasdair Kergon <agk@redhat.com>, Milan Broz <gmazyland@gmail.com>
Cc: Mike Snitzer <snitzer@redhat.com>,
dm-devel@redhat.com, Shaohua Li <shli@kernel.org>,
linux-raid@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] dm crypt: remove an impossible condition
Date: Fri, 17 Mar 2017 23:46:56 +0300 [thread overview]
Message-ID: <20170317204655.GA28261@mwanda> (raw)
Static checkers complain that it doesn't make sense to check if "sval"
is NULL. The intention was to check if strchr() returned NULL, but in
that situation "sval" would be "NULL + 1" so the check doesn't work. We
know from the sscanf() that there is a ':' character in the string so
the check is unnecessary and can be removed.
Now that the check doesn't depend on "sval" it can be moved earlier
for readability.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index ec09bd703b7d..eba218737bdb 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -2401,12 +2401,12 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar
else if (!strcasecmp(opt_string, "submit_from_crypt_cpus"))
set_bit(DM_CRYPT_NO_OFFLOAD, &cc->flags);
else if (sscanf(opt_string, "integrity:%u:", &val) == 1) {
- cc->on_disk_tag_size = val;
- sval = strchr(opt_string + strlen("integrity:"), ':') + 1;
- if (val == 0 || val > MAX_TAG_SIZE || !sval) {
+ if (val == 0 || val > MAX_TAG_SIZE) {
ti->error = "Invalid integrity arguments";
return -EINVAL;
}
+ cc->on_disk_tag_size = val;
+ sval = strchr(opt_string + strlen("integrity:"), ':') + 1;
if (!strcasecmp(sval, "aead")) {
set_bit(CRYPT_MODE_INTEGRITY_AEAD, &cc->cipher_flags);
} else if (!strncasecmp(sval, "hmac(", strlen("hmac("))) {
next reply other threads:[~2017-03-17 20:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 20:46 Dan Carpenter [this message]
2017-03-17 21:38 ` dm crypt: remove an impossible condition Mike Snitzer
2017-03-18 4:14 ` Dan Carpenter
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=20170317204655.GA28261@mwanda \
--to=dan.carpenter@oracle.com \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=gmazyland@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=shli@kernel.org \
--cc=snitzer@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 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).