gen_usb_descriptor: Fix off-by-1 error in endpoint counting

This commit is contained in:
Jeff Epler 2020-08-27 15:10:52 -05:00
parent 49a22b0c55
commit a03b6a99e6
1 changed files with 3 additions and 2 deletions

View File

@ -382,8 +382,9 @@ if args.max_ep != 0:
for interface in interfaces:
for subdescriptor in interface.subdescriptors:
endpoint_address = getattr(subdescriptor, 'bEndpointAddress', 0) & 0x7f
if endpoint_address > args.max_ep:
raise ValueError("Endpoint address %d of %s may not exceed %d" % (endpoint_address & 0x7f, interface.description, args.max_ep))
print("Endpoint %d - vs max_ep %d" % (endpoint_address, args.max_ep))
if endpoint_address >= args.max_ep:
raise ValueError("Endpoint address %d of %s must be less than %d" % (endpoint_address & 0x7f, interface.description, args.max_ep))
else:
print("Unable to check whether maximum number of endpoints is respected", file=sys.stderr)