[2/2] utils: ipu3: Fix return value check on file output
diff mbox series

Message ID 20240226094857.2207313-3-kieran.bingham@ideasonboard.com
State Accepted
Commit bdd85fa01c6078950b93d4c9491694d077c3b60b
Headers show
Series
  • Two small fixes
Related show

Commit Message

Kieran Bingham Feb. 26, 2024, 9:48 a.m. UTC
The data parsed by ipu3-unpack is written out using the write() c
library call, but the error code is incorrectly checked which misses the
single erroroneous return value returned by the function.

Fix it to explicitly check against the error code.

Reported-by: Johan Mattsson <39247600+mjunix@users.noreply.github.com>
Fixes: 23ac77dc4a09 ("utils: ipu3: Add IPU3 raw capture unpack utility")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 utils/ipu3/ipu3-unpack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart Feb. 26, 2024, 10:07 a.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Mon, Feb 26, 2024 at 09:48:57AM +0000, Kieran Bingham wrote:
> The data parsed by ipu3-unpack is written out using the write() c

s/c$/C/

> library call, but the error code is incorrectly checked which misses the
> single erroroneous return value returned by the function.
> 
> Fix it to explicitly check against the error code.
> 
> Reported-by: Johan Mattsson <39247600+mjunix@users.noreply.github.com>

With this dropped,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> Fixes: 23ac77dc4a09 ("utils: ipu3: Add IPU3 raw capture unpack utility")
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  utils/ipu3/ipu3-unpack.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/ipu3/ipu3-unpack.c b/utils/ipu3/ipu3-unpack.c
> index 9d2c1200d932..c96fafed2435 100644
> --- a/utils/ipu3/ipu3-unpack.c
> +++ b/utils/ipu3/ipu3-unpack.c
> @@ -78,7 +78,7 @@ int main(int argc, char *argv[])
>  		}
>  
>  		ret = write(out_fd, out_data, 50);
> -		if (ret < -1) {
> +		if (ret == -1) {
>  			fprintf(stderr, "Failed to write output data: %s\n",
>  				strerror(errno));
>  			goto done;
Umang Jain Feb. 27, 2024, 9:31 a.m. UTC | #2
Hi Kieran,

On 26/02/24 3:37 pm, Laurent Pinchart wrote:
> Hi Kieran,
>
> Thank you for the patch.
>
> On Mon, Feb 26, 2024 at 09:48:57AM +0000, Kieran Bingham wrote:
>> The data parsed by ipu3-unpack is written out using the write() c
> s/c$/C/
>
>> library call, but the error code is incorrectly checked which misses the
>> single erroroneous return value returned by the function.
>>
>> Fix it to explicitly check against the error code.
>>
>> Reported-by: Johan Mattsson <39247600+mjunix@users.noreply.github.com>
> With this dropped,
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

>
>> Fixes: 23ac77dc4a09 ("utils: ipu3: Add IPU3 raw capture unpack utility")
>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>> ---
>>   utils/ipu3/ipu3-unpack.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/utils/ipu3/ipu3-unpack.c b/utils/ipu3/ipu3-unpack.c
>> index 9d2c1200d932..c96fafed2435 100644
>> --- a/utils/ipu3/ipu3-unpack.c
>> +++ b/utils/ipu3/ipu3-unpack.c
>> @@ -78,7 +78,7 @@ int main(int argc, char *argv[])
>>   		}
>>   
>>   		ret = write(out_fd, out_data, 50);
>> -		if (ret < -1) {
>> +		if (ret == -1) {
>>   			fprintf(stderr, "Failed to write output data: %s\n",
>>   				strerror(errno));
>>   			goto done;

Patch
diff mbox series

diff --git a/utils/ipu3/ipu3-unpack.c b/utils/ipu3/ipu3-unpack.c
index 9d2c1200d932..c96fafed2435 100644
--- a/utils/ipu3/ipu3-unpack.c
+++ b/utils/ipu3/ipu3-unpack.c
@@ -78,7 +78,7 @@  int main(int argc, char *argv[])
 		}
 
 		ret = write(out_fd, out_data, 50);
-		if (ret < -1) {
+		if (ret == -1) {
 			fprintf(stderr, "Failed to write output data: %s\n",
 				strerror(errno));
 			goto done;