All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: Sakari Ailus <sakari.ailus@iki.fi>,
	Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Gregor Jasny <gjasny@googlemail.com>
Subject: [v4l-utils] [PATCH 2/8] v4l2-compliance: Constify pointers and references in formats tests
Date: Tue,  2 Apr 2024 03:00:27 +0300	[thread overview]
Message-ID: <20240402000033.4007-3-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20240402000033.4007-1-laurent.pinchart@ideasonboard.com>

Multiple variables point to or reference data that never needs to be
modified. Make them const.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 utils/v4l2-compliance/v4l2-test-formats.cpp | 30 ++++++++++-----------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp
index 8a16613c3097..423567fe573b 100644
--- a/utils/v4l2-compliance/v4l2-test-formats.cpp
+++ b/utils/v4l2-compliance/v4l2-test-formats.cpp
@@ -49,7 +49,7 @@ static int testEnumFrameIntervals(struct node *node, __u32 pixfmt,
 				  __u32 w, __u32 h, __u32 type)
 {
 	struct v4l2_frmivalenum frmival;
-	struct v4l2_frmival_stepwise *sw = &frmival.stepwise;
+	const struct v4l2_frmival_stepwise *sw = &frmival.stepwise;
 	bool found_stepwise = false;
 	unsigned f = 0;
 	int ret;
@@ -129,7 +129,7 @@ static int testEnumFrameIntervals(struct node *node, __u32 pixfmt,
 static int testEnumFrameSizes(struct node *node, __u32 pixfmt)
 {
 	struct v4l2_frmsizeenum frmsize;
-	struct v4l2_frmsize_stepwise *sw = &frmsize.stepwise;
+	const struct v4l2_frmsize_stepwise *sw = &frmsize.stepwise;
 	bool found_stepwise = false;
 	__u64 cookie;
 	unsigned f = 0;
@@ -438,15 +438,15 @@ static void createInvalidFmt(struct v4l2_format &fmt, struct v4l2_clip &clip, un
 
 static int testFormatsType(struct node *node, int ret,  unsigned type, struct v4l2_format &fmt, bool have_clip = false)
 {
-	pixfmt_map &map = node->buftype_pixfmts[type];
-	pixfmt_map *map_splane;
-	struct v4l2_pix_format &pix = fmt.fmt.pix;
-	struct v4l2_pix_format_mplane &pix_mp = fmt.fmt.pix_mp;
-	struct v4l2_window &win = fmt.fmt.win;
-	struct v4l2_vbi_format &vbi = fmt.fmt.vbi;
-	struct v4l2_sliced_vbi_format &sliced = fmt.fmt.sliced;
-	struct v4l2_sdr_format &sdr = fmt.fmt.sdr;
-	struct v4l2_meta_format &meta = fmt.fmt.meta;
+	const pixfmt_map &map = node->buftype_pixfmts[type];
+	const pixfmt_map *map_splane;
+	const struct v4l2_pix_format &pix = fmt.fmt.pix;
+	const struct v4l2_pix_format_mplane &pix_mp = fmt.fmt.pix_mp;
+	const struct v4l2_window &win = fmt.fmt.win;
+	const struct v4l2_vbi_format &vbi = fmt.fmt.vbi;
+	const struct v4l2_sliced_vbi_format &sliced = fmt.fmt.sliced;
+	const struct v4l2_sdr_format &sdr = fmt.fmt.sdr;
+	const struct v4l2_meta_format &meta = fmt.fmt.meta;
 	unsigned min_data_samples;
 	unsigned min_sampling_rate;
 	v4l2_std_id std;
@@ -497,7 +497,7 @@ static int testFormatsType(struct node *node, int ret,  unsigned type, struct v4
 			return fail("pix_mp.reserved not zeroed\n");
 		fail_on_test(pix_mp.num_planes == 0 || pix_mp.num_planes >= VIDEO_MAX_PLANES);
 		for (int i = 0; i < pix_mp.num_planes; i++) {
-			struct v4l2_plane_pix_format &pfmt = pix_mp.plane_fmt[i];
+			const struct v4l2_plane_pix_format &pfmt = pix_mp.plane_fmt[i];
 
 			ret = check_0(pfmt.reserved, sizeof(pfmt.reserved));
 			if (ret)
@@ -559,7 +559,7 @@ static int testFormatsType(struct node *node, int ret,  unsigned type, struct v4
 		if (have_clip)
 			fail_on_test(!win.clipcount && (node->fbuf_caps & V4L2_FBUF_CAP_LIST_CLIPPING));
 		if (win.clipcount) {
-			struct v4l2_rect *r = &win.clips->c;
+			const struct v4l2_rect *r = &win.clips->c;
 			struct v4l2_framebuffer fb;
 
 			fail_on_test(doioctl(node, VIDIOC_G_FBUF, &fb));
@@ -1281,8 +1281,8 @@ int testSlicedVBICap(struct node *node)
 static int testParmStruct(struct node *node, struct v4l2_streamparm &parm)
 {
 	bool is_stateful_enc = node->codec_mask & STATEFUL_ENCODER;
-	struct v4l2_captureparm *cap = &parm.parm.capture;
-	struct v4l2_outputparm *out = &parm.parm.output;
+	const struct v4l2_captureparm *cap = &parm.parm.capture;
+	const struct v4l2_outputparm *out = &parm.parm.output;
 	int ret;
 
 	switch (parm.type) {
-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2024-04-02  0:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02  0:00 [v4l-utils] [PATCH 0/8] Support for the generic line-based metadata support Laurent Pinchart
2024-04-02  0:00 ` [v4l-utils] [PATCH 1/8] utils: media-ctl: Print MUST_CONNECT pad flags Laurent Pinchart
2024-04-03  8:40   ` Laurent Pinchart
2024-04-03  8:43     ` Tomi Valkeinen
2024-04-03  8:56       ` Hans Verkuil
2024-04-04 20:17         ` Sakari Ailus
2024-04-04 22:04           ` Laurent Pinchart
2024-04-02  0:00 ` Laurent Pinchart [this message]
2024-04-03  8:44   ` [v4l-utils] [PATCH 2/8] v4l2-compliance: Constify pointers and references in formats tests Tomi Valkeinen
2024-04-03  8:46   ` Hans Verkuil
2024-04-02  0:00 ` [v4l-utils] [PATCH 3/8] v4l-utils: sync-with-kernel Laurent Pinchart
2024-04-02  0:00 ` [v4l-utils] [PATCH 4/8] utils: media-ctl: Support changed routing API Laurent Pinchart
2024-04-02  0:00 ` [v4l-utils] [PATCH 5/8] utils: media-ctl: Also print INTERNAL pad flag Laurent Pinchart
2024-04-02  0:00 ` [v4l-utils] [PATCH 6/8] v4l2-compliance: Support the changed routing API Laurent Pinchart
2024-04-02 10:54   ` Tomi Valkeinen
2024-04-05  6:37     ` Sakari Ailus
2024-04-02  0:00 ` [v4l-utils] [PATCH 7/8] v4l2-compliance: Add tests for V4L2_FMT_FLAG_META_LINE_BASED flag Laurent Pinchart
2024-04-02  0:00 ` [v4l-utils] [PATCH 8/8] v4l2-compliance: Test IMMUTABLE route flag Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240402000033.4007-3-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=gjasny@googlemail.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@iki.fi \
    --cc=tomi.valkeinen@ideasonboard.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.