-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Added _t to a couple of the NVS typedefs (IDFGH-891) #3239
Conversation
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.
Thanks for thinking of us and sending this PR.
I'm going to ask @igrr to weigh in here, because I think he originally chose this name.
There are some complicating factors here:
- Technically,
typename_t
is reserved by POSIX for use by POSIX types only. Clearly, a large percentage of the world's C code violates this rule and we've violated this rule in many other parts of ESP-IDF. - Given that we've violated the rule elsewhere, it may be better that we're consistent and violate it here as well. Although I'm not sure about this, especially if we wanted to "do the right thing" in the future.
components/nvs_flash/include/nvs.h
Outdated
@@ -26,7 +26,7 @@ extern "C" { | |||
/** | |||
* Opaque pointer type representing non-volatile storage handle | |||
*/ | |||
typedef uint32_t nvs_handle; | |||
typedef uint32_t nvs_handle_t; |
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.
We probably don't want to break all existing projects' code which uses nvs_handle, so at minimum we would want another typedef here to maintain compatibility.
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.
Yep that's a good point, added back the original typedefs I replaced
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.
There seems to be more code in IDF which uses _t
suffix in typedefs than the code which doesn't, so we can probably stick to the "wrong" option. As long as the types are namespaced with an appropriate prefix, the risk of conflicting with a POSIX type should be low.
Agree that a typedef for compatibility with the existing code is needed.
Ah ok I didn't realise the |
Thanks for making those changes, @Frosticles . I've cherry-picked this into our internal review & merge queue, with one small additional small change (added a backwards-compatible nvs_openmode to go with nvs_openmode_t). This PR will be updated when it's merged. |
Just went through and added _t to some typedefs in nvs.h to match the convention. This mainly helps with syntax highlighting, vscode recognises _t as a typedef and highlights it