Re: [systemd-devel] [PATCH v2 1/2] input_id: Make test_pointer / test_keys return if they've found anything
On Mon, Apr 13, 2015 at 03:08:53PM +0200, Hans de Goede wrote: Hi, On 13-04-15 14:41, Zbigniew Jędrzejewski-Szmek wrote: On Mon, Apr 13, 2015 at 11:15:00AM +0200, Hans de Goede wrote: Make test_pointer / test_keys return a boolean indicating whether or not they've set any properties on the device. While touching allmost all test_bit() using lines anyways also remove the extra space between the function name and the '(' (coding style issue). Signed-off-by: Hans de Goede hdego...@redhat.com --- src/udev/udev-builtin-input_id.c | 98 1 file changed, 60 insertions(+), 38 deletions(-) diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index ecfc447..2c8a9ee 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -126,7 +126,7 @@ static void get_cap_mask(struct udev_device *dev, } /* pointer devices */ -static void test_pointers (struct udev_device *dev, +static bool test_pointers (struct udev_device *dev, ^ Those spaces after function name declaration should go too. That seems like something for a separate commit. And the white-space changes should probably be a separate commit becuase now it's hard to see what is going on ;) Almost all changed lines are changed because they must be changed (adding { or }, changing indentation), only 5 or so changed lines are purely removing the extra space between test_bit and '(' which is exactly why I squashed in those changes. I've split the commit up into a whitespace-only one and the new changes. Series pushed as 37186823f3868612e0cbfdc65b2562ccbda61ada Cheers, Peter @@ -135,77 +135,93 @@ static void test_pointers (struct udev_device *dev, bool test) { int is_mouse = 0; int is_touchpad = 0; +bool ret = false; -if (test_bit (INPUT_PROP_ACCELEROMETER, bitmask_props)) { +if (test_bit(INPUT_PROP_ACCELEROMETER, bitmask_props)) { udev_builtin_add_property(dev, test, ID_INPUT_ACCELEROMETER, 1); -return; +return true; } -if (!test_bit (EV_KEY, bitmask_ev)) { -if (test_bit (EV_ABS, bitmask_ev) -test_bit (ABS_X, bitmask_abs) -test_bit (ABS_Y, bitmask_abs) -test_bit (ABS_Z, bitmask_abs)) +if (!test_bit(EV_KEY, bitmask_ev)) { +if (test_bit(EV_ABS, bitmask_ev) +test_bit(ABS_X, bitmask_abs) +test_bit(ABS_Y, bitmask_abs) +test_bit(ABS_Z, bitmask_abs)) { udev_builtin_add_property(dev, test, ID_INPUT_ACCELEROMETER, 1); -return; +ret = true; +} +return ret; } -if (test_bit (EV_ABS, bitmask_ev) -test_bit (ABS_X, bitmask_abs) test_bit (ABS_Y, bitmask_abs)) { -if (test_bit (BTN_STYLUS, bitmask_key) || test_bit (BTN_TOOL_PEN, bitmask_key)) +if (test_bit(EV_ABS, bitmask_ev) +test_bit(ABS_X, bitmask_abs) test_bit(ABS_Y, bitmask_abs)) { +if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key)) { udev_builtin_add_property(dev, test, ID_INPUT_TABLET, 1); -else if (test_bit (BTN_TOOL_FINGER, bitmask_key) !test_bit (BTN_TOOL_PEN, bitmask_key)) +ret = true; +} else if (test_bit(BTN_TOOL_FINGER, bitmask_key) !test_bit(BTN_TOOL_PEN, bitmask_key)) { is_touchpad = 1; -else if (test_bit (BTN_MOUSE, bitmask_key)) +} else if (test_bit(BTN_MOUSE, bitmask_key)) { /* This path is taken by VMware's USB mouse, which has * absolute axes, but no touch/pressure button. */ is_mouse = 1; -else if (test_bit (BTN_TOUCH, bitmask_key)) +} else if (test_bit(BTN_TOUCH, bitmask_key)) { udev_builtin_add_property(dev, test, ID_INPUT_TOUCHSCREEN, 1); +ret = true; /* joysticks don't necessarily have to have buttons; e. g. * rudders/pedals are joystick-like, but buttonless; they have * other fancy axes */ -else if (test_bit (BTN_TRIGGER, bitmask_key) || - test_bit (BTN_A, bitmask_key) || - test_bit (BTN_1, bitmask_key) || - test_bit (ABS_RX, bitmask_abs) || - test_bit (ABS_RY, bitmask_abs) || - test_bit (ABS_RZ, bitmask_abs) || -
Re: [systemd-devel] [PATCH v2 1/2] input_id: Make test_pointer / test_keys return if they've found anything
Hi, On 13-04-15 14:41, Zbigniew Jędrzejewski-Szmek wrote: On Mon, Apr 13, 2015 at 11:15:00AM +0200, Hans de Goede wrote: Make test_pointer / test_keys return a boolean indicating whether or not they've set any properties on the device. While touching allmost all test_bit() using lines anyways also remove the extra space between the function name and the '(' (coding style issue). Signed-off-by: Hans de Goede hdego...@redhat.com --- src/udev/udev-builtin-input_id.c | 98 1 file changed, 60 insertions(+), 38 deletions(-) diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index ecfc447..2c8a9ee 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -126,7 +126,7 @@ static void get_cap_mask(struct udev_device *dev, } /* pointer devices */ -static void test_pointers (struct udev_device *dev, +static bool test_pointers (struct udev_device *dev, ^ Those spaces after function name declaration should go too. That seems like something for a separate commit. And the white-space changes should probably be a separate commit becuase now it's hard to see what is going on ;) Almost all changed lines are changed because they must be changed (adding { or }, changing indentation), only 5 or so changed lines are purely removing the extra space between test_bit and '(' which is exactly why I squashed in those changes. Regards, Hans Zbyszek @@ -135,77 +135,93 @@ static void test_pointers (struct udev_device *dev, bool test) { int is_mouse = 0; int is_touchpad = 0; +bool ret = false; -if (test_bit (INPUT_PROP_ACCELEROMETER, bitmask_props)) { +if (test_bit(INPUT_PROP_ACCELEROMETER, bitmask_props)) { udev_builtin_add_property(dev, test, ID_INPUT_ACCELEROMETER, 1); -return; +return true; } -if (!test_bit (EV_KEY, bitmask_ev)) { -if (test_bit (EV_ABS, bitmask_ev) -test_bit (ABS_X, bitmask_abs) -test_bit (ABS_Y, bitmask_abs) -test_bit (ABS_Z, bitmask_abs)) +if (!test_bit(EV_KEY, bitmask_ev)) { +if (test_bit(EV_ABS, bitmask_ev) +test_bit(ABS_X, bitmask_abs) +test_bit(ABS_Y, bitmask_abs) +test_bit(ABS_Z, bitmask_abs)) { udev_builtin_add_property(dev, test, ID_INPUT_ACCELEROMETER, 1); -return; +ret = true; +} +return ret; } -if (test_bit (EV_ABS, bitmask_ev) -test_bit (ABS_X, bitmask_abs) test_bit (ABS_Y, bitmask_abs)) { -if (test_bit (BTN_STYLUS, bitmask_key) || test_bit (BTN_TOOL_PEN, bitmask_key)) +if (test_bit(EV_ABS, bitmask_ev) +test_bit(ABS_X, bitmask_abs) test_bit(ABS_Y, bitmask_abs)) { +if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key)) { udev_builtin_add_property(dev, test, ID_INPUT_TABLET, 1); -else if (test_bit (BTN_TOOL_FINGER, bitmask_key) !test_bit (BTN_TOOL_PEN, bitmask_key)) +ret = true; +} else if (test_bit(BTN_TOOL_FINGER, bitmask_key) !test_bit(BTN_TOOL_PEN, bitmask_key)) { is_touchpad = 1; -else if (test_bit (BTN_MOUSE, bitmask_key)) +} else if (test_bit(BTN_MOUSE, bitmask_key)) { /* This path is taken by VMware's USB mouse, which has * absolute axes, but no touch/pressure button. */ is_mouse = 1; -else if (test_bit (BTN_TOUCH, bitmask_key)) +} else if (test_bit(BTN_TOUCH, bitmask_key)) { udev_builtin_add_property(dev, test, ID_INPUT_TOUCHSCREEN, 1); +ret = true; /* joysticks don't necessarily have to have buttons; e. g. * rudders/pedals are joystick-like, but buttonless; they have * other fancy axes */ -else if (test_bit (BTN_TRIGGER, bitmask_key) || - test_bit (BTN_A, bitmask_key) || - test_bit (BTN_1, bitmask_key) || - test_bit (ABS_RX, bitmask_abs) || - test_bit (ABS_RY, bitmask_abs) || - test_bit (ABS_RZ, bitmask_abs) || - test_bit (ABS_THROTTLE, bitmask_abs) || - test_bit (ABS_RUDDER, bitmask_abs) || - test_bit (ABS_WHEEL, bitmask_abs) || - test_bit (ABS_GAS, bitmask_abs) || - test_bit (ABS_BRAKE, bitmask_abs)) +
Re: [systemd-devel] [PATCH v2 1/2] input_id: Make test_pointer / test_keys return if they've found anything
On Mon, Apr 13, 2015 at 11:15:00AM +0200, Hans de Goede wrote: Make test_pointer / test_keys return a boolean indicating whether or not they've set any properties on the device. While touching allmost all test_bit() using lines anyways also remove the extra space between the function name and the '(' (coding style issue). Signed-off-by: Hans de Goede hdego...@redhat.com --- src/udev/udev-builtin-input_id.c | 98 1 file changed, 60 insertions(+), 38 deletions(-) diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index ecfc447..2c8a9ee 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -126,7 +126,7 @@ static void get_cap_mask(struct udev_device *dev, } /* pointer devices */ -static void test_pointers (struct udev_device *dev, +static bool test_pointers (struct udev_device *dev, ^ Those spaces after function name declaration should go too. And the white-space changes should probably be a separate commit becuase now it's hard to see what is going on ;) Zbyszek @@ -135,77 +135,93 @@ static void test_pointers (struct udev_device *dev, bool test) { int is_mouse = 0; int is_touchpad = 0; +bool ret = false; -if (test_bit (INPUT_PROP_ACCELEROMETER, bitmask_props)) { +if (test_bit(INPUT_PROP_ACCELEROMETER, bitmask_props)) { udev_builtin_add_property(dev, test, ID_INPUT_ACCELEROMETER, 1); -return; +return true; } -if (!test_bit (EV_KEY, bitmask_ev)) { -if (test_bit (EV_ABS, bitmask_ev) -test_bit (ABS_X, bitmask_abs) -test_bit (ABS_Y, bitmask_abs) -test_bit (ABS_Z, bitmask_abs)) +if (!test_bit(EV_KEY, bitmask_ev)) { +if (test_bit(EV_ABS, bitmask_ev) +test_bit(ABS_X, bitmask_abs) +test_bit(ABS_Y, bitmask_abs) +test_bit(ABS_Z, bitmask_abs)) { udev_builtin_add_property(dev, test, ID_INPUT_ACCELEROMETER, 1); -return; +ret = true; +} +return ret; } -if (test_bit (EV_ABS, bitmask_ev) -test_bit (ABS_X, bitmask_abs) test_bit (ABS_Y, bitmask_abs)) { -if (test_bit (BTN_STYLUS, bitmask_key) || test_bit (BTN_TOOL_PEN, bitmask_key)) +if (test_bit(EV_ABS, bitmask_ev) +test_bit(ABS_X, bitmask_abs) test_bit(ABS_Y, bitmask_abs)) { +if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key)) { udev_builtin_add_property(dev, test, ID_INPUT_TABLET, 1); -else if (test_bit (BTN_TOOL_FINGER, bitmask_key) !test_bit (BTN_TOOL_PEN, bitmask_key)) +ret = true; +} else if (test_bit(BTN_TOOL_FINGER, bitmask_key) !test_bit(BTN_TOOL_PEN, bitmask_key)) { is_touchpad = 1; -else if (test_bit (BTN_MOUSE, bitmask_key)) +} else if (test_bit(BTN_MOUSE, bitmask_key)) { /* This path is taken by VMware's USB mouse, which has * absolute axes, but no touch/pressure button. */ is_mouse = 1; -else if (test_bit (BTN_TOUCH, bitmask_key)) +} else if (test_bit(BTN_TOUCH, bitmask_key)) { udev_builtin_add_property(dev, test, ID_INPUT_TOUCHSCREEN, 1); +ret = true; /* joysticks don't necessarily have to have buttons; e. g. * rudders/pedals are joystick-like, but buttonless; they have * other fancy axes */ -else if (test_bit (BTN_TRIGGER, bitmask_key) || - test_bit (BTN_A, bitmask_key) || - test_bit (BTN_1, bitmask_key) || - test_bit (ABS_RX, bitmask_abs) || - test_bit (ABS_RY, bitmask_abs) || - test_bit (ABS_RZ, bitmask_abs) || - test_bit (ABS_THROTTLE, bitmask_abs) || - test_bit (ABS_RUDDER, bitmask_abs) || - test_bit (ABS_WHEEL, bitmask_abs) || - test_bit (ABS_GAS, bitmask_abs) || - test_bit (ABS_BRAKE, bitmask_abs)) +} else if (test_bit(BTN_TRIGGER, bitmask_key) || + test_bit(BTN_A, bitmask_key) || + test_bit(BTN_1, bitmask_key) || + test_bit(ABS_RX, bitmask_abs) || + test_bit(ABS_RY, bitmask_abs) ||