diff mbox

[FFmpeg-devel] avfilter/graphmonitor: use %z when printing size_t

Message ID 00457db95f71d053ebabe2b0c25384eb0ec621c7.1542626393.git.pross@xvid.org
State New
Headers show

Commit Message

Peter Ross Nov. 19, 2018, 11:26 a.m. UTC
---
32-bit target compiler warning.

 libavfilter/f_graphmonitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paul B Mahol Nov. 19, 2018, 11:34 a.m. UTC | #1
On 11/19/18, Peter Ross <pross@xvid.org> wrote:
> ---
> 32-bit target compiler warning.
>
>  libavfilter/f_graphmonitor.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Not acceptable. Where this happens?
Hendrik Leppkes Nov. 19, 2018, 12:34 p.m. UTC | #2
On Mon, Nov 19, 2018 at 12:27 PM Peter Ross <pross@xvid.org> wrote:
>
> ---
> 32-bit target compiler warning.
>
>  libavfilter/f_graphmonitor.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c
> index 7052c84d9b..3cb8f73dd3 100644
> --- a/libavfilter/f_graphmonitor.c
> +++ b/libavfilter/f_graphmonitor.c
> @@ -211,7 +211,7 @@ static void draw_items(AVFilterContext *ctx, AVFrame *out,
>          snprintf(buffer, sizeof(buffer)-1, " | queue: ");
>          drawtext(out, xpos, ypos, buffer, s->white);
>          xpos += strlen(buffer) * 8;
> -        snprintf(buffer, sizeof(buffer)-1, "%"PRId64, frames);
> +        snprintf(buffer, sizeof(buffer)-1, "%zd", frames);

"%" SIZE_SPECIFIER to be portable.

>          drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white);
>          xpos += strlen(buffer) * 8;
>      }
> --
> 2.17.1
>
> -- Peter
> (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Carl Eugen Hoyos Nov. 19, 2018, 2:23 p.m. UTC | #3
2018-11-19 12:34 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> On 11/19/18, Peter Ross <pross@xvid.org> wrote:
>> ---
>> 32-bit target compiler warning.
>>
>>  libavfilter/f_graphmonitor.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Not acceptable. Where this happens?

This happened when you (and others) agreed to a patch adding a
function that returns size_t. ff_inlink_queued_frames() is not public
so the alternative to this patch is to change the return type or make
frames 64bit which seems less straight-forward.
(Or it happened when FFFrameQueue->queued was defined size_t.)

Carl Eugen
James Almer Nov. 19, 2018, 2:37 p.m. UTC | #4
On 11/19/2018 9:34 AM, Hendrik Leppkes wrote:
> On Mon, Nov 19, 2018 at 12:27 PM Peter Ross <pross@xvid.org> wrote:
>>
>> ---
>> 32-bit target compiler warning.
>>
>>  libavfilter/f_graphmonitor.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c
>> index 7052c84d9b..3cb8f73dd3 100644
>> --- a/libavfilter/f_graphmonitor.c
>> +++ b/libavfilter/f_graphmonitor.c
>> @@ -211,7 +211,7 @@ static void draw_items(AVFilterContext *ctx, AVFrame *out,
>>          snprintf(buffer, sizeof(buffer)-1, " | queue: ");
>>          drawtext(out, xpos, ypos, buffer, s->white);
>>          xpos += strlen(buffer) * 8;
>> -        snprintf(buffer, sizeof(buffer)-1, "%"PRId64, frames);
>> +        snprintf(buffer, sizeof(buffer)-1, "%zd", frames);
> 
> "%" SIZE_SPECIFIER to be portable.

Do recent msvc versions still need this? We don't really support 2012
and older anymore, so maybe %zu (and not %zd as size_t is unsigned) is
enough.

> 
>>          drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white);
>>          xpos += strlen(buffer) * 8;
>>      }
>> --
>> 2.17.1
>>
>> -- Peter
>> (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Nicolas George Nov. 19, 2018, 2:43 p.m. UTC | #5
Carl Eugen Hoyos (2018-11-19):
> This happened when you (and others) agreed to a patch adding a
> function that returns size_t. ff_inlink_queued_frames() is not public
> so the alternative to this patch is to change the return type or make
> frames 64bit which seems less straight-forward.
> (Or it happened when FFFrameQueue->queued was defined size_t.)

size_t is the correct type for a large number of objects that coexist in
memory.

Regards,
Hendrik Leppkes Nov. 19, 2018, 3 p.m. UTC | #6
On Mon, Nov 19, 2018 at 3:38 PM James Almer <jamrial@gmail.com> wrote:
>
> On 11/19/2018 9:34 AM, Hendrik Leppkes wrote:
> > On Mon, Nov 19, 2018 at 12:27 PM Peter Ross <pross@xvid.org> wrote:
> >>
> >> ---
> >> 32-bit target compiler warning.
> >>
> >>  libavfilter/f_graphmonitor.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c
> >> index 7052c84d9b..3cb8f73dd3 100644
> >> --- a/libavfilter/f_graphmonitor.c
> >> +++ b/libavfilter/f_graphmonitor.c
> >> @@ -211,7 +211,7 @@ static void draw_items(AVFilterContext *ctx, AVFrame *out,
> >>          snprintf(buffer, sizeof(buffer)-1, " | queue: ");
> >>          drawtext(out, xpos, ypos, buffer, s->white);
> >>          xpos += strlen(buffer) * 8;
> >> -        snprintf(buffer, sizeof(buffer)-1, "%"PRId64, frames);
> >> +        snprintf(buffer, sizeof(buffer)-1, "%zd", frames);
> >
> > "%" SIZE_SPECIFIER to be portable.
>
> Do recent msvc versions still need this? We don't really support 2012
> and older anymore, so maybe %zu (and not %zd as size_t is unsigned) is
> enough.
>

As far as I can tell, 2015 still needs it. 2017 supports z.

- Hendrik
diff mbox

Patch

diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c
index 7052c84d9b..3cb8f73dd3 100644
--- a/libavfilter/f_graphmonitor.c
+++ b/libavfilter/f_graphmonitor.c
@@ -211,7 +211,7 @@  static void draw_items(AVFilterContext *ctx, AVFrame *out,
         snprintf(buffer, sizeof(buffer)-1, " | queue: ");
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
-        snprintf(buffer, sizeof(buffer)-1, "%"PRId64, frames);
+        snprintf(buffer, sizeof(buffer)-1, "%zd", frames);
         drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white);
         xpos += strlen(buffer) * 8;
     }