LWiFi.cpp warning: passing NULL to non-pointer argument

Moderators: lily.li, violet, salmanfarisvp

Post Reply
matthew
Pre-kindergarten
Pre-kindergarten
Posts: 27
Joined: Mon Dec 29, 2014 2:11 pm

LWiFi.cpp warning: passing NULL to non-pointer argument

Post by matthew » Sun Jan 18, 2015 7:36 am

Compiling Wifi library V1.0.42 with Arduino 1.5.8beta gives the following warning

\arduino\arduino-1.5.8beta\hardware\arduino\mtk\libraries\LWiFi\LWiFi.cpp: In constructor 'LWiFiLoginInfo::LWiFiLoginInfo()':
\arduino\arduino-1.5.8beta\hardware\arduino\mtk\libraries\LWiFi\LWiFi.cpp:24:18: warning: passing NULL to non-pointer argument 1 of 'String::String(int, unsigned char)' [-Wconversion-null]
m_password(NULL)

this comes from the library code
LWiFiLoginInfo::LWiFiLoginInfo():
m_enc(LWIFI_OPEN),
m_password(NULL)
{
}

NOTE: the int LWiFiClass::connect(.. ) method has the line
strncpy((char*)context.apInfo.password, loginInfo.m_password.c_str(), VM_WLAN_PROF_PSWD_MAX_LEN);
which would try and apply .c_str() to a NULL object hence the warning appears to be valid

Changing the code to
LWiFiLoginInfo::LWiFiLoginInfo():
m_enc(LWIFI_OPEN),
m_password("")
{
}
removes the warning and the possible null pointer exception
Can this change be incorporated in the next release?

drbv27
Pre-kindergarten
Pre-kindergarten
Posts: 9
Joined: Wed Jan 21, 2015 12:46 am

Re: LWiFi.cpp warning: passing NULL to non-pointer argument

Post by drbv27 » Wed Jan 21, 2015 3:57 am

I have the same trouble...somebody can help us?
Diego Bonilla

matthew
Pre-kindergarten
Pre-kindergarten
Posts: 27
Joined: Mon Dec 29, 2014 2:11 pm

Re: LWiFi.cpp warning: passing NULL to non-pointer argument

Post by matthew » Tue Jan 27, 2015 1:01 pm

Just edit the code linkIt One in the library
... \arduino\arduino-1.5.8beta\hardware\arduino\mtk\libraries\LWiFi\LWiFi.cpp
to
LWiFiLoginInfo::LWiFiLoginInfo():
m_enc(LWIFI_OPEN),
m_password("")
{
}

and the problem goes away.

Post Reply