* [PATCH] usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
@ 2019-09-25 11:02 ` Dan Carpenter
0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2019-09-25 11:02 UTC (permalink / raw)
To: Guenter Roeck
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, linux-kernel,
kernel-janitors
The "port->typec_caps.data" and "port->typec_caps.type" variables are
enums and in this context GCC will treat them as an unsigned int so they
can never be less than zero.
Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/usb/typec/tcpm/tcpm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 96562744101c..d3b63e000ae2 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -4410,7 +4410,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
if (ret == 0) {
port->typec_caps.data = typec_find_port_data_role(cap_str);
- if (port->typec_caps.data < 0)
+ if ((int)port->typec_caps.data < 0)
return -EINVAL;
}
@@ -4419,7 +4419,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
return ret;
port->typec_caps.type = typec_find_port_power_role(cap_str);
- if (port->typec_caps.type < 0)
+ if ((int)port->typec_caps.type < 0)
return -EINVAL;
port->port_type = port->typec_caps.type;
--
2.20.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH] usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
@ 2019-09-25 11:02 ` Dan Carpenter
0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2019-09-25 11:02 UTC (permalink / raw)
To: Guenter Roeck
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, linux-kernel,
kernel-janitors
The "port->typec_caps.data" and "port->typec_caps.type" variables are
enums and in this context GCC will treat them as an unsigned int so they
can never be less than zero.
Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/usb/typec/tcpm/tcpm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 96562744101c..d3b63e000ae2 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -4410,7 +4410,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
if (ret = 0) {
port->typec_caps.data = typec_find_port_data_role(cap_str);
- if (port->typec_caps.data < 0)
+ if ((int)port->typec_caps.data < 0)
return -EINVAL;
}
@@ -4419,7 +4419,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
return ret;
port->typec_caps.type = typec_find_port_power_role(cap_str);
- if (port->typec_caps.type < 0)
+ if ((int)port->typec_caps.type < 0)
return -EINVAL;
port->port_type = port->typec_caps.type;
--
2.20.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
2019-09-25 11:02 ` Dan Carpenter
@ 2019-09-26 12:53 ` Guenter Roeck
-1 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2019-09-26 12:53 UTC (permalink / raw)
To: Dan Carpenter
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, linux-kernel,
kernel-janitors
On Wed, Sep 25, 2019 at 02:02:19PM +0300, Dan Carpenter wrote:
> The "port->typec_caps.data" and "port->typec_caps.type" variables are
> enums and in this context GCC will treat them as an unsigned int so they
> can never be less than zero.
>
> Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/usb/typec/tcpm/tcpm.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 96562744101c..d3b63e000ae2 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4410,7 +4410,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
> if (ret == 0) {
> port->typec_caps.data = typec_find_port_data_role(cap_str);
> - if (port->typec_caps.data < 0)
> + if ((int)port->typec_caps.data < 0)
> return -EINVAL;
Doesn't that also cause a warning about overwriting error return codes ?
I would prefer something like
ret = typec_find_port_data_role(cap_str);
if (ret < 0)
return ret;
port->typec_caps.data = ret;
Guenter
> }
>
> @@ -4419,7 +4419,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> return ret;
>
> port->typec_caps.type = typec_find_port_power_role(cap_str);
> - if (port->typec_caps.type < 0)
> + if ((int)port->typec_caps.type < 0)
> return -EINVAL;
> port->port_type = port->typec_caps.type;
>
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
@ 2019-09-26 12:53 ` Guenter Roeck
0 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2019-09-26 12:53 UTC (permalink / raw)
To: Dan Carpenter
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, linux-kernel,
kernel-janitors
On Wed, Sep 25, 2019 at 02:02:19PM +0300, Dan Carpenter wrote:
> The "port->typec_caps.data" and "port->typec_caps.type" variables are
> enums and in this context GCC will treat them as an unsigned int so they
> can never be less than zero.
>
> Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/usb/typec/tcpm/tcpm.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 96562744101c..d3b63e000ae2 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4410,7 +4410,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
> if (ret = 0) {
> port->typec_caps.data = typec_find_port_data_role(cap_str);
> - if (port->typec_caps.data < 0)
> + if ((int)port->typec_caps.data < 0)
> return -EINVAL;
Doesn't that also cause a warning about overwriting error return codes ?
I would prefer something like
ret = typec_find_port_data_role(cap_str);
if (ret < 0)
return ret;
port->typec_caps.data = ret;
Guenter
> }
>
> @@ -4419,7 +4419,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> return ret;
>
> port->typec_caps.type = typec_find_port_power_role(cap_str);
> - if (port->typec_caps.type < 0)
> + if ((int)port->typec_caps.type < 0)
> return -EINVAL;
> port->port_type = port->typec_caps.type;
>
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
2019-09-26 12:53 ` Guenter Roeck
@ 2019-10-01 11:54 ` Dan Carpenter
-1 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2019-10-01 11:54 UTC (permalink / raw)
To: Guenter Roeck
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, linux-kernel,
kernel-janitors
On Thu, Sep 26, 2019 at 05:53:10AM -0700, Guenter Roeck wrote:
> On Wed, Sep 25, 2019 at 02:02:19PM +0300, Dan Carpenter wrote:
> > The "port->typec_caps.data" and "port->typec_caps.type" variables are
> > enums and in this context GCC will treat them as an unsigned int so they
> > can never be less than zero.
> >
> > Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > drivers/usb/typec/tcpm/tcpm.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> > index 96562744101c..d3b63e000ae2 100644
> > --- a/drivers/usb/typec/tcpm/tcpm.c
> > +++ b/drivers/usb/typec/tcpm/tcpm.c
> > @@ -4410,7 +4410,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> > ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
> > if (ret == 0) {
> > port->typec_caps.data = typec_find_port_data_role(cap_str);
> > - if (port->typec_caps.data < 0)
> > + if ((int)port->typec_caps.data < 0)
> > return -EINVAL;
>
> Doesn't that also cause a warning about overwriting error return codes ?
I'm happy that you think there is a tool which generates warnings like
that but it's just people manually complaining. :P
I'll resend though.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
@ 2019-10-01 11:54 ` Dan Carpenter
0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2019-10-01 11:54 UTC (permalink / raw)
To: Guenter Roeck
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, linux-kernel,
kernel-janitors
On Thu, Sep 26, 2019 at 05:53:10AM -0700, Guenter Roeck wrote:
> On Wed, Sep 25, 2019 at 02:02:19PM +0300, Dan Carpenter wrote:
> > The "port->typec_caps.data" and "port->typec_caps.type" variables are
> > enums and in this context GCC will treat them as an unsigned int so they
> > can never be less than zero.
> >
> > Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > drivers/usb/typec/tcpm/tcpm.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> > index 96562744101c..d3b63e000ae2 100644
> > --- a/drivers/usb/typec/tcpm/tcpm.c
> > +++ b/drivers/usb/typec/tcpm/tcpm.c
> > @@ -4410,7 +4410,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> > ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
> > if (ret = 0) {
> > port->typec_caps.data = typec_find_port_data_role(cap_str);
> > - if (port->typec_caps.data < 0)
> > + if ((int)port->typec_caps.data < 0)
> > return -EINVAL;
>
> Doesn't that also cause a warning about overwriting error return codes ?
I'm happy that you think there is a tool which generates warnings like
that but it's just people manually complaining. :P
I'll resend though.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2] usb: typec: tcpm: usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
2019-09-26 12:53 ` Guenter Roeck
@ 2019-10-01 12:01 ` Dan Carpenter
-1 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2019-10-01 12:01 UTC (permalink / raw)
To: Guenter Roeck
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, kernel-janitors
The "port->typec_caps.data" and "port->typec_caps.type" variables are
enums and in this context GCC will treat them as an unsigned int so they
can never be less than zero.
Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: preserve the error code
drivers/usb/typec/tcpm/tcpm.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 96562744101c..5f61d9977a15 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -4409,18 +4409,20 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
/* USB data support is optional */
ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
if (ret = 0) {
- port->typec_caps.data = typec_find_port_data_role(cap_str);
- if (port->typec_caps.data < 0)
- return -EINVAL;
+ ret = typec_find_port_data_role(cap_str);
+ if (ret < 0)
+ return ret;
+ port->typec_caps.data = ret;
}
ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
if (ret < 0)
return ret;
- port->typec_caps.type = typec_find_port_power_role(cap_str);
- if (port->typec_caps.type < 0)
- return -EINVAL;
+ ret = typec_find_port_power_role(cap_str);
+ if (ret < 0)
+ return ret;
+ port->typec_caps.type = ret;
port->port_type = port->typec_caps.type;
if (port->port_type = TYPEC_PORT_SNK)
--
2.20.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2] usb: typec: tcpm: usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
@ 2019-10-01 12:01 ` Dan Carpenter
0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2019-10-01 12:01 UTC (permalink / raw)
To: Guenter Roeck
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, kernel-janitors
The "port->typec_caps.data" and "port->typec_caps.type" variables are
enums and in this context GCC will treat them as an unsigned int so they
can never be less than zero.
Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: preserve the error code
drivers/usb/typec/tcpm/tcpm.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 96562744101c..5f61d9977a15 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -4409,18 +4409,20 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
/* USB data support is optional */
ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
if (ret == 0) {
- port->typec_caps.data = typec_find_port_data_role(cap_str);
- if (port->typec_caps.data < 0)
- return -EINVAL;
+ ret = typec_find_port_data_role(cap_str);
+ if (ret < 0)
+ return ret;
+ port->typec_caps.data = ret;
}
ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
if (ret < 0)
return ret;
- port->typec_caps.type = typec_find_port_power_role(cap_str);
- if (port->typec_caps.type < 0)
- return -EINVAL;
+ ret = typec_find_port_power_role(cap_str);
+ if (ret < 0)
+ return ret;
+ port->typec_caps.type = ret;
port->port_type = port->typec_caps.type;
if (port->port_type == TYPEC_PORT_SNK)
--
2.20.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2] usb: typec: tcpm: usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
2019-10-01 12:01 ` Dan Carpenter
@ 2019-10-01 12:04 ` Heikki Krogerus
-1 siblings, 0 replies; 14+ messages in thread
From: Heikki Krogerus @ 2019-10-01 12:04 UTC (permalink / raw)
To: Dan Carpenter
Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, kernel-janitors
On Tue, Oct 01, 2019 at 03:01:17PM +0300, Dan Carpenter wrote:
> The "port->typec_caps.data" and "port->typec_caps.type" variables are
> enums and in this context GCC will treat them as an unsigned int so they
> can never be less than zero.
>
> Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Looks OK to me.
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> v2: preserve the error code
>
> drivers/usb/typec/tcpm/tcpm.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 96562744101c..5f61d9977a15 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4409,18 +4409,20 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> /* USB data support is optional */
> ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
> if (ret = 0) {
> - port->typec_caps.data = typec_find_port_data_role(cap_str);
> - if (port->typec_caps.data < 0)
> - return -EINVAL;
> + ret = typec_find_port_data_role(cap_str);
> + if (ret < 0)
> + return ret;
> + port->typec_caps.data = ret;
> }
>
> ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
> if (ret < 0)
> return ret;
>
> - port->typec_caps.type = typec_find_port_power_role(cap_str);
> - if (port->typec_caps.type < 0)
> - return -EINVAL;
> + ret = typec_find_port_power_role(cap_str);
> + if (ret < 0)
> + return ret;
> + port->typec_caps.type = ret;
> port->port_type = port->typec_caps.type;
>
> if (port->port_type = TYPEC_PORT_SNK)
> --
> 2.20.1
thanks,
--
heikki
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] usb: typec: tcpm: usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
@ 2019-10-01 12:04 ` Heikki Krogerus
0 siblings, 0 replies; 14+ messages in thread
From: Heikki Krogerus @ 2019-10-01 12:04 UTC (permalink / raw)
To: Dan Carpenter
Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, kernel-janitors
On Tue, Oct 01, 2019 at 03:01:17PM +0300, Dan Carpenter wrote:
> The "port->typec_caps.data" and "port->typec_caps.type" variables are
> enums and in this context GCC will treat them as an unsigned int so they
> can never be less than zero.
>
> Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Looks OK to me.
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> v2: preserve the error code
>
> drivers/usb/typec/tcpm/tcpm.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 96562744101c..5f61d9977a15 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4409,18 +4409,20 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> /* USB data support is optional */
> ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
> if (ret == 0) {
> - port->typec_caps.data = typec_find_port_data_role(cap_str);
> - if (port->typec_caps.data < 0)
> - return -EINVAL;
> + ret = typec_find_port_data_role(cap_str);
> + if (ret < 0)
> + return ret;
> + port->typec_caps.data = ret;
> }
>
> ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
> if (ret < 0)
> return ret;
>
> - port->typec_caps.type = typec_find_port_power_role(cap_str);
> - if (port->typec_caps.type < 0)
> - return -EINVAL;
> + ret = typec_find_port_power_role(cap_str);
> + if (ret < 0)
> + return ret;
> + port->typec_caps.type = ret;
> port->port_type = port->typec_caps.type;
>
> if (port->port_type == TYPEC_PORT_SNK)
> --
> 2.20.1
thanks,
--
heikki
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
2019-10-01 11:54 ` Dan Carpenter
@ 2019-10-01 13:40 ` Guenter Roeck
-1 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2019-10-01 13:40 UTC (permalink / raw)
To: Dan Carpenter
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, linux-kernel,
kernel-janitors
On 10/1/19 4:54 AM, Dan Carpenter wrote:
> On Thu, Sep 26, 2019 at 05:53:10AM -0700, Guenter Roeck wrote:
>> On Wed, Sep 25, 2019 at 02:02:19PM +0300, Dan Carpenter wrote:
>>> The "port->typec_caps.data" and "port->typec_caps.type" variables are
>>> enums and in this context GCC will treat them as an unsigned int so they
>>> can never be less than zero.
>>>
>>> Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
>>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>> ---
>>> drivers/usb/typec/tcpm/tcpm.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
>>> index 96562744101c..d3b63e000ae2 100644
>>> --- a/drivers/usb/typec/tcpm/tcpm.c
>>> +++ b/drivers/usb/typec/tcpm/tcpm.c
>>> @@ -4410,7 +4410,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
>>> ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
>>> if (ret == 0) {
>>> port->typec_caps.data = typec_find_port_data_role(cap_str);
>>> - if (port->typec_caps.data < 0)
>>> + if ((int)port->typec_caps.data < 0)
>>> return -EINVAL;
>>
>> Doesn't that also cause a warning about overwriting error return codes ?
>
> I'm happy that you think there is a tool which generates warnings like
> that but it's just people manually complaining. :P
>
I am quite sure there is, or at least used to be - I have seen such warnings.
Maybe it was removed.
Guenter
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
@ 2019-10-01 13:40 ` Guenter Roeck
0 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2019-10-01 13:40 UTC (permalink / raw)
To: Dan Carpenter
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, linux-kernel,
kernel-janitors
On 10/1/19 4:54 AM, Dan Carpenter wrote:
> On Thu, Sep 26, 2019 at 05:53:10AM -0700, Guenter Roeck wrote:
>> On Wed, Sep 25, 2019 at 02:02:19PM +0300, Dan Carpenter wrote:
>>> The "port->typec_caps.data" and "port->typec_caps.type" variables are
>>> enums and in this context GCC will treat them as an unsigned int so they
>>> can never be less than zero.
>>>
>>> Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
>>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>> ---
>>> drivers/usb/typec/tcpm/tcpm.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
>>> index 96562744101c..d3b63e000ae2 100644
>>> --- a/drivers/usb/typec/tcpm/tcpm.c
>>> +++ b/drivers/usb/typec/tcpm/tcpm.c
>>> @@ -4410,7 +4410,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
>>> ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
>>> if (ret = 0) {
>>> port->typec_caps.data = typec_find_port_data_role(cap_str);
>>> - if (port->typec_caps.data < 0)
>>> + if ((int)port->typec_caps.data < 0)
>>> return -EINVAL;
>>
>> Doesn't that also cause a warning about overwriting error return codes ?
>
> I'm happy that you think there is a tool which generates warnings like
> that but it's just people manually complaining. :P
>
I am quite sure there is, or at least used to be - I have seen such warnings.
Maybe it was removed.
Guenter
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] usb: typec: tcpm: usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
2019-10-01 12:01 ` Dan Carpenter
@ 2019-10-01 13:42 ` Guenter Roeck
-1 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2019-10-01 13:42 UTC (permalink / raw)
To: Dan Carpenter
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, kernel-janitors
On 10/1/19 5:01 AM, Dan Carpenter wrote:
> The "port->typec_caps.data" and "port->typec_caps.type" variables are
> enums and in this context GCC will treat them as an unsigned int so they
> can never be less than zero.
>
> Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> v2: preserve the error code
>
> drivers/usb/typec/tcpm/tcpm.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 96562744101c..5f61d9977a15 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4409,18 +4409,20 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> /* USB data support is optional */
> ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
> if (ret = 0) {
> - port->typec_caps.data = typec_find_port_data_role(cap_str);
> - if (port->typec_caps.data < 0)
> - return -EINVAL;
> + ret = typec_find_port_data_role(cap_str);
> + if (ret < 0)
> + return ret;
> + port->typec_caps.data = ret;
> }
>
> ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
> if (ret < 0)
> return ret;
>
> - port->typec_caps.type = typec_find_port_power_role(cap_str);
> - if (port->typec_caps.type < 0)
> - return -EINVAL;
> + ret = typec_find_port_power_role(cap_str);
> + if (ret < 0)
> + return ret;
> + port->typec_caps.type = ret;
> port->port_type = port->typec_caps.type;
>
> if (port->port_type = TYPEC_PORT_SNK)
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] usb: typec: tcpm: usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()
@ 2019-10-01 13:42 ` Guenter Roeck
0 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2019-10-01 13:42 UTC (permalink / raw)
To: Dan Carpenter
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, kernel-janitors
On 10/1/19 5:01 AM, Dan Carpenter wrote:
> The "port->typec_caps.data" and "port->typec_caps.type" variables are
> enums and in this context GCC will treat them as an unsigned int so they
> can never be less than zero.
>
> Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> v2: preserve the error code
>
> drivers/usb/typec/tcpm/tcpm.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 96562744101c..5f61d9977a15 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4409,18 +4409,20 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> /* USB data support is optional */
> ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
> if (ret == 0) {
> - port->typec_caps.data = typec_find_port_data_role(cap_str);
> - if (port->typec_caps.data < 0)
> - return -EINVAL;
> + ret = typec_find_port_data_role(cap_str);
> + if (ret < 0)
> + return ret;
> + port->typec_caps.data = ret;
> }
>
> ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
> if (ret < 0)
> return ret;
>
> - port->typec_caps.type = typec_find_port_power_role(cap_str);
> - if (port->typec_caps.type < 0)
> - return -EINVAL;
> + ret = typec_find_port_power_role(cap_str);
> + if (ret < 0)
> + return ret;
> + port->typec_caps.type = ret;
> port->port_type = port->typec_caps.type;
>
> if (port->port_type == TYPEC_PORT_SNK)
>
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2019-10-01 13:42 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25 11:02 [PATCH] usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps() Dan Carpenter
2019-09-25 11:02 ` Dan Carpenter
2019-09-26 12:53 ` Guenter Roeck
2019-09-26 12:53 ` Guenter Roeck
2019-10-01 11:54 ` Dan Carpenter
2019-10-01 11:54 ` Dan Carpenter
2019-10-01 13:40 ` Guenter Roeck
2019-10-01 13:40 ` Guenter Roeck
2019-10-01 12:01 ` [PATCH v2] usb: typec: tcpm: " Dan Carpenter
2019-10-01 12:01 ` Dan Carpenter
2019-10-01 12:04 ` Heikki Krogerus
2019-10-01 12:04 ` Heikki Krogerus
2019-10-01 13:42 ` Guenter Roeck
2019-10-01 13:42 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.