[FFmpeg-devel] [PATCH] lavu/hash.c: Add missing "static const".

Clément Bœsch u at pkh.me
Sat Aug 30 21:50:53 CEST 2014


On Sat, Aug 30, 2014 at 04:36:57PM +0200, Reimar Döffinger wrote:
> On Fri, Aug 29, 2014 at 09:29:46PM +0200, Clément Bœsch wrote:
> > On Fri, Aug 29, 2014 at 06:34:52PM +0200, Reimar Döffinger wrote:
> > > Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
> > > ---
> > >  libavutil/hash.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/libavutil/hash.c b/libavutil/hash.c
> > > index 773f29e..979fdd9 100644
> > > --- a/libavutil/hash.c
> > > +++ b/libavutil/hash.c
> > > @@ -63,7 +63,7 @@ typedef struct AVHashContext {
> > >  struct {
> > >      const char *name;
> > >      int size;
> > > -} hashdesc[] = {
> > > +} static const hashdesc[] = {
> > >      [MD5]     = {"MD5",     16},
> > >      [MURMUR3] = {"murmur3", 16},
> > >      [RIPEMD128] = {"RIPEMD128", 16},
> > 
> > shouldn't that be static const struct { } hashdesc[] = { ... }
> > 
> > as in static const <type> foo[] = { ... };
> 
> Reason I prefer this one is that if the struct becomes
> large it because very non-obvious that the array actually is
> "static const".
> It also is much harder to check/filter with grep.
> So for practical reasons I think it is better to place it here,
> or alternatively to name the struct and split them...
> But mostly I care about having it in .rodata, everything else
> I'm willing to adapt to what others prefer.

I'm mostly concerned about consistency. Except the one you added in
drawtext, this form is never used:

[~/src/ffmpeg]☭ git grep 'static const struct {'
libavcodec/aacps.c:    static const struct {
libavcodec/aacsbr.c:    static const struct {
libavcodec/dirac.c:static const struct {
libavcodec/dirac.c:static const struct {
libavcodec/indeo4.c:static const struct {
libavcodec/jacosubdec.c:static const struct {
libavcodec/libschroedinger.h:static const struct {
libavcodec/mace.c:static const struct {
libavcodec/svq3.c:static const struct {
libavcodec/twinvq_data.h:static const struct {
libavcodec/vorbis_enc_data.h:static const struct {
libavcodec/vorbis_enc_data.h:static const struct {
libavcodec/vp9.c:    static const struct {
libavcodec/webvttdec.c:static const struct {
libavdevice/v4l.c:static const struct {
libavfilter/avf_showspectrum.c:static const struct {
libavfilter/vf_curves.c:static const struct {
libavfilter/vf_mp.c:static const struct {
libavfilter/vf_signalstats.c:static const struct {
libavformat/gxfenc.c:static const struct {
libavformat/mov_chan.c:static const struct {
libavformat/movenc.c:static const struct {
libavformat/mxf.c:static const struct {
libavformat/mxfenc.c:static const struct {
libavformat/rtp.c:static const struct {
libavformat/utils.c:    static const struct {
libavutil/channel_layout.c:static const struct {
libavutil/cpu.c:static const struct {
libavutil/eval.c:static const struct {
[~/src/ffmpeg]☭ git grep '} static const'
libavfilter/vf_drawtext.c:} static const ft_errors[] =
[~/src/ffmpeg]☭  

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140830/a70cd088/attachment.asc>


More information about the ffmpeg-devel mailing list