* [PATCH] USB-FHCI: Use a signed return type for fhci_create_ep()
@ 2015-12-19 20:15 SF Markus Elfring
2015-12-19 20:27 ` Dan Carpenter
2015-12-19 20:46 ` [PATCH] USB-FHCI: Use a signed return type for fhci_create_ep() Sergei Shtylyov
0 siblings, 2 replies; 8+ messages in thread
From: SF Markus Elfring @ 2015-12-19 20:15 UTC (permalink / raw)
To: linux-usb, Greg Kroah-Hartman; +Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 19 Dec 2015 21:10:20 +0100
The return type "u32" was used by the fhci_create_ep() function even though
it will eventually return a negative error code.
Improve this implementation detail by using the type "s32" instead.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/usb/host/fhci-tds.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/fhci-tds.c b/drivers/usb/host/fhci-tds.c
index f82ad5d..c1ae172 100644
--- a/drivers/usb/host/fhci-tds.c
+++ b/drivers/usb/host/fhci-tds.c
@@ -149,7 +149,7 @@ void fhci_ep0_free(struct fhci_usb *usb)
* data_mem The data memory partition(BUS)
* ring_len TD ring length
*/
-u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
+s32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
u32 ring_len)
{
struct endpoint *ep;
--
2.6.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] USB-FHCI: Use a signed return type for fhci_create_ep()
2015-12-19 20:15 [PATCH] USB-FHCI: Use a signed return type for fhci_create_ep() SF Markus Elfring
@ 2015-12-19 20:27 ` Dan Carpenter
2015-12-19 20:55 ` SF Markus Elfring
2015-12-22 15:48 ` [PATCH v2 0/2] USB-FHCI: Use return type "int" for two functions SF Markus Elfring
2015-12-19 20:46 ` [PATCH] USB-FHCI: Use a signed return type for fhci_create_ep() Sergei Shtylyov
1 sibling, 2 replies; 8+ messages in thread
From: Dan Carpenter @ 2015-12-19 20:27 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-usb, Greg Kroah-Hartman, LKML, kernel-janitors,
Julia Lawall
Just make it an int. The caller also casts it to u32...
regards,
dan carpenter
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] USB-FHCI: Use a signed return type for fhci_create_ep()
2015-12-19 20:15 [PATCH] USB-FHCI: Use a signed return type for fhci_create_ep() SF Markus Elfring
2015-12-19 20:27 ` Dan Carpenter
@ 2015-12-19 20:46 ` Sergei Shtylyov
1 sibling, 0 replies; 8+ messages in thread
From: Sergei Shtylyov @ 2015-12-19 20:46 UTC (permalink / raw)
To: SF Markus Elfring, linux-usb, Greg Kroah-Hartman
Cc: LKML, kernel-janitors, Julia Lawall
Hello.
On 12/19/2015 11:15 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 19 Dec 2015 21:10:20 +0100
>
> The return type "u32" was used by the fhci_create_ep() function even though
> it will eventually return a negative error code.
> Improve this implementation detail by using the type "s32" instead.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/usb/host/fhci-tds.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/fhci-tds.c b/drivers/usb/host/fhci-tds.c
> index f82ad5d..c1ae172 100644
> --- a/drivers/usb/host/fhci-tds.c
> +++ b/drivers/usb/host/fhci-tds.c
> @@ -149,7 +149,7 @@ void fhci_ep0_free(struct fhci_usb *usb)
> * data_mem The data memory partition(BUS)
> * ring_len TD ring length
> */
> -u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
> +s32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
Should be just *int*, I think.
[...]
MBR, Sergei
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] USB-FHCI: Use a signed return type for fhci_create_ep()
2015-12-19 20:27 ` Dan Carpenter
@ 2015-12-19 20:55 ` SF Markus Elfring
2015-12-19 21:04 ` Dan Carpenter
2015-12-22 15:48 ` [PATCH v2 0/2] USB-FHCI: Use return type "int" for two functions SF Markus Elfring
1 sibling, 1 reply; 8+ messages in thread
From: SF Markus Elfring @ 2015-12-19 20:55 UTC (permalink / raw)
To: Dan Carpenter
Cc: linux-usb, Greg Kroah-Hartman, LKML, kernel-janitors,
Julia Lawall
> Just make it an int.
Thanks for your suggestion.
Will any more software developers prefer this data type
at some source code places?
> The caller also casts it to u32...
Do you want to get rid of similar casts in affected functions?
Regards,
Markus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] USB-FHCI: Use a signed return type for fhci_create_ep()
2015-12-19 20:55 ` SF Markus Elfring
@ 2015-12-19 21:04 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2015-12-19 21:04 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-usb, Greg Kroah-Hartman, LKML, kernel-janitors,
Julia Lawall
On Sat, Dec 19, 2015 at 09:55:02PM +0100, SF Markus Elfring wrote:
> > Just make it an int.
>
> Thanks for your suggestion.
>
> Will any more software developers prefer this data type
> at some source code places?
>
Use s32 if the hardware spec specifies that you must. Otherwise prefer
ordinary types.
>
> > The caller also casts it to u32...
>
> Do you want to get rid of similar casts in affected functions?
If you want, that would be great. I just enjoy complaining generally,
though. :P
regards,
dan carpenter
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 0/2] USB-FHCI: Use return type "int" for two functions
2015-12-19 20:27 ` Dan Carpenter
2015-12-19 20:55 ` SF Markus Elfring
@ 2015-12-22 15:48 ` SF Markus Elfring
2015-12-22 15:51 ` [PATCH v2 1/2] USB-FHCI: Use a signed return type for fhci_create_ep() SF Markus Elfring
2015-12-22 15:54 ` [PATCH v2 2/2] USB-FHCI: Use a signed return type for endpoint_zero_init() SF Markus Elfring
1 sibling, 2 replies; 8+ messages in thread
From: SF Markus Elfring @ 2015-12-22 15:48 UTC (permalink / raw)
To: linux-usb, Dan Carpenter, Greg Kroah-Hartman
Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 22 Dec 2015 16:43:12 +0100
Another update suggestion was taken into account after a patch was applied
from static source code analysis.
Markus Elfring (2):
Use a signed return type for fhci_create_ep()
Use a signed return type for endpoint_zero_init()
drivers/usb/host/fhci-hcd.c | 4 ++--
drivers/usb/host/fhci-tds.c | 2 +-
drivers/usb/host/fhci.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
--
2.6.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/2] USB-FHCI: Use a signed return type for fhci_create_ep()
2015-12-22 15:48 ` [PATCH v2 0/2] USB-FHCI: Use return type "int" for two functions SF Markus Elfring
@ 2015-12-22 15:51 ` SF Markus Elfring
2015-12-22 15:54 ` [PATCH v2 2/2] USB-FHCI: Use a signed return type for endpoint_zero_init() SF Markus Elfring
1 sibling, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2015-12-22 15:51 UTC (permalink / raw)
To: linux-usb, Dan Carpenter, Greg Kroah-Hartman
Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 22 Dec 2015 16:10:14 +0100
The return type "u32" was used by the fhci_create_ep() function even though
it will eventually return a negative error code.
Improve this implementation detail by using the type "int" instead.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/usb/host/fhci-tds.c | 2 +-
drivers/usb/host/fhci.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/fhci-tds.c b/drivers/usb/host/fhci-tds.c
index f82ad5d..fc0b525 100644
--- a/drivers/usb/host/fhci-tds.c
+++ b/drivers/usb/host/fhci-tds.c
@@ -149,7 +149,7 @@ void fhci_ep0_free(struct fhci_usb *usb)
* data_mem The data memory partition(BUS)
* ring_len TD ring length
*/
-u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
+int fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
u32 ring_len)
{
struct endpoint *ep;
diff --git a/drivers/usb/host/fhci.h b/drivers/usb/host/fhci.h
index 154e6a0..afa3cfc 100644
--- a/drivers/usb/host/fhci.h
+++ b/drivers/usb/host/fhci.h
@@ -547,7 +547,7 @@ u32 fhci_host_transaction(struct fhci_usb *usb, struct packet *pkt,
void fhci_host_transmit_actual_frame(struct fhci_usb *usb);
void fhci_tx_conf_interrupt(struct fhci_usb *usb);
void fhci_push_dummy_bd(struct endpoint *ep);
-u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
+int fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
u32 ring_len);
void fhci_init_ep_registers(struct fhci_usb *usb,
struct endpoint *ep,
--
2.6.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/2] USB-FHCI: Use a signed return type for endpoint_zero_init()
2015-12-22 15:48 ` [PATCH v2 0/2] USB-FHCI: Use return type "int" for two functions SF Markus Elfring
2015-12-22 15:51 ` [PATCH v2 1/2] USB-FHCI: Use a signed return type for fhci_create_ep() SF Markus Elfring
@ 2015-12-22 15:54 ` SF Markus Elfring
1 sibling, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2015-12-22 15:54 UTC (permalink / raw)
To: linux-usb, Dan Carpenter, Greg Kroah-Hartman
Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 22 Dec 2015 16:24:46 +0100
The return type "u32" was used by the endpoint_zero_init() function
even though it can return a value which corresponds to a negative
error code from a call of the fhci_create_ep() function.
Improve this implementation detail by using the type "int" instead.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/usb/host/fhci-hcd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index c6cebb9..b2889f0 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -64,11 +64,11 @@ u16 fhci_get_sof_timer_count(struct fhci_usb *usb)
}
/* initialize the endpoint zero */
-static u32 endpoint_zero_init(struct fhci_usb *usb,
+static int endpoint_zero_init(struct fhci_usb *usb,
enum fhci_mem_alloc data_mem,
u32 ring_len)
{
- u32 rc;
+ int rc;
rc = fhci_create_ep(usb, data_mem, ring_len);
if (rc)
--
2.6.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-12-22 15:54 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-19 20:15 [PATCH] USB-FHCI: Use a signed return type for fhci_create_ep() SF Markus Elfring
2015-12-19 20:27 ` Dan Carpenter
2015-12-19 20:55 ` SF Markus Elfring
2015-12-19 21:04 ` Dan Carpenter
2015-12-22 15:48 ` [PATCH v2 0/2] USB-FHCI: Use return type "int" for two functions SF Markus Elfring
2015-12-22 15:51 ` [PATCH v2 1/2] USB-FHCI: Use a signed return type for fhci_create_ep() SF Markus Elfring
2015-12-22 15:54 ` [PATCH v2 2/2] USB-FHCI: Use a signed return type for endpoint_zero_init() SF Markus Elfring
2015-12-19 20:46 ` [PATCH] USB-FHCI: Use a signed return type for fhci_create_ep() Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).