2022-02-14 10:38:33

by Aashish Sharma

[permalink] [raw]
Subject: [PATCH] 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]

Signed-off-by: Aashish Sharma <[email protected]>
---
drivers/md/dm-crypt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index d4ae31558826..489b23cb37c3 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -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 */
--
2.35.1.265.g69c8d7142f-goog