ESP8266 Developer Zone The Official ESP8266 Forum 2016-10-10T21:51:24+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=2750 2016-10-10T21:51:24+08:00 2016-10-10T21:51:24+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2750&p=10108#p10108 <![CDATA[Re: os_bzero() detecting correct length issue]]> Statistics: Posted by eriksl — Mon Oct 10, 2016 9:51 pm


]]>
2016-09-14T17:42:25+08:00 2016-09-14T17:42:25+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2750&p=9826#p9826 <![CDATA[Re: os_bzero() detecting correct length issue]]> Rgds,
Frenk

Statistics: Posted by FrenkR — Wed Sep 14, 2016 5:42 pm


]]>
2016-09-12T21:40:07+08:00 2016-09-12T21:40:07+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2750&p=9795#p9795 <![CDATA[Re: os_bzero() detecting correct length issue]]>
The REAL issue here is, like often, that correct prototypes of SDK functions are simply missing. If the prototype had been there, the TS would have had an error from the compiler and would have know what was the issue.

Proper C language level support from Espressif has always been very lame. I'd really like a better job on this:
- missing lots of prototypes
- use of nonstandard int types (uint32) vs. standard types (uint32_t, stdint.h).
- lots of improper use of #define where an inline function or an enum would be the correct choice

Statistics: Posted by eriksl — Mon Sep 12, 2016 9:40 pm


]]>
2016-09-08T12:15:32+08:00 2016-09-08T12:15:32+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2750&p=9770#p9770 <![CDATA[Re: os_bzero() detecting correct length issue]]>
Being specific to os_bzero() or the standard GCC bzero(), it is not a very popular function. Has been marked as legacy by the current GCC standards and is not recommended. Also note that the function sets the initial n bytes of an array to '0' or NULL, when you call the function as follows: os_bzero (str, n);

Always specify the length n!
And if possible, please switch to os_memset. It will work much better and will always work with future SDK versions. :)

Statistics: Posted by Guest — Thu Sep 08, 2016 12:15 pm


]]>
2016-09-06T17:04:54+08:00 2016-09-06T17:04:54+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2750&p=9750#p9750 <![CDATA[os_bzero() detecting correct length issue]]> using SDK 2.0 with latest patch.
it seems that os_bzero() in some cases can't recognize correct structure length. I have following situation:

Code:

   struct station_config * confSTA;
   confSTA = (struct station_config *) os_zalloc(sizeof(struct station_config));
   
    wifi_station_get_config(confSTA);
   
   // os_bzero(confSTA->ssid); <-- if I use this one, then wifi_station_set_config() triggers wdt reset!
   os_bzero(confSTA->ssid, sizeof(confSTA->ssid)); // this one is working
   if (os_strlen(_userSettings->wifiSsid) > 0)
      os_sprintf(confSTA->ssid, "%s", _userSettings->wifiSsid);
      
   wifi_station_set_config(confSTA); // this function fails if os_bzero() has no length specified as a second argument
   os_free(confSTA);
      


Is there any rule of thumb when os_bzero() is safe to use or is in this case bug of wifi_station_set_config()?

Rdds,
Frenk

Statistics: Posted by FrenkR — Tue Sep 06, 2016 5:04 pm


]]>