Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[beken-72xx] Free list returned by wlan_sta_scan_result() #226
[beken-72xx] Free list returned by wlan_sta_scan_result() #226
Changes from 3 commits
1485b26
b0c9190
a85c912
c119111
7910d09
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are Arduino APIs, we're not supposed to change the function signatures or behavior. As unfortunate as it is (the APIs are pretty badly designed IMHO), doing otherwise may cause undesired problems with compilation if the user's code uses these methods for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was afraid of something like that.
I do not see any description of the return value, but returning the previous count does not allow this method to indicate an error. And, correct me if i'm wrong, failure to allocate a memory should be quite common on systems like that, so it is important to know that and react (eg. by retrying or at least not writing to the memory area).
So, I would strongly suggest changing the API even risking breaking the user's code.
Alternatively, if it is only the method's signature that must remain the same, I suggest returning instead the count of items that we successfully allocated. Then the user can compare it to what was requested and judge by that. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, upon checking I see that there's no such method in ESP32 at all:
https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiScan.h
Sorry for the confusion. I must have taken the wifi library from somewhere else then, because I don't think I'd ever write a function with such a weird return value.
Of course, you're free to keep your changes in this case. This function could even be made private now - no other class is supposed to use it anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see this function always returns RTW_SUCCESS, even on error. Is this intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably; this is a scanning callback called by the SDK, I don't even think it cares about errors. So the return value is most likely meaningless, and returning an error code would likely cause some other problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just checked and it appears that you're right - the SDK completely ignores the value returned by this callback. So for the sake of consistency it's better to always return RTW_SUCCESS.