usbus_fmt: assert descr len matches claimed len

This commit adds runtime assertions to validate that the total length of
the configuration descriptor as communicated to the host device matches the
generated length of the configuration descriptor.
This commit is contained in:
Koen Zandberg 2019-10-24 11:51:07 +02:00 committed by benpicco
parent 2f74d9d644
commit cd25e1c011

View File

@ -260,6 +260,7 @@ size_t usbus_fmt_descriptor_conf(usbus_t *usbus)
usbus_control_slicer_put_bytes(usbus, (uint8_t *)&conf, sizeof(conf));
len += _fmt_descriptors_post(usbus, usbus->descr_gen);
len += _fmt_descriptors_ifaces(usbus);
assert(len == conf.total_length);
return len;
}