diff mbox series

utils: checks for empty instead of size in if

Message ID 20200416041046.389060-1-rosenp@gmail.com (mailing list archive)
State New, archived
Headers show
Series utils: checks for empty instead of size in if | expand

Commit Message

Rosen Penev April 16, 2020, 4:10 a.m. UTC
Found with clang-tidy's readability-container-size-empty

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 utils/cec-ctl/cec-ctl.cpp           |  2 +-
 utils/rds-ctl/rds-ctl.cpp           |  2 +-
 utils/v4l2-ctl/v4l2-ctl-common.cpp  |  4 ++--
 utils/v4l2-ctl/v4l2-ctl-overlay.cpp | 10 +++++-----
 4 files changed, 9 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index b64a42b5..ae668806 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -2309,7 +2309,7 @@  int main(int argc, char **argv)
 		return 1;
 	}
 
-	if (msgs.size())
+	if (!msgs.empty())
 		warn_if_unconfigured = true;
 
 	if (store_pin && analyze_pin) {
diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp
index 17d3e203..b1e076fb 100644
--- a/utils/rds-ctl/rds-ctl.cpp
+++ b/utils/rds-ctl/rds-ctl.cpp
@@ -992,7 +992,7 @@  int main(int argc, char **argv)
 	if (!params.options[OptSetDevice]) {
 		/* check the system for RDS capable devices */
 		dev_vec devices = list_devices();
-		if (devices.size() == 0) {
+		if (devices.empty()) {
 			fprintf(stderr, "No RDS-capable device found\n");
 			exit(1);
 		}
diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp
index ac294dd1..e3c2602c 100644
--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
@@ -1007,7 +1007,7 @@  void common_set(cv4l_fd &_fd)
 				}
 				continue;
 			}
-			if (iter->second.size()) {
+			if (!iter->second.empty()) {
 				ctrls.which = iter->first;
 				ctrls.count = iter->second.size();
 				ctrls.controls = &iter->second[0];
@@ -1133,7 +1133,7 @@  void common_get(cv4l_fd &_fd)
 				}
 				continue;
 			}
-			if (iter->second.size()) {
+			if (!iter->second.empty()) {
 				ctrls.which = iter->first;
 				ctrls.count = iter->second.size();
 				ctrls.controls = &iter->second[0];
diff --git a/utils/v4l2-ctl/v4l2-ctl-overlay.cpp b/utils/v4l2-ctl/v4l2-ctl-overlay.cpp
index 4eca772b..162248bc 100644
--- a/utils/v4l2-ctl/v4l2-ctl-overlay.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-overlay.cpp
@@ -395,9 +395,9 @@  static void do_try_set_overlay(struct v4l2_format &fmt, int fd)
 	if (((set_overlay_fmt & FmtWidth) && win.w.width != overlay_fmt.fmt.win.w.width) ||
 	    ((set_overlay_fmt & FmtHeight) && win.w.height != overlay_fmt.fmt.win.w.height))
 		keep_old_bitmap = keep_old_clip = false;
-	if (options[OptClearBitmap] || bitmap_rects.size())
+	if (options[OptClearBitmap] || !bitmap_rects.empty())
 		keep_old_bitmap = false;
-	if (options[OptClearClips] || clips.size())
+	if (options[OptClearClips] || !clips.empty())
 		keep_old_clip = false;
 
 	win.bitmap = NULL;
@@ -428,11 +428,11 @@  static void do_try_set_overlay(struct v4l2_format &fmt, int fd)
 		win.w.height = overlay_fmt.fmt.win.w.height;
 	if (set_overlay_fmt & FmtField)
 		win.field = overlay_fmt.fmt.win.field;
-	if (clips.size()) {
+	if (!clips.empty()) {
 		win.clipcount = clips.size();
 		win.clips = &clips[0];
 	}
-	if (bitmap_rects.size()) {
+	if (!bitmap_rects.empty()) {
 		free(bitmap);
 		stride = (win.w.width + 7) / 8;
 		bitmap = (unsigned char *)calloc(1, stride * win.w.height);
@@ -471,7 +471,7 @@  void overlay_set(cv4l_fd &_fd)
 
 	if ((options[OptSetOverlayFormat] || options[OptTryOverlayFormat]) &&
 			(set_overlay_fmt || options[OptClearClips] || options[OptClearBitmap] ||
-			 bitmap_rects.size() || clips.size())) {
+			 !bitmap_rects.empty() || !clips.empty())) {
 		struct v4l2_format fmt;
 
 		memset(&fmt, 0, sizeof(fmt));