paho.mqtt.c icon indicating copy to clipboard operation
paho.mqtt.c copied to clipboard

Zero out MQTTProperty before reading

Open fpagliughi opened this issue 1 year ago • 2 comments

This is a small nit...

It would be nice to zero out the MQTTProperty union/value before reading fields into it. That would leave any unused space predictably set to zero.

On advantage is that if you accidentally read an 8 or 16-bit value out using a larger field size (i.e. read as a u32) you still get the correct numeric value.

(Wonder what made me think to do this).

fpagliughi avatar Jul 03 '24 23:07 fpagliughi

How will this impact PAHO_HIGH_PERFORMANCE?

jumoog avatar Jul 04 '24 07:07 jumoog

It is just an unconditional zero of memory for a tiny (~40byte) data struct. The performance hit in the overall read function is minimal, and that is overall likely undetectable in the overall read of a packet.

Though I definitely want to start giving a closer look to the performance characteristics of this library, we will need to look more at thread synchronization and things like that.

fpagliughi avatar Jul 04 '24 14:07 fpagliughi