From 37c8dec45c29ebf016a7b514fa248d36929916a5 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 10 Jul 2017 15:21:15 +1000 Subject: [PATCH] Fix the various scan-build warnings for dead assignments Signed-off-by: Peter Hutterer --- src/driver-etekcity.c | 3 +++ src/driver-hidpp20.c | 2 ++ src/hidpp10.c | 1 - src/hidpp20.c | 2 -- test/test-device.c | 2 +- tools/ratbag-command.c | 15 +++++++++------ 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/driver-etekcity.c b/src/driver-etekcity.c index 474388fe..680fbbfa 100644 --- a/src/driver-etekcity.c +++ b/src/driver-etekcity.c @@ -652,6 +652,9 @@ etekcity_probe(struct ratbag_device *device) rc = ratbag_hidraw_raw_request(device, ETEKCITY_REPORT_ID_SPEED_SETTING, drv_data->speed_setting, ETEKCITY_REPORT_SIZE_SPEED_SETTING, HID_FEATURE_REPORT, HID_REQ_GET_REPORT); + if (rc) + return rc; + log_debug(device->ratbag, "device is at %d ms of latency\n", drv_data->speed_setting[2]); /* profiles are 0-indexed */ diff --git a/src/driver-hidpp20.c b/src/driver-hidpp20.c index 9520653e..104a18b4 100644 --- a/src/driver-hidpp20.c +++ b/src/driver-hidpp20.c @@ -772,6 +772,8 @@ hidpp20drv_init_feature(struct ratbag_device *device, uint16_t feature) &feature_index, &feature_type, &feature_version); + if (rc < 0) + return rc; switch (feature) { case HIDPP_PAGE_ROOT: diff --git a/src/hidpp10.c b/src/hidpp10.c index a16272f4..0ffc4463 100644 --- a/src/hidpp10.c +++ b/src/hidpp10.c @@ -1080,7 +1080,6 @@ hidpp10_onboard_profiles_macro_next(struct hidpp10_device *device, break; case HIDPP10_MACRO_END: - step = 1; return 0; default: if (macro->any.type >= 0x80 && macro->any.type <= 0xFE) { diff --git a/src/hidpp20.c b/src/hidpp20.c index 873731db..6c7a6de0 100644 --- a/src/hidpp20.c +++ b/src/hidpp20.c @@ -975,7 +975,6 @@ int hidpp20_adjustable_dpi_get_sensors(struct hidpp20_device *device, *sensors_list = s_list; return num_sensors; err: - num_sensors = 0; free(s_list); return rc > 0 ? -EPROTO : rc; } @@ -1457,7 +1456,6 @@ hidpp20_onboard_profiles_macro_next(struct hidpp20_device *device, rc = -EAGAIN; break; case HIDPP20_MACRO_END: - step = 1; return 0; default: hidpp_log_error(&device->base, "unknown tag: 0x%02x\n", macro->any.type); diff --git a/test/test-device.c b/test/test-device.c index 24d7a1df..a19f30b1 100644 --- a/test/test-device.c +++ b/test/test-device.c @@ -488,7 +488,7 @@ START_TEST(device_freed_before_profile) is_active = ratbag_profile_is_active(p); ck_assert_int_eq(is_active, 1); - p = ratbag_profile_unref(p); + ratbag_profile_unref(p); ratbag_unref(r); ck_assert_int_eq(device_freed_count, 1); } diff --git a/tools/ratbag-command.c b/tools/ratbag-command.c index 65a621c8..4e0ba1cf 100644 --- a/tools/ratbag-command.c +++ b/tools/ratbag-command.c @@ -480,13 +480,13 @@ ratbag_cmd_info(const struct ratbag_cmd *cmd, printf(" Button: %d type %s is mapped to '%s'\n", b, button_type_to_str(type), action); free(action); - button = ratbag_button_unref(button); + ratbag_button_unref(button); } for (l = 0; l < num_leds; l++) { led = ratbag_profile_get_led(profile, l); ratbag_printf_led(led, " LED: %d ", l); - led = ratbag_led_unref(led); + ratbag_led_unref(led); } ratbag_profile_unref(profile); @@ -540,8 +540,8 @@ ratbag_cmd_switch_etekcity(const struct ratbag_cmd *cmd, commit = 2; } - button_6 = ratbag_button_unref(button_6); - button_7 = ratbag_button_unref(button_7); + ratbag_button_unref(button_6); + ratbag_button_unref(button_7); printf("Switched the current profile of '%s' to %sreport the volume keys\n", ratbag_device_get_name(device), @@ -673,6 +673,9 @@ ratbag_cmd_change_button(const struct ratbag_cmd *cmd, argc -= 3; argv += 3; + (void)argc; + (void)argv; + if (streq(action_str, "button")) { action_type = RATBAG_BUTTON_ACTION_TYPE_BUTTON; btnkey = atoi(action_arg); @@ -766,7 +769,7 @@ ratbag_cmd_change_button(const struct ratbag_cmd *cmd, } out: - button = ratbag_button_unref(button); + ratbag_button_unref(button); return rc; } @@ -1869,7 +1872,7 @@ ratbag_cmd_profile_active_set(const struct ratbag_cmd *cmd, } out: - profile = ratbag_profile_unref(profile); + ratbag_profile_unref(profile); return rc; }