* [PATCH 0/3] crypto: Use int type to store negative error codes
@ 2025-09-03 13:25 Qianfeng Rong
2025-09-03 13:25 ` [PATCH 1/3] crypto: ccp - " Qianfeng Rong
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Qianfeng Rong @ 2025-09-03 13:25 UTC (permalink / raw)
To: Ashish Kalra, Tom Lendacky, John Allen, Herbert Xu,
David S. Miller, Akhil R, Thierry Reding, Jonathan Hunter,
Uwe Kleine-König, Colin Ian King, Qianfeng Rong,
open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - SE...,
open list, open list:TEGRA ARCHITECTURE SUPPORT
The 'ret' variable usually is used to store returns from some functions,
which return either zero on success or negative error codes on failure.
Storing the negative error codes in unsigned type, doesn't cause an issue
at runtime but can be confusing. Additionally, assigning negative error
codes to unsigned type may trigger a GCC warning when the -Wsign-conversion
flag is enabled.
Change 'ret' from u32/unsigned int to int type. No effect on runtime.
Qianfeng Rong (3):
crypto: ccp - Use int type to store negative error codes
crypto: hisilicon/sec - Use int type to store negative error codes
crypto: tegra - Use int type to store negative error codes
drivers/crypto/ccp/sev-dev.c | 3 ++-
drivers/crypto/hisilicon/sec/sec_drv.c | 3 ++-
drivers/crypto/tegra/tegra-se-hash.c | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] crypto: ccp - Use int type to store negative error codes
2025-09-03 13:25 [PATCH 0/3] crypto: Use int type to store negative error codes Qianfeng Rong
@ 2025-09-03 13:25 ` Qianfeng Rong
2025-09-08 16:00 ` Tom Lendacky
2025-09-03 13:25 ` [PATCH 2/3] crypto: hisilicon/sec " Qianfeng Rong
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Qianfeng Rong @ 2025-09-03 13:25 UTC (permalink / raw)
To: Ashish Kalra, Tom Lendacky, John Allen, Herbert Xu,
David S. Miller,
open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - SE...,
open list
Cc: Qianfeng Rong
Change the 'ret' variable in __sev_do_cmd_locked() from unsigned int to
int, as it needs to store negative error codes.
No effect on runtime.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
drivers/crypto/ccp/sev-dev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 4f000dc2e639..6c116f6f9b79 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -848,9 +848,10 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
struct sev_device *sev;
unsigned int cmdbuff_hi, cmdbuff_lo;
unsigned int phys_lsb, phys_msb;
- unsigned int reg, ret = 0;
+ unsigned int reg;
void *cmd_buf;
int buf_len;
+ int ret = 0;
if (!psp || !psp->sev_data)
return -ENODEV;
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] crypto: hisilicon/sec - Use int type to store negative error codes
2025-09-03 13:25 [PATCH 0/3] crypto: Use int type to store negative error codes Qianfeng Rong
2025-09-03 13:25 ` [PATCH 1/3] crypto: ccp - " Qianfeng Rong
@ 2025-09-03 13:25 ` Qianfeng Rong
2025-09-03 13:25 ` [PATCH 3/3] crypto: tegra " Qianfeng Rong
2025-09-13 4:27 ` [PATCH 0/3] crypto: " Herbert Xu
3 siblings, 0 replies; 6+ messages in thread
From: Qianfeng Rong @ 2025-09-03 13:25 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Uwe Kleine-König,
Qianfeng Rong, Colin Ian King, open list:CRYPTO API, open list
Change the 'ret' variable in sec_hw_init() from u32 to int, as
it needs to store either negative error codes or zero returned by
sec_ipv4_hashmask().
No effect on runtime.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
drivers/crypto/hisilicon/sec/sec_drv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/hisilicon/sec/sec_drv.c b/drivers/crypto/hisilicon/sec/sec_drv.c
index ef0cb733c92c..129cb6faa0b7 100644
--- a/drivers/crypto/hisilicon/sec/sec_drv.c
+++ b/drivers/crypto/hisilicon/sec/sec_drv.c
@@ -922,7 +922,8 @@ static int sec_hw_init(struct sec_dev_info *info)
struct iommu_domain *domain;
u32 sec_ipv4_mask = 0;
u32 sec_ipv6_mask[10] = {};
- u32 i, ret;
+ int ret;
+ u32 i;
domain = iommu_get_domain_for_dev(info->dev);
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] crypto: tegra - Use int type to store negative error codes
2025-09-03 13:25 [PATCH 0/3] crypto: Use int type to store negative error codes Qianfeng Rong
2025-09-03 13:25 ` [PATCH 1/3] crypto: ccp - " Qianfeng Rong
2025-09-03 13:25 ` [PATCH 2/3] crypto: hisilicon/sec " Qianfeng Rong
@ 2025-09-03 13:25 ` Qianfeng Rong
2025-09-13 4:27 ` [PATCH 0/3] crypto: " Herbert Xu
3 siblings, 0 replies; 6+ messages in thread
From: Qianfeng Rong @ 2025-09-03 13:25 UTC (permalink / raw)
To: Akhil R, Herbert Xu, David S. Miller, Thierry Reding,
Jonathan Hunter, open list:CRYPTO API,
open list:TEGRA ARCHITECTURE SUPPORT, open list
Cc: Qianfeng Rong
Change the 'ret' variable in tegra_sha_do_update() from unsigned int to
int, as it needs to store either negative error codes or zero returned
by tegra_se_host1x_submit().
No effect on runtime.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
drivers/crypto/tegra/tegra-se-hash.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/tegra/tegra-se-hash.c b/drivers/crypto/tegra/tegra-se-hash.c
index d09b4aaeecef..4a298ace6e9f 100644
--- a/drivers/crypto/tegra/tegra-se-hash.c
+++ b/drivers/crypto/tegra/tegra-se-hash.c
@@ -400,8 +400,9 @@ static int tegra_sha_do_update(struct ahash_request *req)
struct tegra_sha_ctx *ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
struct tegra_sha_reqctx *rctx = ahash_request_ctx(req);
struct tegra_se *se = ctx->se;
- unsigned int nblks, nresidue, size, ret;
+ unsigned int nblks, nresidue, size;
u32 *cpuvaddr = se->cmdbuf->addr;
+ int ret;
nresidue = (req->nbytes + rctx->residue.size) % rctx->blk_size;
nblks = (req->nbytes + rctx->residue.size) / rctx->blk_size;
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] crypto: ccp - Use int type to store negative error codes
2025-09-03 13:25 ` [PATCH 1/3] crypto: ccp - " Qianfeng Rong
@ 2025-09-08 16:00 ` Tom Lendacky
0 siblings, 0 replies; 6+ messages in thread
From: Tom Lendacky @ 2025-09-08 16:00 UTC (permalink / raw)
To: Qianfeng Rong, Ashish Kalra, John Allen, Herbert Xu,
David S. Miller,
open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - SE...,
open list
On 9/3/25 08:25, Qianfeng Rong wrote:
> Change the 'ret' variable in __sev_do_cmd_locked() from unsigned int to
> int, as it needs to store negative error codes.
>
> No effect on runtime.
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Not sure it needs to be initialized either, but not worth changing that
as part of this patch.
> ---
> drivers/crypto/ccp/sev-dev.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index 4f000dc2e639..6c116f6f9b79 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -848,9 +848,10 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
> struct sev_device *sev;
> unsigned int cmdbuff_hi, cmdbuff_lo;
> unsigned int phys_lsb, phys_msb;
> - unsigned int reg, ret = 0;
> + unsigned int reg;
> void *cmd_buf;
> int buf_len;
> + int ret = 0;
>
> if (!psp || !psp->sev_data)
> return -ENODEV;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] crypto: Use int type to store negative error codes
2025-09-03 13:25 [PATCH 0/3] crypto: Use int type to store negative error codes Qianfeng Rong
` (2 preceding siblings ...)
2025-09-03 13:25 ` [PATCH 3/3] crypto: tegra " Qianfeng Rong
@ 2025-09-13 4:27 ` Herbert Xu
3 siblings, 0 replies; 6+ messages in thread
From: Herbert Xu @ 2025-09-13 4:27 UTC (permalink / raw)
To: Qianfeng Rong
Cc: Ashish Kalra, Tom Lendacky, John Allen, David S. Miller, Akhil R,
Thierry Reding, Jonathan Hunter, Uwe Kleine-König,
Colin Ian King,
open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - SE...,
open list, open list:TEGRA ARCHITECTURE SUPPORT
On Wed, Sep 03, 2025 at 09:25:34PM +0800, Qianfeng Rong wrote:
> The 'ret' variable usually is used to store returns from some functions,
> which return either zero on success or negative error codes on failure.
>
> Storing the negative error codes in unsigned type, doesn't cause an issue
> at runtime but can be confusing. Additionally, assigning negative error
> codes to unsigned type may trigger a GCC warning when the -Wsign-conversion
> flag is enabled.
>
> Change 'ret' from u32/unsigned int to int type. No effect on runtime.
>
> Qianfeng Rong (3):
> crypto: ccp - Use int type to store negative error codes
> crypto: hisilicon/sec - Use int type to store negative error codes
> crypto: tegra - Use int type to store negative error codes
>
> drivers/crypto/ccp/sev-dev.c | 3 ++-
> drivers/crypto/hisilicon/sec/sec_drv.c | 3 ++-
> drivers/crypto/tegra/tegra-se-hash.c | 3 ++-
> 3 files changed, 6 insertions(+), 3 deletions(-)
>
> --
> 2.34.1
All applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-09-13 4:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-03 13:25 [PATCH 0/3] crypto: Use int type to store negative error codes Qianfeng Rong
2025-09-03 13:25 ` [PATCH 1/3] crypto: ccp - " Qianfeng Rong
2025-09-08 16:00 ` Tom Lendacky
2025-09-03 13:25 ` [PATCH 2/3] crypto: hisilicon/sec " Qianfeng Rong
2025-09-03 13:25 ` [PATCH 3/3] crypto: tegra " Qianfeng Rong
2025-09-13 4:27 ` [PATCH 0/3] crypto: " Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®