diff mbox series

[master] yavta: Fix 32-bit compile

Message ID 20240913194211.12423-1-reatmon@ti.com (mailing list archive)
State New
Headers show
Series [master] yavta: Fix 32-bit compile | expand

Commit Message

Ryan Eatmon Sept. 13, 2024, 7:42 p.m. UTC
The format for printing various time elements are not working for 64bit
times on a 32bit compile.

../git/yavta.c:2195:51: error: format '%ld' expects argument of type 'long int', but argument 8 has type '__time64_t' {aka 'long long int'} [-Werror=format=]
 2195 |                 printf("%u (%u) [%c] %s %u %u B %ld.%06ld %ld.%06ld %.3f fps ts %s/%s\n", i, buf.index,
      |                                                 ~~^
      |                                                   |
      |                                                   long int
      |                                                 %lld
......
 2199 |                         buf.timestamp.tv_sec, buf.timestamp.tv_usec,
      |                         ~~~~~~~~~~~~~~~~~~~~
      |                                      |
      |                                      __time64_t {aka long long int}

Change the formats to be lld/llu to accommodate the change for 32bit
compiles.

Signed-off-by: Ryan Eatmon <reatmon@ti.com>
---
 yavta.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Laurent Pinchart Sept. 14, 2024, 12:32 a.m. UTC | #1
Hi Ryan,

Thank you for the patch.

On Fri, Sep 13, 2024 at 02:42:11PM -0500, Ryan Eatmon wrote:
> The format for printing various time elements are not working for 64bit
> times on a 32bit compile.
> 
> ../git/yavta.c:2195:51: error: format '%ld' expects argument of type 'long int', but argument 8 has type '__time64_t' {aka 'long long int'} [-Werror=format=]
>  2195 |                 printf("%u (%u) [%c] %s %u %u B %ld.%06ld %ld.%06ld %.3f fps ts %s/%s\n", i, buf.index,
>       |                                                 ~~^
>       |                                                   |
>       |                                                   long int
>       |                                                 %lld
> ......
>  2199 |                         buf.timestamp.tv_sec, buf.timestamp.tv_usec,
>       |                         ~~~~~~~~~~~~~~~~~~~~
>       |                                      |
>       |                                      __time64_t {aka long long int}
> 
> Change the formats to be lld/llu to accommodate the change for 32bit
> compiles.

Ricardo Ribalda has submitted a similar patch previously, see
https://lore.kernel.org/linux-media/20230920125939.1478-1-ricardo@ribalda.com/.
It had fallen through the cracks (my bad), and I have now applied it.
Could you check if it solves your problem ?

> Signed-off-by: Ryan Eatmon <reatmon@ti.com>
> ---
>  yavta.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/yavta.c b/yavta.c
> index 3bf82b3..0655311 100644
> --- a/yavta.c
> +++ b/yavta.c
> @@ -2192,12 +2192,12 @@ static int video_do_capture(struct device *dev, unsigned int nframes,
>  
>  		clock_gettime(CLOCK_MONOTONIC, &ts);
>  		get_ts_flags(buf.flags, &ts_type, &ts_source);
> -		printf("%u (%u) [%c] %s %u %u B %ld.%06ld %ld.%06ld %.3f fps ts %s/%s\n", i, buf.index,
> +		printf("%u (%u) [%c] %s %u %u B %lld.%06lld %lld.%06ld %.3f fps ts %s/%s\n", i, buf.index,
>  			(buf.flags & V4L2_BUF_FLAG_ERROR) ? 'E' : '-',
>  			v4l2_field_name(buf.field),
>  			buf.sequence, video_buffer_bytes_used(dev, &buf),
> -			buf.timestamp.tv_sec, buf.timestamp.tv_usec,
> -			ts.tv_sec, ts.tv_nsec/1000, fps,
> +			(long long int) buf.timestamp.tv_sec, (long long int) buf.timestamp.tv_usec,
> +			(long long int) ts.tv_sec, ts.tv_nsec/1000, fps,
>  			ts_type, ts_source);
>  
>  		last = buf.timestamp;
> @@ -2254,8 +2254,8 @@ static int video_do_capture(struct device *dev, unsigned int nframes,
>  	bps = size/(ts.tv_nsec/1000.0+1000000.0*ts.tv_sec)*1000000.0;
>  	fps = i/(ts.tv_nsec/1000.0+1000000.0*ts.tv_sec)*1000000.0;
>  
> -	printf("Captured %u frames in %lu.%06lu seconds (%f fps, %f B/s).\n",
> -		i, ts.tv_sec, ts.tv_nsec/1000, fps, bps);
> +	printf("Captured %u frames in %llu.%06lu seconds (%f fps, %f B/s).\n",
> +		i, (long long unsigned int) ts.tv_sec, ts.tv_nsec/1000, fps, bps);
>  
>  done:
>  	video_free_buffers(dev);
Ryan Eatmon Sept. 16, 2024, 2:34 p.m. UTC | #2
Yes.  That patch is perfect and better worded than mine.  Glad this was 
resolved.  Thank you.



On 9/13/2024 7:32 PM, Laurent Pinchart wrote:
> Hi Ryan,
> 
> Thank you for the patch.
> 
> On Fri, Sep 13, 2024 at 02:42:11PM -0500, Ryan Eatmon wrote:
>> The format for printing various time elements are not working for 64bit
>> times on a 32bit compile.
>>
>> ../git/yavta.c:2195:51: error: format '%ld' expects argument of type 'long int', but argument 8 has type '__time64_t' {aka 'long long int'} [-Werror=format=]
>>   2195 |                 printf("%u (%u) [%c] %s %u %u B %ld.%06ld %ld.%06ld %.3f fps ts %s/%s\n", i, buf.index,
>>        |                                                 ~~^
>>        |                                                   |
>>        |                                                   long int
>>        |                                                 %lld
>> ......
>>   2199 |                         buf.timestamp.tv_sec, buf.timestamp.tv_usec,
>>        |                         ~~~~~~~~~~~~~~~~~~~~
>>        |                                      |
>>        |                                      __time64_t {aka long long int}
>>
>> Change the formats to be lld/llu to accommodate the change for 32bit
>> compiles.
> 
> Ricardo Ribalda has submitted a similar patch previously, see
> https://lore.kernel.org/linux-media/20230920125939.1478-1-ricardo@ribalda.com/.
> It had fallen through the cracks (my bad), and I have now applied it.
> Could you check if it solves your problem ?
> 
>> Signed-off-by: Ryan Eatmon <reatmon@ti.com>
>> ---
>>   yavta.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/yavta.c b/yavta.c
>> index 3bf82b3..0655311 100644
>> --- a/yavta.c
>> +++ b/yavta.c
>> @@ -2192,12 +2192,12 @@ static int video_do_capture(struct device *dev, unsigned int nframes,
>>   
>>   		clock_gettime(CLOCK_MONOTONIC, &ts);
>>   		get_ts_flags(buf.flags, &ts_type, &ts_source);
>> -		printf("%u (%u) [%c] %s %u %u B %ld.%06ld %ld.%06ld %.3f fps ts %s/%s\n", i, buf.index,
>> +		printf("%u (%u) [%c] %s %u %u B %lld.%06lld %lld.%06ld %.3f fps ts %s/%s\n", i, buf.index,
>>   			(buf.flags & V4L2_BUF_FLAG_ERROR) ? 'E' : '-',
>>   			v4l2_field_name(buf.field),
>>   			buf.sequence, video_buffer_bytes_used(dev, &buf),
>> -			buf.timestamp.tv_sec, buf.timestamp.tv_usec,
>> -			ts.tv_sec, ts.tv_nsec/1000, fps,
>> +			(long long int) buf.timestamp.tv_sec, (long long int) buf.timestamp.tv_usec,
>> +			(long long int) ts.tv_sec, ts.tv_nsec/1000, fps,
>>   			ts_type, ts_source);
>>   
>>   		last = buf.timestamp;
>> @@ -2254,8 +2254,8 @@ static int video_do_capture(struct device *dev, unsigned int nframes,
>>   	bps = size/(ts.tv_nsec/1000.0+1000000.0*ts.tv_sec)*1000000.0;
>>   	fps = i/(ts.tv_nsec/1000.0+1000000.0*ts.tv_sec)*1000000.0;
>>   
>> -	printf("Captured %u frames in %lu.%06lu seconds (%f fps, %f B/s).\n",
>> -		i, ts.tv_sec, ts.tv_nsec/1000, fps, bps);
>> +	printf("Captured %u frames in %llu.%06lu seconds (%f fps, %f B/s).\n",
>> +		i, (long long unsigned int) ts.tv_sec, ts.tv_nsec/1000, fps, bps);
>>   
>>   done:
>>   	video_free_buffers(dev);
>
diff mbox series

Patch

diff --git a/yavta.c b/yavta.c
index 3bf82b3..0655311 100644
--- a/yavta.c
+++ b/yavta.c
@@ -2192,12 +2192,12 @@  static int video_do_capture(struct device *dev, unsigned int nframes,
 
 		clock_gettime(CLOCK_MONOTONIC, &ts);
 		get_ts_flags(buf.flags, &ts_type, &ts_source);
-		printf("%u (%u) [%c] %s %u %u B %ld.%06ld %ld.%06ld %.3f fps ts %s/%s\n", i, buf.index,
+		printf("%u (%u) [%c] %s %u %u B %lld.%06lld %lld.%06ld %.3f fps ts %s/%s\n", i, buf.index,
 			(buf.flags & V4L2_BUF_FLAG_ERROR) ? 'E' : '-',
 			v4l2_field_name(buf.field),
 			buf.sequence, video_buffer_bytes_used(dev, &buf),
-			buf.timestamp.tv_sec, buf.timestamp.tv_usec,
-			ts.tv_sec, ts.tv_nsec/1000, fps,
+			(long long int) buf.timestamp.tv_sec, (long long int) buf.timestamp.tv_usec,
+			(long long int) ts.tv_sec, ts.tv_nsec/1000, fps,
 			ts_type, ts_source);
 
 		last = buf.timestamp;
@@ -2254,8 +2254,8 @@  static int video_do_capture(struct device *dev, unsigned int nframes,
 	bps = size/(ts.tv_nsec/1000.0+1000000.0*ts.tv_sec)*1000000.0;
 	fps = i/(ts.tv_nsec/1000.0+1000000.0*ts.tv_sec)*1000000.0;
 
-	printf("Captured %u frames in %lu.%06lu seconds (%f fps, %f B/s).\n",
-		i, ts.tv_sec, ts.tv_nsec/1000, fps, bps);
+	printf("Captured %u frames in %llu.%06lu seconds (%f fps, %f B/s).\n",
+		i, (long long unsigned int) ts.tv_sec, ts.tv_nsec/1000, fps, bps);
 
 done:
 	video_free_buffers(dev);