diff mbox series

[3/8,clang-tidy] use auto

Message ID 20200727031456.232955-4-rosenp@gmail.com (mailing list archive)
State New, archived
Headers show
Series v4l-utils: C++11 modernization | expand

Commit Message

Rosen Penev July 27, 2020, 3:14 a.m. UTC
Found with modernize-use-auto

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 utils/cec-compliance/cec-compliance.cpp     | 2 +-
 utils/cec-compliance/cec-test.cpp           | 2 +-
 utils/cec-ctl/cec-ctl.cpp                   | 2 +-
 utils/cec-follower/cec-follower.cpp         | 2 +-
 utils/rds-ctl/rds-ctl.cpp                   | 2 +-
 utils/v4l2-compliance/v4l2-compliance.cpp   | 6 +++---
 utils/v4l2-compliance/v4l2-test-buffers.cpp | 6 +++---
 utils/v4l2-ctl/v4l2-ctl-common.cpp          | 4 ++--
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp       | 1 +
 utils/v4l2-ctl/v4l2-ctl-vidcap.cpp          | 4 ++--
 utils/v4l2-ctl/v4l2-ctl.cpp                 | 8 ++++----
 11 files changed, 20 insertions(+), 19 deletions(-)
diff mbox series

Patch

diff --git a/utils/cec-compliance/cec-compliance.cpp b/utils/cec-compliance/cec-compliance.cpp
index 796d0b3c..06a8e23f 100644
--- a/utils/cec-compliance/cec-compliance.cpp
+++ b/utils/cec-compliance/cec-compliance.cpp
@@ -655,7 +655,7 @@  int cec_named_ioctl(struct node *node, const char *name,
 {
 	int retval;
 	int e;
-	struct cec_msg *msg = static_cast<struct cec_msg *>(parm);
+	auto msg = static_cast<struct cec_msg *>(parm);
 	__u8 opcode = 0;
 	std::string opname;
 
diff --git a/utils/cec-compliance/cec-test.cpp b/utils/cec-compliance/cec-test.cpp
index 2b5265a3..986d134f 100644
--- a/utils/cec-compliance/cec-test.cpp
+++ b/utils/cec-compliance/cec-test.cpp
@@ -1502,7 +1502,7 @@  void collectTests()
 	for (const auto &test : tests) {
 		for (unsigned j = 0; j < test.num_subtests; j++) {
 			std::string name = safename(test.subtests[j].name);
-			__u64 func = (__u64)test.subtests[j].test_fn;
+			auto func = (__u64)test.subtests[j].test_fn;
 
 			if (mapTestFuncs.find(name) != mapTestFuncs.end() &&
 			    mapTestFuncs[name] != func) {
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index 1fa7ba15..8ae800bb 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -1772,7 +1772,7 @@  static void list_devices()
 	closedir(dp);
 
 	/* Find device nodes which are links to other device nodes */
-	for (dev_vec::iterator iter = files.begin();
+	for (auto iter = files.begin();
 			iter != files.end(); ) {
 		char link[64+1];
 		int link_len;
diff --git a/utils/cec-follower/cec-follower.cpp b/utils/cec-follower/cec-follower.cpp
index 9acdb305..673c6e31 100644
--- a/utils/cec-follower/cec-follower.cpp
+++ b/utils/cec-follower/cec-follower.cpp
@@ -277,7 +277,7 @@  int cec_named_ioctl(int fd, const char *name,
 			name, retval, strerror(e));
 
 	if (!retval) {
-		const struct cec_msg *msg = static_cast<const struct cec_msg *>(parm);
+		const auto msg = static_cast<const struct cec_msg *>(parm);
 
 		/* Update the timestamp whenever we successfully transmit to an LA,
 		   or whenever we receive something from the LA */
diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp
index e69a498d..12ec8bae 100644
--- a/utils/rds-ctl/rds-ctl.cpp
+++ b/utils/rds-ctl/rds-ctl.cpp
@@ -346,7 +346,7 @@  static dev_vec list_devices()
 
 	/* Iterate through all devices, and remove all non-accessible devices
 	 * and all devices that don't offer the RDS_BLOCK_IO capability */
-	for (dev_vec::iterator iter = files.begin();
+	for (auto iter = files.begin();
 			iter != files.end();) {
 		int fd = open(iter->c_str(), O_RDONLY | O_NONBLOCK);
 		std::string bus_info;
diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
index 5f9996fb..fa941a14 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -900,11 +900,11 @@  static std::string make_devname(const char *device, const char *devname,
 		return device;
 	}
 
-	media_v2_entity *ents = new media_v2_entity[topology.num_entities];
+	auto ents = new media_v2_entity[topology.num_entities];
 	topology.ptr_entities = (uintptr_t)ents;
-	media_v2_link *links = new media_v2_link[topology.num_links];
+	auto links = new media_v2_link[topology.num_links];
 	topology.ptr_links = (uintptr_t)links;
-	media_v2_interface *ifaces = new media_v2_interface[topology.num_interfaces];
+	auto ifaces = new media_v2_interface[topology.num_interfaces];
 	topology.ptr_interfaces = (uintptr_t)ifaces;
 
 	unsigned i, ent_id, iface_id = 0;
diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp
index d4b1eb8b..436de288 100644
--- a/utils/v4l2-compliance/v4l2-test-buffers.cpp
+++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp
@@ -1681,7 +1681,7 @@  int testUserPtr(struct node *node, struct node *node_m2m_cap, unsigned frame_cou
 			for (unsigned p = 0; p < q.g_num_planes(); p++) {
 				/* ensure that len is a multiple of 4 */
 				__u32 len = ((q.g_length(p) + 3) & ~0x3) + 4 * 4096;
-				__u32 *m = static_cast<__u32 *>(malloc(len));
+				auto m = static_cast<__u32 *>(malloc(len));
 
 				fail_on_test(!m);
 				fail_on_test((uintptr_t)m & 0x7);
@@ -1740,7 +1740,7 @@  int testUserPtr(struct node *node, struct node *node_m2m_cap, unsigned frame_cou
 				__u32 buflen = (q.g_length(p) + 3U) & ~3U;
 				__u32 memlen = buflen + 4 * 4096;
 				__u32 *m = buffers[i][p];
-				__u32 *u = static_cast<__u32 *>(q.g_userptr(i, p));
+				auto u = static_cast<__u32 *>(q.g_userptr(i, p));
 
 				for (__u32 *x = m; x < u; x++)
 					if (*x != filler)
@@ -2372,7 +2372,7 @@  public:
 private:
 	static void *startRoutine(void *arg)
 	{
-		BlockingThread *self = static_cast<BlockingThread *>(arg);
+		auto self = static_cast<BlockingThread *>(arg);
 
 		pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
 		pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp
index ea026fd5..c8705a04 100644
--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
@@ -225,7 +225,7 @@  static void list_media_devices(const std::string &media_bus_info)
 		return;
 	}
 
-	media_v2_interface *ifaces = new media_v2_interface[topology.num_interfaces];
+	auto ifaces = new media_v2_interface[topology.num_interfaces];
 	topology.ptr_interfaces = (uintptr_t)ifaces;
 
 	if (!ioctl(media_fd, MEDIA_IOC_G_TOPOLOGY, &topology))
@@ -259,7 +259,7 @@  static void list_devices()
 	closedir(dp);
 
 	/* Find device nodes which are links to other device nodes */
-	for (dev_vec::iterator iter = files.begin();
+	for (auto iter = files.begin();
 			iter != files.end(); ) {
 		char link[64+1];
 		int link_len;
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index d986c7b6..0c384fe9 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -1,3 +1,4 @@ 
+#include <algorithm>
 #include <cstdlib>
 #include <cstring>
 
diff --git a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
index 80312b51..5abab5e7 100644
--- a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
@@ -366,7 +366,7 @@  void print_touch_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
 		'.', ',', ':', ';', '!', '|', 'i', 'c',
 		'n', 'o', 'm', 'I', 'C', 'N', 'O', 'M',
 	};
-	__s16 *vbuf = static_cast<__s16 *>(q.g_dataptr(buf.g_index(), 0));
+	auto vbuf = static_cast<__s16 *>(q.g_dataptr(buf.g_index(), 0));
 	__u32 x, y;
 
 	switch (fmt.g_pixelformat()) {
@@ -375,7 +375,7 @@  void print_touch_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
 			fprintf(f, "TD16: ");
 
 			for (x = 0; x < fmt.g_width(); x++, vbuf++) {
-				__s16 v = static_cast<__s16>(le16toh(*vbuf));
+				auto v = static_cast<__s16>(le16toh(*vbuf));
 
 				if (!options[OptConcise])
 					fprintf(f, "% 4d", v);
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index 321d2d1c..a31b29f8 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -484,7 +484,7 @@  void printfmt(int fd, const struct v4l2_format &vfmt)
 			}
 		printf("\tClip Bitmap : %s", vfmt.fmt.win.bitmap ? "Yes, " : "No\n");
 		if (vfmt.fmt.win.bitmap) {
-			unsigned char *bitmap = static_cast<unsigned char *>(vfmt.fmt.win.bitmap);
+			auto bitmap = static_cast<unsigned char *>(vfmt.fmt.win.bitmap);
 			unsigned stride = (vfmt.fmt.win.w.width + 7) / 8;
 			unsigned cnt = 0;
 
@@ -1056,11 +1056,11 @@  static const char *make_devname(const char *device, const char *devname,
 		return device;
 	}
 
-	media_v2_entity *ents = new media_v2_entity[topology.num_entities];
+	auto ents = new media_v2_entity[topology.num_entities];
 	topology.ptr_entities = (uintptr_t)ents;
-	media_v2_link *links = new media_v2_link[topology.num_links];
+	auto links = new media_v2_link[topology.num_links];
 	topology.ptr_links = (uintptr_t)links;
-	media_v2_interface *ifaces = new media_v2_interface[topology.num_interfaces];
+	auto ifaces = new media_v2_interface[topology.num_interfaces];
 	topology.ptr_interfaces = (uintptr_t)ifaces;
 
 	unsigned i, ent_id, iface_id = 0;