diff mbox

[FFmpeg-devel] lavc/avpacket: Make pkt parameter of av_packet_get_side_data() const

Message ID CAB0OVGqFV-J44wtRgqmSx7OgFOFc07mzZ+E=mVi392LfQ2gA6g@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos Feb. 26, 2017, 11:04 a.m. UTC
2017-02-26 11:51 GMT+01:00 Nicolas George <george@nsup.org>:
> L'octidi 8 ventôse, an CCXXV, Carl Eugen Hoyos a écrit :
>> Hi!
>>
>> I believe adding const to the declaration of av_packet_get_side_data()
>> better reflects its intention, also fixes a warning.
>>
>> Please comment, Carl Eugen
>
>> From a17c4bab8cd21c15e91f5efd03d5900eda29090b Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <cehoyos@ag.or.at>
>> Date: Sun, 26 Feb 2017 11:39:07 +0100
>> Subject: [PATCH] lavc/avpacket: Make pkt parameter of
>>  av_packet_get_side_data() const.
>> MIME-Version: 1.0
>> Content-Type: text/plain; charset=UTF-8
>> Content-Transfer-Encoding: 8bit
>>
>> Reflects the actual code and silences a gcc warning:
>
>> libavcodec/utils.c:2102:36: warning: passing argument 1 of ???av_packet_get_side_data??? discards ???const??? qualifier from pointer target type [-Wdiscarded-qualifiers]
>
> You have an encoding problem, probably UTF-8 related, in your
> copy-paste. I suggest you re-run gcc with LC_CTYPE=C to get the error
> message in plain ASCII.

Thanks for noticing, not reproducible on the web interface:
http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=560f5188
Same issue for 3aef2fce

> Also, lines in commit messages are usually better wrapped around 64-70
> characters.

I would prefer not to wrap gcc output.

>> ---
>>  libavcodec/avcodec.h  |    6 +++++-
>>  libavcodec/avpacket.c |    6 +++++-
>>  libavcodec/version.h  |    3 +++
>>  3 files changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index 925a8c7..b065309 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -4563,7 +4563,11 @@ int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
>>   * @param size pointer for side information size to store (optional)
>>   * @return pointer to data if present or NULL otherwise
>>   */
>> -uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
>
>> +uint8_t* av_packet_get_side_data(
>> +#if FF_API_CONST_GET_SIDE_DATA
>> +const
>> +#endif
>> +                                 AVPacket *pkt, enum AVPacketSideDataType type,
>
> I do not think we need the FF_API dance, since it is not an ABI break.

I agree that there is no ABI break (but I suspect FF_API does not
imply an ABI break).

> I think is is not an API break either.

I may misremember but I thought it's an API break for c++ users.

Anyway, new patch attached.

Thank you, Carl Eugen

Comments

Carl Eugen Hoyos March 7, 2017, 8:59 a.m. UTC | #1
2017-02-26 12:04 GMT+01:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:
> 2017-02-26 11:51 GMT+01:00 Nicolas George <george@nsup.org>:

>>> -uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
>>
>>> +uint8_t* av_packet_get_side_data(
>>> +#if FF_API_CONST_GET_SIDE_DATA
>>> +const
>>> +#endif
>>> +                                 AVPacket *pkt, enum AVPacketSideDataType type,
>>
>> I do not think we need the FF_API dance, since it is not an ABI break.
>
> I agree that there is no ABI break (but I suspect FF_API does not
> imply an ABI break).
>
>> I think is is not an API break either.
>
> I may misremember but I thought it's an API break for c++ users.
>
> Anyway, new patch attached.

Ping.
Should this not be changed, should one of the patches be applied?

Thank you, Carl Eugen
Michael Niedermayer March 11, 2017, 2:24 p.m. UTC | #2
On Tue, Mar 07, 2017 at 09:59:42AM +0100, Carl Eugen Hoyos wrote:
> 2017-02-26 12:04 GMT+01:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:
> > 2017-02-26 11:51 GMT+01:00 Nicolas George <george@nsup.org>:
> 
> >>> -uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
> >>
> >>> +uint8_t* av_packet_get_side_data(
> >>> +#if FF_API_CONST_GET_SIDE_DATA
> >>> +const
> >>> +#endif
> >>> +                                 AVPacket *pkt, enum AVPacketSideDataType type,
> >>
> >> I do not think we need the FF_API dance, since it is not an ABI break.
> >
> > I agree that there is no ABI break (but I suspect FF_API does not
> > imply an ABI break).
> >
> >> I think is is not an API break either.
> >
> > I may misremember but I thought it's an API break for c++ users.
> >
> > Anyway, new patch attached.
> 
> Ping.
> Should this not be changed, should one of the patches be applied?

i agree one should be applied, iam not 100% sure if it can break a
user app and need the #if or not

[...]
Carl Eugen Hoyos March 13, 2017, 8:59 a.m. UTC | #3
2017-02-26 12:04 GMT+01:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:

> Anyway, new patch attached.

I will push this version if nobody objects.

Carl Eugen
Carl Eugen Hoyos March 16, 2017, 8:10 p.m. UTC | #4
2017-02-26 12:04 GMT+01:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:
> Anyway, new patch attached.

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

From 75381486fd28945d1aa0c3f4caa4f738d0bbe08e Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos@ag.or.at>
Date: Sun, 26 Feb 2017 11:58:49 +0100
Subject: [PATCH] lavc/avpacket: Make pkt parameter of
 av_packet_get_side_data() const.

Reflects the actual code and silences a gcc warning:
libavcodec/utils.c:2102:36: warning: passing argument 1 of 'av_packet_get_side_data' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
---
 libavcodec/avcodec.h  |    2 +-
 libavcodec/avpacket.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 925a8c7..7e9637e 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -4563,7 +4563,7 @@  int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
  * @param size pointer for side information size to store (optional)
  * @return pointer to data if present or NULL otherwise
  */
-uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
+uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type,
                                  int *size);
 
 int av_packet_merge_side_data(AVPacket *pkt);
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 8e028a2..eb570a2 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -336,7 +336,7 @@  uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
     return data;
 }
 
-uint8_t *av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
+uint8_t *av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type,
                                  int *size)
 {
     int i;
-- 
1.7.10.4