[FFmpeg-devel] [PATCH] Remove only use of compound literals in FFmpeg.

Nicolas George george at nsup.org
Mon Dec 30 11:36:05 CET 2013


Le decadi 10 nivôse, an CCXXII, Reimar Döffinger a écrit :
> Sorry, I missed it was a function, not a macro.

There are both a function or a macro. More precisely, there are two
functions and a macro working together:

- av_strerror() is the core API to convert an error code to a string; it
  returns an error code if it fails, but still produces an usable error
  text.

- av_make_error_string() is a trivial wrapper on av_strerror() that discards
  the return value and returns the string instead, so it can be used
  directly as a function argument.

- av_err2str() is a macro around av_make_error_string() that uses the
  compound literal feature to allocate a local buffer.

The av_ts2str() and av_ts2timestr() macros follow the same logic, except
there is only one function that takes a buffer and returns it.

> That leaves the question if you think this patch is reasonable.
> My personal opinion is that using this feature when it doesn't really
> help much if any in readability isn't a good idea anyway, but before
> I start a flame-war I don't mind dropping any of these patches.

Like Clément, I believe that the 2str macros help readability. And since
similar constructs are used in a few places and they do not cause a problem
for your use case, there is no reason to change them.

I do not object to the af_aresample.c change, it does not make the code less
readable.

Clément: in your grep, you forget a few cases:

git grep -E '\(u?int([0-9]+_t)?\[[0-9a-zA-Z_]*\]\)'

But still, the af_aresample.c case is the only one where the array elements
are not constant.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131230/5a636edf/attachment.asc>


More information about the ffmpeg-devel mailing list