Open th-otto opened 1 month ago
Thanks for taking the time to make this PR @th-otto and apologies it took me a week to get to it. I was building out a test suite around it.
I don't think we should be adjusting the size to the boundary of the next entry. If you look at other SCSI commands that have lists of data, if the user requests a size less than the data, it always chops it off at the requested bytes. Likely due to the client app potentially only allocating a buffer of that size. The client app should know (and I'll document this) the size of the wifi_network_entry
and offset of the entries(2) in the data.
Edit: I'm re-thinking this after sleeping on it. Since it's a custom command we can do this and it does make more sense (why would you want a 1/2 a wifi ssid?!). If a BlueSCSI Toolbox app wants 1, 5, or all networks it'll need know the size anyways. It can call with len 2 to know how many are available if really required for saving memory.
I did take a look at @jcs code and whatever we do here should be backwards compatible as he has a of buffer, and requests 2048 bytes.
I think the check condition if size is less than 2 is probably good - you can get no usable info from just getting the first half of the entry size.
It was a good idea to unshadow the size var.
If you have time to make these adjustments, great! If you don't I can cherry pick it down and adjust and merge. Let me know!
See https://github.com/BlueSCSI/BlueSCSI-v2/issues/173