quirks: enforce uppercase hex numbers
No specific reason other than consistency. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
1 parent
8630e0ef67
commit
c412924003
4 files changed
+17
-14
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
+12
-9
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user