[PATCH 2/3] v4l2: printings for all buf types

Dmitry V. Levin ldv at altlinux.org
Tue Apr 4 00:43:51 UTC 2017


On Wed, Mar 29, 2017 at 11:55:43PM +0300, Edgar Kaziahmedov wrote:
> * v4l2.c: add meaningful and informative printings for all
> v4l2 buf types in the 'print_v4l2_format_fmt' routine,
> implementation print_v4l2_clip routine to print the clips field
> in case of the overlay type buf
> * xlat/v4l2_vbi_flags.in: new flags for and V4L2_BUF_TYPE_VBI*
> * xlat/v4l2_sliced_flags.in: new flags for V4L2_BUF_TYPE_SLICED*

I understand gnu style changelog is not easy for beginner.
As you are not the first one who patches v4l2.c and corresponding xlat
files, just have a look at earlier commit messages.

[...]
> -
> -	/* TODO: Complete this switch statement */
> -#if 0
> -	case V4L2_BUF_TYPE_VIDEO_OVERLAY:
> -#if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
> +	/* OUTPUT_OVERLAY since Linux 2.6.22 */

strace still supports older kernels, so please do not remove this
HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY check.  Not yet.

[...]
> +	/* both since Linux 2.5.46 */
>  	case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
> -	case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
> +	case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: {
> +		unsigned int i, j;
> +
>  		tprints(prefix);
> -		tprints("fmt.sliced={???}");
> +		tprints("fmt.sliced={service_set=");
> +		printxval(v4l2_sliced_flags, f->fmt.sliced.service_set,
> +			"V4L2_SLICED_???");
> +		tprintf(", io_size=%u, service_lines=[",
> +			f->fmt.sliced.io_size);
> +		for (i = 0; i < ARRAY_SIZE(f->fmt.sliced.service_lines); i++) {
> +			if (i > 0)
> +				tprints(", ");
> +			tprints("[");
> +			for (j = 0;
> +			     j < ARRAY_SIZE(f->fmt.sliced.service_lines[0]);
> +			     j++) {
> +				if (j > 0)
> +					tprints(", ");
> +				tprintf("%#x",
> +					f->fmt.sliced.service_lines[i][j]);
> +			}
> +			tprints("]");
> +		}
> +		tprintf("]}");
>  		break;
> -
> +	}

It was my advice to use ARRAY_SIZE, and it's the right way to do,
but everything has exploded in -m32 build:

gcc -DHAVE_CONFIG_H   -I./linux/x86_64 -I../linux/x86_64 -I./linux -I../linux -I. -I..   -DIN_MPERS -DMPERS_IS_m32 -I./mpers-m32  -Wall -Wempty-body -Wformat-security -Wignored-qualifiers -Winit-self -Wlogical-op -Wmissing-parameter-type -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wsign-compare -Wtype-limits -Wwrite-strings -Werror  -pipe -Wall -g -O2 -c -o libmpers_m32_a-v4l2.o `test -f 'v4l2.c' || echo '../'`v4l2.c
In file included from ../v4l2.c:30:0:
../v4l2.c: In function 'print_v4l2_format_fmt':
../defs.h:78:46: error: subscripted value is neither array nor pointer nor vector
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]) + MUST_BE_ARRAY(a))
                                              ^
../v4l2.c:315:13: note: in expansion of macro 'ARRAY_SIZE'
         j < ARRAY_SIZE(f->fmt.sliced.service_lines[0]);
             ^~~~~~~~~~
In file included from ../defs.h:58:0,
                 from ../v4l2.c:30:
../gcc_compat.h:59:66: error: subscripted value is neither array nor pointer nor vector
 # define MUST_BE_ARRAY(a) FAIL_BUILD_ON_ZERO(!SAME_TYPE((a), &(a)[0]))
                                                                  ^
../gcc_compat.h:57:59: note: in definition of macro 'FAIL_BUILD_ON_ZERO'
 # define FAIL_BUILD_ON_ZERO(expr) (sizeof(int[-1 + 2 * !!(expr)]) * 0)
                                                           ^~~~
../gcc_compat.h:59:47: note: in expansion of macro 'SAME_TYPE'
 # define MUST_BE_ARRAY(a) FAIL_BUILD_ON_ZERO(!SAME_TYPE((a), &(a)[0]))
                                               ^~~~~~~~~
../defs.h:78:53: note: in expansion of macro 'MUST_BE_ARRAY'
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]) + MUST_BE_ARRAY(a))
                                                     ^~~~~~~~~~~~~
../v4l2.c:315:13: note: in expansion of macro 'ARRAY_SIZE'
         j < ARRAY_SIZE(f->fmt.sliced.service_lines[0]);
             ^~~~~~~~~~
../v4l2.c:320:36: error: subscripted value is neither array nor pointer nor vector
      f->fmt.sliced.service_lines[i][j]);
                                    ^

This must be a bug in mpers.awk because mpers-m32/struct_v4l2_format.h looks
wrong around service_lines.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170404/85019d5a/attachment.bin>


More information about the Strace-devel mailing list