diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2019-01-18 11:57:55 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2019-01-18 04:31:53 +0000 |
commit | c412924003b31541b0b97025d71609a38367863e (patch) | |
tree | 03631ca0dbd3667b4663864fc3289358890f8a00 | |
parent | 8630e0ef67ff458160492c2ce5c912a6e0adabaa (diff) | |
download | libinput-c412924003b31541b0b97025d71609a38367863e.tar.gz |
quirks: enforce uppercase hex numbers
No specific reason other than consistency.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | quirks/30-vendor-contour.quirks | 4 | ||||
-rw-r--r-- | quirks/30-vendor-kensington.quirks | 2 | ||||
-rw-r--r-- | quirks/50-system-chicony.quirks | 4 | ||||
-rw-r--r-- | src/quirks.c | 21 |
4 files changed, 17 insertions, 14 deletions
diff --git a/quirks/30-vendor-contour.quirks b/quirks/30-vendor-contour.quirks index 12773e58..23738b08 100644 --- a/quirks/30-vendor-contour.quirks +++ b/quirks/30-vendor-contour.quirks @@ -1,11 +1,11 @@ [Contour Design RollerMouse Free 2] -MatchVendor=0x0b33 +MatchVendor=0x0B33 MatchProduct=0x0401 MatchUdevType=mouse ModelBouncingKeys=1 [Contour Design RollerMouse Re:d] -MatchVendor=0x0b33 +MatchVendor=0x0B33 MatchProduct=0x1000 MatchUdevType=mouse ModelBouncingKeys=1 diff --git a/quirks/30-vendor-kensington.quirks b/quirks/30-vendor-kensington.quirks index d422a58e..f4d83a09 100644 --- a/quirks/30-vendor-kensington.quirks +++ b/quirks/30-vendor-kensington.quirks @@ -1,7 +1,7 @@ # Kensington Orbit claims to have a middle button, same for [Kensington Orbit Scroll Wheel] MatchBus=usb -MatchVendor=0x047d +MatchVendor=0x047D MatchProduct=0x2048 ModelTrackball=1 AttrEventCodeDisable=BTN_MIDDLE diff --git a/quirks/50-system-chicony.quirks b/quirks/50-system-chicony.quirks index 1ce3b8dc..911b7d69 100644 --- a/quirks/50-system-chicony.quirks +++ b/quirks/50-system-chicony.quirks @@ -12,6 +12,6 @@ AttrTPKComboLayout=below [Chicony Lenovo MIIX 720 Touchpad] MatchUdevType=touchpad MatchBus=usb -MatchVendor=0x17ef -MatchProduct=0x60a6 +MatchVendor=0x17EF +MatchProduct=0x60A6 AttrTPKComboLayout=below diff --git a/src/quirks.c b/src/quirks.c index fa12045b..fd7fbfd8 100644 --- a/src/quirks.c +++ b/src/quirks.c @@ -438,6 +438,15 @@ section_destroy(struct section *s) free(s); } +static inline bool +parse_hex(const char *value, unsigned int *parsed) +{ + return strneq(value, "0x", 2) && + safe_atou_base(value, parsed, 16) && + strspn(value, "0123456789xABCDEF") == strlen(value) && + *parsed <= 0xFFFF; +} + /** * Parse a MatchFooBar=banana line. * @@ -483,9 +492,7 @@ parse_match(struct quirks_context *ctx, unsigned int vendor; check_set_bit(s, M_VID); - if (!strneq(value, "0x", 2) || - !safe_atou_base(value, &vendor, 16) || - vendor > 0xFFFF) + if (!parse_hex(value, &vendor)) goto out; s->match.vendor = vendor; @@ -493,9 +500,7 @@ parse_match(struct quirks_context *ctx, unsigned int product; check_set_bit(s, M_PID); - if (!strneq(value, "0x", 2) || - !safe_atou_base(value, &product, 16) || - product > 0xFFFF) + if (!parse_hex(value, &product)) goto out; s->match.product = product; @@ -503,9 +508,7 @@ parse_match(struct quirks_context *ctx, unsigned int version; check_set_bit(s, M_VERSION); - if (!strneq(value, "0x", 2) || - !safe_atou_base(value, &version, 16) || - version > 0xFFFF) + if (!parse_hex(value, &version)) goto out; s->match.version = version; |