Skip to content

Commit

Permalink
Suppress sparse warning
Browse files Browse the repository at this point in the history
Reported by sparse:
examples/cryptosk.c: In function ‘test_skcipher_encrypt’:
examples/cryptosk.c:121:35: error: passing argument 3 of
‘skcipher_request_set_callback’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  121 |                                   test_skcipher_callback, &sk->result);
      |                                   ^~~~~~~~~~~~~~~~~~~~~~
      |                                   |
      |                                   void (*)(struct crypto_async_request *, int)
In file included from ./include/crypto/internal/skcipher.h:13,
                 from examples/cryptosk.c:4:
./include/crypto/skcipher.h:576:70: note: expected ‘crypto_completion_t’
{aka ‘void (*)(void *, int)’} but argument is of type ‘void (*)(struct crypto_async_request *, int)’
  576 |                                                  crypto_completion_t compl,
      |                                                  ~~~~~~~~~~~~~~~~~~~~^~~~~
cc1: some warnings being treated as errors
  • Loading branch information
jserv committed Apr 15, 2024
1 parent 1d38d2e commit eee8c61
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/cryptosk.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ static int test_skcipher_encrypt(char *plaintext, char *password,
{
int ret = -EFAULT;
unsigned char key[SYMMETRIC_KEY_LENGTH];
crypto_completion_t compl ;

if (!sk->tfm) {
sk->tfm = crypto_alloc_skcipher("cbc-aes-aesni", 0, 0);
Expand All @@ -117,8 +118,9 @@ static int test_skcipher_encrypt(char *plaintext, char *password,
}
}

skcipher_request_set_callback(sk->req, CRYPTO_TFM_REQ_MAY_BACKLOG,
test_skcipher_callback, &sk->result);
compl = (crypto_completion_t)test_skcipher_callback;
skcipher_request_set_callback(sk->req, CRYPTO_TFM_REQ_MAY_BACKLOG, compl,
&sk->result);

/* clear the key */
memset((void *)key, '\0', SYMMETRIC_KEY_LENGTH);
Expand Down

0 comments on commit eee8c61

Please sign in to comment.