* [PATCH] staging: gpib: Change return type of fluke_get_dma_residue
@ 2024-10-15 20:33 Kees Bakker
2024-11-03 23:45 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Kees Bakker @ 2024-10-15 20:33 UTC (permalink / raw)
To: Dave Penkler; +Cc: Linux Staging
The function fluke_get_dma_residue returns an error as a negative value.
So the return type must not be unsigned.
This was detected by Coverity, CID 1600782
Signed-off-by: Kees Bakker <kees@ijzerbout.nl>
---
v1 -> v2: change type of `residue` var; add note about Coverity CID in commit message
drivers/staging/gpib/eastwood/fluke_gpib.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/gpib/eastwood/fluke_gpib.c b/drivers/staging/gpib/eastwood/fluke_gpib.c
index f9f149db222d..3843e986f104 100644
--- a/drivers/staging/gpib/eastwood/fluke_gpib.c
+++ b/drivers/staging/gpib/eastwood/fluke_gpib.c
@@ -536,7 +536,7 @@ static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length
return 0;
}
-static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
+static int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
{
struct dma_tx_state state;
int result;
@@ -549,7 +549,7 @@ static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t co
dmaengine_tx_status(chan, cookie, &state);
// hardware doesn't support resume, so dont call this
// method unless the dma transfer is done.
- return state.residue;
+ return (int)state.residue;
}
static int fluke_dma_read(gpib_board_t *board, uint8_t *buffer,
@@ -559,7 +559,7 @@ static int fluke_dma_read(gpib_board_t *board, uint8_t *buffer,
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
int retval = 0;
unsigned long flags;
- unsigned int residue;
+ int residue;
dma_addr_t bus_address;
struct dma_async_tx_descriptor *tx_desc;
dma_cookie_t dma_cookie;
--
2.47.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH] staging: gpib: Change return type of fluke_get_dma_residue
@ 2024-10-15 20:33 Kees Bakker
2024-10-19 7:59 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Kees Bakker @ 2024-10-15 20:33 UTC (permalink / raw)
To: Dave Penkler, Linux Staging
The function fluke_get_dma_residue returns an error as a negative value.
So the return type must not be unsigned.
Signed-off-by: Kees Bakker <kees@ijzerbout.nl>
---
drivers/staging/gpib/eastwood/fluke_gpib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/gpib/eastwood/fluke_gpib.c b/drivers/staging/gpib/eastwood/fluke_gpib.c
index f9f149db222d..77bbe2b587b1 100644
--- a/drivers/staging/gpib/eastwood/fluke_gpib.c
+++ b/drivers/staging/gpib/eastwood/fluke_gpib.c
@@ -536,7 +536,7 @@ static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length
return 0;
}
-static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
+static int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
{
struct dma_tx_state state;
int result;
@@ -549,7 +549,7 @@ static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t co
dmaengine_tx_status(chan, cookie, &state);
// hardware doesn't support resume, so dont call this
// method unless the dma transfer is done.
- return state.residue;
+ return (int)state.residue;
}
static int fluke_dma_read(gpib_board_t *board, uint8_t *buffer,
--
2.47.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] staging: gpib: Change return type of fluke_get_dma_residue
2024-10-15 20:33 Kees Bakker
@ 2024-10-19 7:59 ` Greg KH
2024-10-19 18:19 ` Kees Bakker
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2024-10-19 7:59 UTC (permalink / raw)
To: Kees Bakker; +Cc: Dave Penkler, Linux Staging
On Tue, Oct 15, 2024 at 10:33:30PM +0200, Kees Bakker wrote:
> The function fluke_get_dma_residue returns an error as a negative value.
> So the return type must not be unsigned.
>
> Signed-off-by: Kees Bakker <kees@ijzerbout.nl>
> ---
> drivers/staging/gpib/eastwood/fluke_gpib.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/gpib/eastwood/fluke_gpib.c b/drivers/staging/gpib/eastwood/fluke_gpib.c
> index f9f149db222d..77bbe2b587b1 100644
> --- a/drivers/staging/gpib/eastwood/fluke_gpib.c
> +++ b/drivers/staging/gpib/eastwood/fluke_gpib.c
> @@ -536,7 +536,7 @@ static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length
> return 0;
> }
>
> -static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
> +static int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
> {
> struct dma_tx_state state;
> int result;
> @@ -549,7 +549,7 @@ static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t co
> dmaengine_tx_status(chan, cookie, &state);
> // hardware doesn't support resume, so dont call this
> // method unless the dma transfer is done.
> - return state.residue;
> + return (int)state.residue;
Then why isn't residue an int? Shouldn't that be also changed?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] staging: gpib: Change return type of fluke_get_dma_residue
2024-10-19 7:59 ` Greg KH
@ 2024-10-19 18:19 ` Kees Bakker
0 siblings, 0 replies; 5+ messages in thread
From: Kees Bakker @ 2024-10-19 18:19 UTC (permalink / raw)
To: Greg KH; +Cc: Dave Penkler, Linux Staging
Op 19-10-2024 om 09:59 schreef Greg KH:
> On Tue, Oct 15, 2024 at 10:33:30PM +0200, Kees Bakker wrote:
>> The function fluke_get_dma_residue returns an error as a negative value.
>> So the return type must not be unsigned.
>>
>> Signed-off-by: Kees Bakker <kees@ijzerbout.nl>
>> ---
>> drivers/staging/gpib/eastwood/fluke_gpib.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/gpib/eastwood/fluke_gpib.c b/drivers/staging/gpib/eastwood/fluke_gpib.c
>> index f9f149db222d..77bbe2b587b1 100644
>> --- a/drivers/staging/gpib/eastwood/fluke_gpib.c
>> +++ b/drivers/staging/gpib/eastwood/fluke_gpib.c
>> @@ -536,7 +536,7 @@ static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length
>> return 0;
>> }
>>
>> -static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
>> +static int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
>> {
>> struct dma_tx_state state;
>> int result;
>> @@ -549,7 +549,7 @@ static unsigned int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t co
>> dmaengine_tx_status(chan, cookie, &state);
>> // hardware doesn't support resume, so dont call this
>> // method unless the dma transfer is done.
>> - return state.residue;
>> + return (int)state.residue;
> Then why isn't residue an int? Shouldn't that be also changed?
Good catch. I need to resend a patch.
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-11-04 5:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-15 20:33 [PATCH] staging: gpib: Change return type of fluke_get_dma_residue Kees Bakker
2024-11-03 23:45 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2024-10-15 20:33 Kees Bakker
2024-10-19 7:59 ` Greg KH
2024-10-19 18:19 ` Kees Bakker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox