[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240811205509.1089027-1-jain.abhinav177@gmail.com>
Date: Mon, 12 Aug 2024 02:25:09 +0530
From: Abhinav Jain <jain.abhinav177@...il.com>
To: idryomov@...il.com,
xiubli@...hat.com,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
ceph-devel@...r.kernel.org,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: skhan@...uxfoundation.org,
javier.carrasco.cruz@...il.com,
Abhinav Jain <jain.abhinav177@...il.com>
Subject: [PATCH net v2] libceph: Make the arguments const as per the TODO
net/ceph/crypto.c:
Modify arguments to const in ceph_crypto_key_decode().
Modify ceph_key_preparse() and ceph_crypto_key_unarmor()
in accordance with the changes.
net/ceph/crypto.h:
Add changes in the prototype of ceph_crypto_key_decode().
net/ceph/auth_x.c:
Modify the arguments to function ceph_crypto_key_decode()
being called in the function process_one_ticket().
v1:
lore.kernel.org/all/20240811193645.1082042-1-jain.abhinav177@...il.com
Changes since v1:
- Incorrect changes made in v1 fixed.
- Found the other files where the change needed to be made.
Signed-off-by: Abhinav Jain <jain.abhinav177@...il.com>
---
net/ceph/auth_x.c | 4 +++-
net/ceph/crypto.c | 15 ++++++++-------
net/ceph/crypto.h | 2 +-
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c
index b71b1635916e..81272603f981 100644
--- a/net/ceph/auth_x.c
+++ b/net/ceph/auth_x.c
@@ -204,7 +204,9 @@ static int process_one_ticket(struct ceph_auth_client *ac,
if (tkt_struct_v != 1)
goto bad;
- ret = ceph_crypto_key_decode(&new_session_key, &dp, dend);
+ ret = ceph_crypto_key_decode(&new_session_key, \
+ (const void **)&dp, (const void *)dend);
+
if (ret)
goto out;
diff --git a/net/ceph/crypto.c b/net/ceph/crypto.c
index 051d22c0e4ad..905b80d738b1 100644
--- a/net/ceph/crypto.c
+++ b/net/ceph/crypto.c
@@ -86,7 +86,7 @@ int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end)
return 0;
}
-int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end)
+int ceph_crypto_key_decode(struct ceph_crypto_key *key, const void **p, const void *end)
{
int ret;
@@ -109,7 +109,8 @@ int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *inkey)
{
int inlen = strlen(inkey);
int blen = inlen * 3 / 4;
- void *buf, *p;
+ void *buf;
+ const void *p;
int ret;
dout("crypto_key_unarmor %s\n", inkey);
@@ -123,7 +124,7 @@ int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *inkey)
}
p = buf;
- ret = ceph_crypto_key_decode(key, &p, p + blen);
+ ret = ceph_crypto_key_decode(key, &p, (const void *)((const char *)p + blen));
kfree(buf);
if (ret)
return ret;
@@ -300,7 +301,7 @@ static int ceph_key_preparse(struct key_preparsed_payload *prep)
struct ceph_crypto_key *ckey;
size_t datalen = prep->datalen;
int ret;
- void *p;
+ const void *p;
ret = -EINVAL;
if (datalen <= 0 || datalen > 32767 || !prep->data)
@@ -311,9 +312,9 @@ static int ceph_key_preparse(struct key_preparsed_payload *prep)
if (!ckey)
goto err;
- /* TODO ceph_crypto_key_decode should really take const input */
- p = (void *)prep->data;
- ret = ceph_crypto_key_decode(ckey, &p, (char*)prep->data+datalen);
+ p = prep->data;
+ ret = ceph_crypto_key_decode(ckey, &p, \
+ (const void *)((const char *)prep->data + datalen));
if (ret < 0)
goto err_ckey;
diff --git a/net/ceph/crypto.h b/net/ceph/crypto.h
index 13bd526349fa..ba57376fa635 100644
--- a/net/ceph/crypto.h
+++ b/net/ceph/crypto.h
@@ -22,7 +22,7 @@ struct ceph_crypto_key {
int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
const struct ceph_crypto_key *src);
int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end);
-int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
+int ceph_crypto_key_decode(struct ceph_crypto_key *key, const void **p, const void *end);
int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *in);
void ceph_crypto_key_destroy(struct ceph_crypto_key *key);
--
2.34.1
Powered by blists - more mailing lists