quirks: enforce uppercase hex numbers
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 18 Jan 2019 01:57:55 +0000 (11:57 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 18 Jan 2019 04:31:53 +0000 (04:31 +0000)
No specific reason other than consistency.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
quirks/30-vendor-contour.quirks
quirks/30-vendor-kensington.quirks
quirks/50-system-chicony.quirks
src/quirks.c

index 12773e588a62445c17365dc9e7648fa3dc1301c9..23738b08b41373d2e279492d9bcae42171ab72c7 100644 (file)
@@ -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
index d422a58efca6638d3381cf0a6e8c73f997b216d9..f4d83a091300052deb128f1aee82736ff81f99b6 100644 (file)
@@ -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
index 1ce3b8dca3a9c79a6263be62d78f1585b7620702..911b7d699cc7ca52f2b4cb6c85f33bad4c2397e5 100644 (file)
@@ -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
index fa12045b6aa52620568ef9ccd9fa7d553c3da3eb..fd7fbfd83ad1d70f616c00b71d62b067c4ab5bd8 100644 (file)
@@ -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;