cppcheck: turn several references to const
PATCH 1/2 cppcheck: turn several references to const
Found with constParameter
Signed-off-by Rosen Penev <[email protected]>
--- utils/cec-ctl/cec-ctl.cpp | 18 +++++++++--------- utils/qvidcap/capture.cpp | 4 ++-- utils/v4l2-compliance/v4l2-test-controls.cpp | 4 ++-- utils/v4l2-ctl/v4l2-ctl-selection.cpp | 4 ++-- utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-)
utils/cec-ctl/cec-ctl.cpp +9 -9
@@ -791,7 +791,7 @@ static void show_msg(const cec_msg &msg) status.c_str()); } -static void wait_for_msgs(struct node &node, __u32 monitor_time) +static void wait_for_msgs(const struct node &node, __u32 monitor_time) { fd_set rd_fds; fd_set ex_fds;
@@ -836,7 +836,7 @@ static void wait_for_msgs(struct node &node, __u32 monitor_time) #define MONITOR_FL_DROPPED_EVENTS (1 << 16) -static void monitor(struct node &node, __u32 monitor_time, const char *store_pin) +static void monitor(const struct node &node, __u32 monitor_time, const char *store_pin) { __u32 monitor = CEC_MODE_MONITOR; fd_set rd_fds;
@@ -1057,7 +1057,7 @@ err: std::exit(EXIT_FAILURE); } -static bool wait_for_pwr_state(struct node &node, unsigned from, +static bool wait_for_pwr_state(const struct node &node, unsigned from, unsigned &hpd_is_low_cnt, bool on) { struct cec_msg msg;
@@ -1116,18 +1116,18 @@ static bool wait_for_pwr_state(struct node &node, unsigned from, return pwr == (on ? CEC_OP_POWER_STATUS_ON : CEC_OP_POWER_STATUS_STANDBY); } -static bool wait_for_power_on(struct node &node, unsigned from) +static bool wait_for_power_on(const struct node &node, unsigned from) { unsigned hpd_is_low_cnt = 0; return wait_for_pwr_state(node, from, hpd_is_low_cnt, true); } -static bool wait_for_power_off(struct node &node, unsigned from, unsigned &hpd_is_low_cnt) +static bool wait_for_power_off(const struct node &node, unsigned from, unsigned &hpd_is_low_cnt) { return wait_for_pwr_state(node, from, hpd_is_low_cnt, false); } -static int transmit_msg_retry(struct node &node, struct cec_msg &msg) +static int transmit_msg_retry(const struct node &node, struct cec_msg &msg) { bool from_unreg = cec_msg_initiator(&msg) == CEC_LOG_ADDR_UNREGISTERED; unsigned cnt = 0;
@@ -1144,7 +1144,7 @@ static int transmit_msg_retry(struct node &node, struct cec_msg &msg) return ret; } -static int init_power_cycle_test(struct node &node, unsigned repeats, unsigned max_tries) +static int init_power_cycle_test(const struct node &node, unsigned repeats, unsigned max_tries) { struct cec_msg msg; unsigned from;
@@ -1261,7 +1261,7 @@ static int init_power_cycle_test(struct node &node, unsigned repeats, unsigned m return from; } -static void test_power_cycle(struct node &node, unsigned int max_tries, +static void test_power_cycle(const struct node &node, unsigned int max_tries, unsigned int retry_sleep) { struct cec_log_addrs laddrs = { };
@@ -1476,7 +1476,7 @@ static void test_power_cycle(struct node &node, unsigned int max_tries, printf("Test had %u failure%s\n", failures, failures == 1 ? "" : "s"); } -static void stress_test_power_cycle(struct node &node, unsigned cnt, +static void stress_test_power_cycle(const struct node &node, unsigned cnt, unsigned min_sleep, unsigned max_sleep, unsigned max_tries, bool has_seed, unsigned seed, unsigned repeats, double sleep_before_on, double sleep_before_off)
utils/qvidcap/capture.cpp +2 -2
@@ -543,7 +543,7 @@ void CaptureWin::mouseDoubleClickEvent(QMouseEvent * e) toggleFullScreen(); } -void CaptureWin::cycleMenu(__u32 &overrideVal, __u32 &origVal, +void CaptureWin::cycleMenu(__u32 &overrideVal, const __u32 &origVal, const __u32 values[], bool hasShift, bool hasCtrl) { unsigned i;
@@ -1106,7 +1106,7 @@ bool CaptureWin::setV4LFormat(cv4l_fmt &fmt) return true; } -void CaptureWin::setPixelAspect(v4l2_fract &pixelaspect) +void CaptureWin::setPixelAspect(const v4l2_fract &pixelaspect) { m_pixelaspect = pixelaspect; }
utils/v4l2-compliance/v4l2-test-controls.cpp +2 -2
@@ -345,7 +345,7 @@ int testQueryControls(struct node *node) return 0; } -static int checkSimpleCtrl(struct v4l2_control &ctrl, struct test_query_ext_ctrl &qctrl) +static int checkSimpleCtrl(const struct v4l2_control &ctrl, const struct test_query_ext_ctrl &qctrl) { if (ctrl.id != qctrl.id) return fail("control id mismatch\n");
@@ -524,7 +524,7 @@ int testSimpleControls(struct node *node) return 0; } -static int checkExtendedCtrl(struct v4l2_ext_control &ctrl, struct test_query_ext_ctrl &qctrl) +static int checkExtendedCtrl(const struct v4l2_ext_control &ctrl, const struct test_query_ext_ctrl &qctrl) { int len;
utils/v4l2-ctl/v4l2-ctl-selection.cpp +2 -2
@@ -69,7 +69,7 @@ void selection_usage() ); } -static void do_crop(int fd, unsigned int set_crop, struct v4l2_rect &vcrop, v4l2_buf_type type) +static void do_crop(int fd, unsigned int set_crop, const struct v4l2_rect &vcrop, v4l2_buf_type type) { struct v4l2_crop in_crop;
@@ -125,7 +125,7 @@ static void parse_crop(char *optarg, unsigned int &set_crop, v4l2_rect &vcrop) } } -static void do_selection(int fd, unsigned int set_selection, struct v4l2_selection &vsel, +static void do_selection(int fd, unsigned int set_selection, const struct v4l2_selection &vsel, v4l2_buf_type type) { struct v4l2_selection in_selection;
utils/v4l2-ctl/v4l2-ctl-streaming.cpp +2 -2
@@ -2211,7 +2211,7 @@ static int capture_setup(cv4l_fd &fd, cv4l_queue &in, cv4l_fd *exp_fd, cv4l_fmt static void stateful_m2m(cv4l_fd &fd, cv4l_queue &in, cv4l_queue &out, FILE *fin, FILE *fout, cv4l_fmt &fmt_in, - cv4l_fmt &fmt_out, cv4l_fd *exp_fd_p) + const cv4l_fmt &fmt_out, cv4l_fd *exp_fd_p) { int fd_flags = fcntl(fd.g_fd(), F_GETFL); fps_timestamps fps_ts[2];
@@ -2411,7 +2411,7 @@ static void stateful_m2m(cv4l_fd &fd, cv4l_queue &in, cv4l_queue &out, static void stateless_m2m(cv4l_fd &fd, cv4l_queue &in, cv4l_queue &out, FILE *fin, FILE *fout, cv4l_fmt &fmt_in, - cv4l_fmt &fmt_out, cv4l_fd *exp_fd_p) + const cv4l_fmt &fmt_out, cv4l_fd *exp_fd_p) { fps_timestamps fps_ts[2]; unsigned count[2] = { 0, 0 };
Signature · 1 line
2.26.2
PATCH 2/2 [cppcheck: use const references
Found with constVariable
Signed-off-by Rosen Penev <[email protected]>
--- utils/common/media-info.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
utils/common/media-info.cpp +2 -2
@@ -439,7 +439,7 @@ static __u32 read_topology(int media_fd, __u32 major, __u32 minor, *is_invalid = true; return MEDIA_ENT_F_UNKNOWN; } - media_v2_interface &iface = v2_ifaces[i]; + const media_v2_interface &iface = v2_ifaces[i]; for (i = 0; i < topology.num_links; i++) { __u32 type = v2_links[i].flags & MEDIA_LNK_FL_LINK_TYPE;
@@ -486,7 +486,7 @@ static __u32 read_topology(int media_fd, __u32 major, __u32 minor, if (is_radio) return MEDIA_ENT_F_UNKNOWN; - media_v2_entity &ent = v2_ents[i]; + const media_v2_entity &ent = v2_ents[i]; printf("Entity Info:\n"); printf("\tID : 0x%08x (%u)\n", ent.id, ent.id); printf("\tName : %s\n", ent.name);
Signature · 1 line
2.26.2