* [PATCH] usb: typec: ucsi: fix Clang -Wsign-conversion warning
@ 2025-04-22 13:47 Qasim Ijaz
2025-04-23 13:43 ` Heikki Krogerus
0 siblings, 1 reply; 2+ messages in thread
From: Qasim Ijaz @ 2025-04-22 13:47 UTC (permalink / raw)
To: heikki.krogerus, gregkh, lumag, pooja.katiyar, diogo.ivo, madhu.m,
saranya.gopal
Cc: linux-usb, linux-kernel, stable
debugfs.c emits the following warnings when compiling with the -Wsign-conversion flag with clang 15:
drivers/usb/typec/ucsi/debugfs.c:58:27: warning: implicit conversion changes signedness: 'int' to 'u32' (aka 'unsigned int') [-Wsign-conversion]
ucsi->debugfs->status = ret;
~ ^~~
drivers/usb/typec/ucsi/debugfs.c:71:25: warning: implicit conversion changes signedness: 'u32' (aka 'unsigned int') to 'int' [-Wsign-conversion]
return ucsi->debugfs->status;
~~~~~~ ~~~~~~~~~~~~~~~^~~~~~
During ucsi_cmd() we see:
if (ret < 0) {
ucsi->debugfs->status = ret;
return ret;
}
But "status" is u32 meaning unsigned wrap-around occurs when assigning a value which is < 0 to it, this obscures the real status.
To fix this make the "status" of type int since ret is also of type int.
Fixes: df0383ffad64 ("usb: typec: ucsi: Add debugfs for ucsi commands")
Cc: stable@vger.kernel.org
Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
---
drivers/usb/typec/ucsi/ucsi.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h
index 3a2c1762bec1..525d28160413 100644
--- a/drivers/usb/typec/ucsi/ucsi.h
+++ b/drivers/usb/typec/ucsi/ucsi.h
@@ -432,7 +432,7 @@ struct ucsi_debugfs_entry {
u64 low;
u64 high;
} response;
- u32 status;
+ int status;
struct dentry *dentry;
};
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: typec: ucsi: fix Clang -Wsign-conversion warning
2025-04-22 13:47 [PATCH] usb: typec: ucsi: fix Clang -Wsign-conversion warning Qasim Ijaz
@ 2025-04-23 13:43 ` Heikki Krogerus
0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2025-04-23 13:43 UTC (permalink / raw)
To: Qasim Ijaz
Cc: gregkh, lumag, pooja.katiyar, diogo.ivo, madhu.m, saranya.gopal,
linux-usb, linux-kernel, stable
On Tue, Apr 22, 2025 at 02:47:17PM +0100, Qasim Ijaz wrote:
> debugfs.c emits the following warnings when compiling with the -Wsign-conversion flag with clang 15:
>
> drivers/usb/typec/ucsi/debugfs.c:58:27: warning: implicit conversion changes signedness: 'int' to 'u32' (aka 'unsigned int') [-Wsign-conversion]
> ucsi->debugfs->status = ret;
> ~ ^~~
> drivers/usb/typec/ucsi/debugfs.c:71:25: warning: implicit conversion changes signedness: 'u32' (aka 'unsigned int') to 'int' [-Wsign-conversion]
> return ucsi->debugfs->status;
> ~~~~~~ ~~~~~~~~~~~~~~~^~~~~~
>
> During ucsi_cmd() we see:
>
> if (ret < 0) {
> ucsi->debugfs->status = ret;
> return ret;
> }
>
> But "status" is u32 meaning unsigned wrap-around occurs when assigning a value which is < 0 to it, this obscures the real status.
>
> To fix this make the "status" of type int since ret is also of type int.
>
> Fixes: df0383ffad64 ("usb: typec: ucsi: Add debugfs for ucsi commands")
> Cc: stable@vger.kernel.org
> Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/ucsi/ucsi.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h
> index 3a2c1762bec1..525d28160413 100644
> --- a/drivers/usb/typec/ucsi/ucsi.h
> +++ b/drivers/usb/typec/ucsi/ucsi.h
> @@ -432,7 +432,7 @@ struct ucsi_debugfs_entry {
> u64 low;
> u64 high;
> } response;
> - u32 status;
> + int status;
> struct dentry *dentry;
> };
>
> --
> 2.39.5
--
heikki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-23 13:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-22 13:47 [PATCH] usb: typec: ucsi: fix Clang -Wsign-conversion warning Qasim Ijaz
2025-04-23 13:43 ` Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox