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

EEPROM class is throwing a warning: converting to non-pointer type 'nvs_handle {aka unsigned int}' from NULL #3142

Closed
CircuitSetup opened this issue Aug 27, 2019 · 10 comments · Fixed by #3246

Comments

@CircuitSetup
Copy link

Hardware:

Board: ESP32 Dev Module
Core Installation version: 1.0.3-rc2
IDE name: Arduino IDE
Flash Frequency: 40Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 10

Description:

The constructor for the EEPROM class is throwing a warning when compiling:

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.3-rc2\libraries\EEPROM\src\EEPROM.cpp: In constructor 'EEPROMClass::EEPROMClass()':

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.3-rc2\libraries\EEPROM\src\EEPROM.cpp:37:25: warning: converting to non-pointer type 'nvs_handle {aka unsigned int}' from NULL [-Wconversion-null]

   , _user_defined_size(0)

                         ^

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.3-rc2\libraries\EEPROM\src\EEPROM.cpp: In constructor 'EEPROMClass::EEPROMClass(uint32_t)':

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.3-rc2\libraries\EEPROM\src\EEPROM.cpp:48:25: warning: converting to non-pointer type 'nvs_handle {aka unsigned int}' from NULL [-Wconversion-null]

   , _user_defined_size(0)

                         ^

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.3-rc2\libraries\EEPROM\src\EEPROM.cpp: In constructor 'EEPROMClass::EEPROMClass(const char*, uint32_t)':

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.3-rc2\libraries\EEPROM\src\EEPROM.cpp:58:41: warning: converting to non-pointer type 'nvs_handle {aka unsigned int}' from NULL [-Wconversion-null]

   , _user_defined_size(user_defined_size)
@lbernstone
Copy link
Contributor

Works correctly, just throwing the warning?

@CircuitSetup
Copy link
Author

CircuitSetup commented Aug 29, 2019

I havent tested all of the functions. Writing and getting data to EEPROM seems to be working properly.

@C47D
Copy link

C47D commented Sep 1, 2019

Just tried to replicate this with the eeprom_class.ino example and I am not getting any warnings. I have enabled all the warnings on the Preferences menu.

imagen

Mind sharing your test code?

@CircuitSetup
Copy link
Author

Thanks for checking! The EEPROM functions I'm using are located here: https://github.com/CircuitSetup/Split-Single-Phase-Energy-Meter/blob/master/Software/EmonESP/src/config.cpp

I wouldn't doubt if it's something simple that I'm missing since nothing was changed between 1.0.2 to 1.0.3 rc2

@lbernstone
Copy link
Contributor

lbernstone commented Sep 1, 2019

Oh, it definitely is an issue. I will fix it, just don't have time to test right now. It will make it into the 1.0.4 release.

@CircuitSetup
Copy link
Author

Oh, it definitely is an issue. I will fix it, just don't have time to test right now. It will make it into the 1.0.4 release.

What specifically would this be affecting?

@lbernstone
Copy link
Contributor

It will make the message go away. As mentioned in the message, it is a warning.

@C47D
Copy link

C47D commented Sep 2, 2019

@CircuitSetup, thanks for the link, I will take a look at it and use the 1.0.3 rc2 branch, I test it only with the 1.0.2 stable.

@lbernstone, cool, I was planning to try to understand the issue and fix it.

I am more familiar with C code, so, is the issue because of the initializer list on the EEPROM constructor? The 0 should have a UL at the end to let the compiler know to treat the 0 as an uint32_t value?

@lbernstone
Copy link
Contributor

It says exactly what the issue is, even though it points to the wrong line of code. I am treating nvs_handle like a pointer, but it is a uint32_t, which should not be set to NULL.

@C47D
Copy link

C47D commented Sep 2, 2019

Silly me, i was looking at _user_defined_size all the time, it points to the wrong line of code indeed.

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 a pull request may close this issue.

3 participants