Skip to contentSkip to conversation

dm crypt: fixed compiler warning in conditional expression

PATCH New Aashish Sharma 1 participant 1 message Feb 11, 2022 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm crypt: fixed compiler warning in conditional expression

Explicitly converting unsigned int in the right of the conditional expression to int to match the left side operand and the return type, fixing the following compiler warning:

drivers/md/dm-crypt.c:2593:43: warning: signed and unsigned type in conditional expression [-Wsign-compare]

---
 drivers/md/dm-crypt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/dm-crypt.c +2 -1
index d4ae31558826..489b23cb37c3 100644
@@ -2590,7 +2590,8 @@ static int crypt_set_keyring_key(struct crypt_config *cc, const char *key_string
 
 static int get_key_size(char **key_string)
 {
-	return (*key_string[0] == ':') ? -EINVAL : strlen(*key_string) >> 1;
+	return (*key_string[0] == ':') ? -EINVAL
+				: (int)(strlen(*key_string) >> 1);
 }
 
 #endif /* CONFIG_KEYS */
Signature · 1 line
2.35.1.265.g69c8d7142f-goog