Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero out MQTTProperty before reading #1498

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

fpagliughi
Copy link
Contributor

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).

@jumoog
Copy link
Contributor

jumoog commented Jul 4, 2024

How will this impact PAHO_HIGH_PERFORMANCE?

@fpagliughi
Copy link
Contributor Author

fpagliughi commented Jul 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants