diff mbox

[FFmpeg-devel] libavcodec/opusenc: use correct format specifiers

Message ID 20170326181322.35584-1-k@ylo.ph
State Accepted
Headers show

Commit Message

Kyle Swanson March 26, 2017, 6:13 p.m. UTC
Squelches the following compiler warnings:

libavcodec/opusenc.c:1051:16: warning: format specifies type 'long' but
the argument has type 'long long' [-Wformat]
               avctx->bit_rate/1000, clipped_rate/1000);
               ^~~~~~~~~~~~~~~~~~~~
libavcodec/opusenc.c:1051:38: warning: format specifies type 'long' but
the argument has type 'long long' [-Wformat]
               avctx->bit_rate/1000, clipped_rate/1000);
                                     ^~~~~~~~~~~~~~~~~

Signed-off-by: Kyle Swanson <k@ylo.ph>
---
 libavcodec/opusenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nicolas George March 26, 2017, 6:20 p.m. UTC | #1
Thanks for the patch.

Le sextidi 6 germinal, an CCXXV, Kyle Swanson a écrit :
> Squelches the following compiler warnings:
> 
> libavcodec/opusenc.c:1051:16: warning: format specifies type 'long' but
> the argument has type 'long long' [-Wformat]
>                avctx->bit_rate/1000, clipped_rate/1000);
>                ^~~~~~~~~~~~~~~~~~~~
> libavcodec/opusenc.c:1051:38: warning: format specifies type 'long' but
> the argument has type 'long long' [-Wformat]
>                avctx->bit_rate/1000, clipped_rate/1000);
>                                      ^~~~~~~~~~~~~~~~~
> 
> Signed-off-by: Kyle Swanson <k@ylo.ph>
> ---
>  libavcodec/opusenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
> index 56368db..292d060 100644
> --- a/libavcodec/opusenc.c
> +++ b/libavcodec/opusenc.c
> @@ -1047,7 +1047,7 @@ static av_cold int opus_encode_init(AVCodecContext *avctx)
>          avctx->bit_rate = coupled*(96000) + (s->channels - coupled*2)*(48000);
>      } else if (avctx->bit_rate < 6000 || avctx->bit_rate > 255000 * s->channels) {
>          int64_t clipped_rate = av_clip(avctx->bit_rate, 6000, 255000 * s->channels);

> -        av_log(avctx, AV_LOG_ERROR, "Unsupported bitrate %li kbps, clipping to %li kbps\n",
> +        av_log(avctx, AV_LOG_ERROR, "Unsupported bitrate %lli kbps, clipping to %lli kbps\n",

The old specifier was wrong, but %ll is wrong too: avctx->bit_rate is
int64_t, not long nor long long.

>                 avctx->bit_rate/1000, clipped_rate/1000);
>          avctx->bit_rate = clipped_rate;
>      }

Regards,
Kyle Swanson March 26, 2017, 6:53 p.m. UTC | #2
Hi,

On Sun, Mar 26, 2017 at 1:20 PM, Nicolas George <george@nsup.org> wrote:
>
> Thanks for the patch.
>
> Le sextidi 6 germinal, an CCXXV, Kyle Swanson a écrit :
> > Squelches the following compiler warnings:
> >
> > libavcodec/opusenc.c:1051:16: warning: format specifies type 'long' but
> > the argument has type 'long long' [-Wformat]
> >                avctx->bit_rate/1000, clipped_rate/1000);
> >                ^~~~~~~~~~~~~~~~~~~~
> > libavcodec/opusenc.c:1051:38: warning: format specifies type 'long' but
> > the argument has type 'long long' [-Wformat]
> >                avctx->bit_rate/1000, clipped_rate/1000);
> >                                      ^~~~~~~~~~~~~~~~~
> >
> > Signed-off-by: Kyle Swanson <k@ylo.ph>
> > ---
> >  libavcodec/opusenc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
> > index 56368db..292d060 100644
> > --- a/libavcodec/opusenc.c
> > +++ b/libavcodec/opusenc.c
> > @@ -1047,7 +1047,7 @@ static av_cold int opus_encode_init(AVCodecContext *avctx)
> >          avctx->bit_rate = coupled*(96000) + (s->channels - coupled*2)*(48000);
> >      } else if (avctx->bit_rate < 6000 || avctx->bit_rate > 255000 * s->channels) {
> >          int64_t clipped_rate = av_clip(avctx->bit_rate, 6000, 255000 * s->channels);
>
> > -        av_log(avctx, AV_LOG_ERROR, "Unsupported bitrate %li kbps, clipping to %li kbps\n",
> > +        av_log(avctx, AV_LOG_ERROR, "Unsupported bitrate %lli kbps, clipping to %lli kbps\n",
>
> The old specifier was wrong, but %ll is wrong too: avctx->bit_rate is
> int64_t, not long nor long long.


Thanks, new patch is attached. %" PRIu64 " should be correct.

>
>
> >                 avctx->bit_rate/1000, clipped_rate/1000);
> >          avctx->bit_rate = clipped_rate;
> >      }
>
> Regards,
>
> --
>   Nicolas George
Kyle Swanson March 26, 2017, 7:14 p.m. UTC | #3
On Sun, Mar 26, 2017 at 1:53 PM, Kyle Swanson <k@ylo.ph> wrote:
> Hi,
>
> On Sun, Mar 26, 2017 at 1:20 PM, Nicolas George <george@nsup.org> wrote:
>>
>> Thanks for the patch.
>>
>> Le sextidi 6 germinal, an CCXXV, Kyle Swanson a écrit :
>> > Squelches the following compiler warnings:
>> >
>> > libavcodec/opusenc.c:1051:16: warning: format specifies type 'long' but
>> > the argument has type 'long long' [-Wformat]
>> >                avctx->bit_rate/1000, clipped_rate/1000);
>> >                ^~~~~~~~~~~~~~~~~~~~
>> > libavcodec/opusenc.c:1051:38: warning: format specifies type 'long' but
>> > the argument has type 'long long' [-Wformat]
>> >                avctx->bit_rate/1000, clipped_rate/1000);
>> >                                      ^~~~~~~~~~~~~~~~~
>> >
>> > Signed-off-by: Kyle Swanson <k@ylo.ph>
>> > ---
>> >  libavcodec/opusenc.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
>> > index 56368db..292d060 100644
>> > --- a/libavcodec/opusenc.c
>> > +++ b/libavcodec/opusenc.c
>> > @@ -1047,7 +1047,7 @@ static av_cold int opus_encode_init(AVCodecContext *avctx)
>> >          avctx->bit_rate = coupled*(96000) + (s->channels - coupled*2)*(48000);
>> >      } else if (avctx->bit_rate < 6000 || avctx->bit_rate > 255000 * s->channels) {
>> >          int64_t clipped_rate = av_clip(avctx->bit_rate, 6000, 255000 * s->channels);
>>
>> > -        av_log(avctx, AV_LOG_ERROR, "Unsupported bitrate %li kbps, clipping to %li kbps\n",
>> > +        av_log(avctx, AV_LOG_ERROR, "Unsupported bitrate %lli kbps, clipping to %lli kbps\n",
>>
>> The old specifier was wrong, but %ll is wrong too: avctx->bit_rate is
>> int64_t, not long nor long long.
>
>
> Thanks, new patch is attached. %" PRIu64 " should be correct.

Ignore previous patch, we should actually be using %" PRId64 ". Can't
believe that took three tries ⊙﹏⊙.

>
>>
>>
>> >                 avctx->bit_rate/1000, clipped_rate/1000);
>> >          avctx->bit_rate = clipped_rate;
>> >      }
>>
>> Regards,
>>
>> --
>>   Nicolas George
Carl Eugen Hoyos March 27, 2017, 7:38 a.m. UTC | #4
2017-03-26 21:14 GMT+02:00 Kyle Swanson <k@ylo.ph>:

> Ignore previous patch, we should actually be using %" PRId64 ". Can't
> believe that took three tries ⊙﹏⊙.

I removed the spaces that are not used anywhere else in the codebase
and pushed.

Thank you, Carl Eugen
diff mbox

Patch

diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
index 56368db..292d060 100644
--- a/libavcodec/opusenc.c
+++ b/libavcodec/opusenc.c
@@ -1047,7 +1047,7 @@  static av_cold int opus_encode_init(AVCodecContext *avctx)
         avctx->bit_rate = coupled*(96000) + (s->channels - coupled*2)*(48000);
     } else if (avctx->bit_rate < 6000 || avctx->bit_rate > 255000 * s->channels) {
         int64_t clipped_rate = av_clip(avctx->bit_rate, 6000, 255000 * s->channels);
-        av_log(avctx, AV_LOG_ERROR, "Unsupported bitrate %li kbps, clipping to %li kbps\n",
+        av_log(avctx, AV_LOG_ERROR, "Unsupported bitrate %lli kbps, clipping to %lli kbps\n",
                avctx->bit_rate/1000, clipped_rate/1000);
         avctx->bit_rate = clipped_rate;
     }