Message/TLV builder API
Aleksander Morgado
aleksander at aleksander.es
Thu Oct 9 08:42:51 PDT 2014
Hey,
The qmi_utils_write_{something}_to_buffer() methods are really a bit
error prone, as the caller needs to make sure that there is enough
space in the buffer to write the variable that is being written, and
failure to do so would make some nasty assert()s.
I've now developed a new TLV writer API which does bounds checking and
error reporting, and also changed the libqmi implementation to avoid
relying on fixed-size stack buffers. We now rely on GByteArray to grow
the QmiMessage as we're adding more contents to the TLV. Note that
there won't be one realloc() per qmi_message_tlv_write_{something}()
call, as GByteArray does internally reallocs to the closest power-of-2
IIRC.
This work is in the 'aleksander/tlv-api' branch in upstream git.
This is WIP, but comments on the API are greatly appreciated. Relevant
commit is:
http://cgit.freedesktop.org/libqmi/commit/?h=aleksander/tlv-api&id=5b223047864b0ae0f423d33ea284df5b01eacb57
I'm also going to update the TLV reader API, and end up with all those
qmi_utils_read/write methods deprecated in the API.
--
Aleksander
https://aleksander.es
More information about the libqmi-devel
mailing list