[PATCH libinput 1/2] Fix a few things scan-build complains about

Peter Hutterer peter.hutterer at who-t.net
Fri Jul 7 01:54:27 UTC 2017


Uninitialized variables, potential NULL dereferences, dead assignments and an
unused return value.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/test-keyboard.c |  6 +++---
 test/test-log.c      |  6 +++++-
 test/test-path.c     |  3 +--
 test/test-tablet.c   | 12 +++---------
 test/test-touchpad.c | 12 ++++++------
 tools/shared.c       |  9 +++++----
 6 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/test/test-keyboard.c b/test/test-keyboard.c
index 23538083..dc2e630e 100644
--- a/test/test-keyboard.c
+++ b/test/test-keyboard.c
@@ -213,9 +213,9 @@ START_TEST(keyboard_key_auto_release)
 		libinput_dispatch(libinput);
 
 		event = libinput_get_event(libinput);
-		kevent = litest_is_keyboard_event(event,
-						  key,
-						  LIBINPUT_KEY_STATE_PRESSED);
+		litest_is_keyboard_event(event,
+					 key,
+					 LIBINPUT_KEY_STATE_PRESSED);
 		libinput_event_destroy(event);
 	}
 
diff --git a/test/test-log.c b/test/test-log.c
index c07e6bd5..6b1e3923 100644
--- a/test/test-log.c
+++ b/test/test-log.c
@@ -148,9 +148,13 @@ axisrange_warning_log_handler(struct libinput *libinput,
 			      const char *format,
 			      va_list args)
 {
+	const char *substr;
+
 	axisrange_log_handler_called++;
 	litest_assert_notnull(format);
-	litest_assert_notnull(strstr(format, "is outside expected range"));
+
+	substr = strstr(format, "is outside expected range");
+	litest_assert_notnull(substr);
 }
 
 START_TEST(log_axisrange_warning)
diff --git a/test/test-path.c b/test/test-path.c
index d4087f1a..801166ea 100644
--- a/test/test-path.c
+++ b/test/test-path.c
@@ -651,8 +651,7 @@ START_TEST(path_add_device_suspend_resume)
 	device = libinput_path_add_device(li,
 					  libevdev_uinput_get_devnode(uinput1));
 	ck_assert(device != NULL);
-	device = libinput_path_add_device(li,
-					  libevdev_uinput_get_devnode(uinput2));
+	libinput_path_add_device(li, libevdev_uinput_get_devnode(uinput2));
 
 	libinput_dispatch(li);
 
diff --git a/test/test-tablet.c b/test/test-tablet.c
index d61478fc..a9ad9592 100644
--- a/test/test-tablet.c
+++ b/test/test-tablet.c
@@ -907,7 +907,7 @@ START_TEST(proximity_out_clear_buttons)
 	 */
 	for (button = BTN_TOUCH + 1; button <= BTN_STYLUS2; button++) {
 		bool button_released = false;
-		uint32_t event_button;
+		uint32_t event_button = 0;
 		enum libinput_button_state state;
 
 		if (!libevdev_has_event_code(dev->evdev, EV_KEY, button))
@@ -1505,8 +1505,6 @@ START_TEST(left_handed)
 	tablet_event = litest_is_tablet_event(event,
 				LIBINPUT_EVENT_TABLET_TOOL_AXIS);
 
-	tablet_event = libinput_event_get_tablet_tool_event(event);
-
 	x = libinput_event_tablet_tool_get_x(tablet_event);
 	y = libinput_event_tablet_tool_get_y(tablet_event);
 
@@ -2368,7 +2366,6 @@ START_TEST(tool_capabilities)
 	event = libinput_get_event(li);
 	t = litest_is_tablet_event(event, LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
 	tool = libinput_event_tablet_tool_get_tool(t);
-	tool = libinput_event_tablet_tool_get_tool(t);
 
 	ck_assert(libinput_tablet_tool_has_pressure(tool));
 	ck_assert(libinput_tablet_tool_has_distance(tool));
@@ -3036,8 +3033,7 @@ START_TEST(tablet_calibration_set_matrix_delta)
 	libinput_event_destroy(event);
 
 	event = libinput_get_event(li);
-	tablet_event = litest_is_tablet_event(event,
-					      LIBINPUT_EVENT_TABLET_TOOL_TIP);
+	litest_is_tablet_event(event, LIBINPUT_EVENT_TABLET_TOOL_TIP);
 	libinput_event_destroy(event);
 
 	litest_tablet_motion(dev, 80, 80, axes);
@@ -3067,8 +3063,7 @@ START_TEST(tablet_calibration_set_matrix_delta)
 	libinput_event_destroy(event);
 
 	event = libinput_get_event(li);
-	tablet_event = litest_is_tablet_event(event,
-					      LIBINPUT_EVENT_TABLET_TOOL_TIP);
+	litest_is_tablet_event(event, LIBINPUT_EVENT_TABLET_TOOL_TIP);
 	libinput_event_destroy(event);
 
 	litest_tablet_motion(dev, 80, 80, axes);
@@ -3434,7 +3429,6 @@ START_TEST(tablet_pressure_range)
 		event = libinput_get_event(li);
 		tev = litest_is_tablet_event(event, LIBINPUT_EVENT_TABLET_TOOL_AXIS);
 		p = libinput_event_tablet_tool_get_pressure(tev);
-		p = libinput_event_tablet_tool_get_pressure(tev);
 		ck_assert_double_ge(p, 0.0);
 		ck_assert_double_le(p, 1.0);
 		libinput_event_destroy(event);
diff --git a/test/test-touchpad.c b/test/test-touchpad.c
index 913fad64..a96f376c 100644
--- a/test/test-touchpad.c
+++ b/test/test-touchpad.c
@@ -855,9 +855,9 @@ START_TEST(touchpad_edge_scroll_buttonareas_click_stops_scroll)
 	libinput_event_destroy(event);
 
 	event = libinput_get_event(li);
-	ptrev = litest_is_button_event(event,
-				       BTN_RIGHT,
-				       LIBINPUT_BUTTON_STATE_PRESSED);
+	litest_is_button_event(event,
+			       BTN_RIGHT,
+			       LIBINPUT_BUTTON_STATE_PRESSED);
 
 	libinput_event_destroy(event);
 
@@ -905,9 +905,9 @@ START_TEST(touchpad_edge_scroll_clickfinger_click_stops_scroll)
 	libinput_event_destroy(event);
 
 	event = libinput_get_event(li);
-	ptrev = litest_is_button_event(event,
-				       BTN_LEFT,
-				       LIBINPUT_BUTTON_STATE_PRESSED);
+	litest_is_button_event(event,
+			       BTN_LEFT,
+			       LIBINPUT_BUTTON_STATE_PRESSED);
 
 	libinput_event_destroy(event);
 
diff --git a/tools/shared.c b/tools/shared.c
index 998782ff..8039de9b 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -491,10 +491,11 @@ tools_exec_command(const char *prefix, int real_argc, char **real_argv)
 	setup_path();
 
 	rc = execvp(executable, argv);
-	fprintf(stderr,
-		"Failed to execute '%s' (%s)\n",
-		command,
-		strerror(errno));
+	if (rc)
+		fprintf(stderr,
+			"Failed to execute '%s' (%s)\n",
+			command,
+			strerror(errno));
 
 	return EXIT_FAILURE;
 }
-- 
2.13.0



More information about the wayland-devel mailing list