All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm crypt: remove an impossible condition
@ 2017-03-17 20:46 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2017-03-17 20:46 UTC (permalink / raw)
  To: Alasdair Kergon, Milan Broz
  Cc: Mike Snitzer, dm-devel, Shaohua Li, linux-raid, kernel-janitors

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("))) {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-03-18  4:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17 20:46 [PATCH] dm crypt: remove an impossible condition Dan Carpenter
2017-03-17 20:46 ` Dan Carpenter
2017-03-17 21:38 ` Mike Snitzer
2017-03-17 21:38   ` Mike Snitzer
2017-03-18  4:14   ` Dan Carpenter
2017-03-18  4:14     ` Dan Carpenter

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.