[libav-devel] [PATCH] matroska: K&R cosmetic refactoring

Diego Biurrun diego at biurrun.de
Fri Mar 7 01:39:36 CET 2014


On Sat, Mar 01, 2014 at 05:28:15PM +0100, Keiji Costantini wrote:
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -70,8 +70,8 @@ typedef const struct EbmlSyntax {
>      int list_elem_size;
>      int data_offset;
>      union {
> -        uint64_t    u;
> -        double      f;
> +        uint64_t u;
> +        double f;
>          const char *s;
>          const struct EbmlSyntax *n;

The alignment does not hurt here, so I'd keep it as-is, same below.

> @@ -615,7 +615,7 @@ static int ebml_level_end(MatroskaDemuxContext *matroska)
>  static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb,
>                           int max_size, uint64_t *number)
>  {
> -    int read = 1, n = 1;
> +    int read       = 1, n = 1;

excessive alignment

> @@ -626,7 +626,7 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb,
>          if (!pb->eof_reached) {
>              int64_t pos = avio_tell(pb);
>              av_log(matroska->ctx, AV_LOG_ERROR,
> -                   "Read error at pos. %"PRIu64" (0x%"PRIx64")\n",
> +                   "Read error at pos. %" PRIu64 " (0x%" PRIx64 ")\n",

stray change

> @@ -716,7 +716,7 @@ static int ebml_read_ascii(AVIOContext *pb, int size, char **str)
>       * byte more, read the string and NULL-terminate it ourselves. */
>      if (!(res = av_malloc(size + 1)))
>          return AVERROR(ENOMEM);
> -    if (avio_read(pb, (uint8_t *) res, size) != size) {
> +    if (avio_read(pb, (uint8_t *)res, size) != size) {

This was as Dennis and Brian wanted before.

> @@ -907,26 +907,32 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
>              return res;
>          if (max_lengths[syntax->type] && length > max_lengths[syntax->type]) {
>              av_log(matroska->ctx, AV_LOG_ERROR,
> -                   "Invalid length 0x%"PRIx64" > 0x%"PRIx64" for syntax element %i\n",
> +                   "Invalid length 0x%" PRIx64 " > 0x%" PRIx64
> +                   " for syntax element %i\n",

more stray changes

>      switch (syntax->type) {
> -    case EBML_UINT:  res = ebml_read_uint  (pb, length, data);  break;
> -    case EBML_FLOAT: res = ebml_read_float (pb, length, data);  break;
> +    case EBML_UINT:  res = ebml_read_uint(pb, length, data);
> +        break;
> +    case EBML_FLOAT: res = ebml_read_float(pb, length, data);
> +        break;

missing linebreaks, more below

> @@ -958,14 +967,13 @@ static void ebml_free(EbmlSyntax *syntax, void *data)
>  static int matroska_probe(AVProbeData *p)
>  {
>      uint64_t total = 0;
> -    int len_mask = 0x80, size = 1, n = 1, i;
> +    int len_mask   = 0x80, size = 1, n = 1, i;

excessive alignment

> @@ -2396,17 +2443,19 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
> -            index_sub = av_index_search_timestamp(tracks[i].stream, st->index_entries[index].timestamp, AVSEEK_FLAG_BACKWARD);
> +            index_sub = av_index_search_timestamp(
> +                tracks[i].stream, st->index_entries[index].timestamp,
> +                AVSEEK_FLAG_BACKWARD);

Ugh, no, please don't break lines like this.


I'll fix all the issues and push tomorrow.

Diego


More information about the libav-devel mailing list