drivers/wireless/gs2200m: Fix compiler warning

wireless/gs2200m.c: In function 'gs2200m_send_cmd':
Error: wireless/gs2200m.c:1555:32: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
 1555 |       memset(pkt_dat, 0, sizeof(pkt_dat));
      |                                ^
Error: wireless/gs2200m.c:1570:36: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
 1570 |           memset(pkt_dat, 0, sizeof(pkt_dat));
      |                                    ^
wireless/gs2200m.c: In function 'gs2200m_ioctl':
Error: wireless/gs2200m.c:318:25: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=]
  318 |   snprintf(str, 5, "%04d", num);
      |                         ^
wireless/gs2200m.c:318:3: note: 'snprintf' output between 5 and 6 bytes into a destination of size 5
  318 |   snprintf(str, 5, "%04d", num);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-03-06 18:17:05 +08:00 committed by Petro Karashchenko
parent 366e2d5f64
commit 98976176e1

View File

@ -315,7 +315,7 @@ static uint8_t _cid_to_uint8(char c)
static void _to_ascii_char(uint16_t num, char *str)
{
DEBUGASSERT(num <= 2032); /* See Table 20 */
snprintf(str, 5, "%04d", num);
snprintf(str, 6, "%04d", num);
}
/****************************************************************************
@ -1552,7 +1552,7 @@ retry_recv:
/* release & initialize pkt_dat before retry */
_release_pkt_dat(dev, pkt_dat);
memset(pkt_dat, 0, sizeof(pkt_dat));
memset(pkt_dat, 0, sizeof(*pkt_dat));
bulk = true;
goto retry_recv;
@ -1567,7 +1567,7 @@ retry_recv:
/* release & initialize pkt_dat before retry */
_release_pkt_dat(dev, pkt_dat);
memset(pkt_dat, 0, sizeof(pkt_dat));
memset(pkt_dat, 0, sizeof(*pkt_dat));
}
wlwarn("*** retry cmd=%s (n=%d)\n", cmd, n);
@ -1639,7 +1639,7 @@ static enum pkt_type_e gs2200m_set_opmode(FAR struct gs2200m_dev_s *dev,
static enum pkt_type_e gs2200m_get_mac(FAR struct gs2200m_dev_s *dev)
{
struct pkt_dat_s pkt_dat;
enum pkt_type_e r;
enum pkt_type_e r;
uint32_t mac[6];
char cmd[16];
int n;
@ -1731,7 +1731,7 @@ static enum pkt_type_e gs2200m_join_network(FAR struct gs2200m_dev_s *dev,
FAR char *ssid, uint8_t ch)
{
struct pkt_dat_s pkt_dat;
enum pkt_type_e r;
enum pkt_type_e r;
char cmd[64];
char addr[3][17];
int n;
@ -1864,7 +1864,7 @@ static enum pkt_type_e gs2200m_set_wpa2pf(FAR struct gs2200m_dev_s *dev,
enum pkt_type_e gs2200m_get_wstatus(FAR struct gs2200m_dev_s *dev)
{
struct pkt_dat_s pkt_dat;
enum pkt_type_e r;
enum pkt_type_e r;
int i;
/* Initialize pkt_dat and send command */
@ -1897,8 +1897,8 @@ gs2200m_create_clnt(FAR struct gs2200m_dev_s *dev,
FAR struct gs2200m_connect_msg *msg,
FAR char *cid)
{
enum pkt_type_e r;
struct pkt_dat_s pkt_dat;
enum pkt_type_e r;
char cmd[40];
char *p;
int n;
@ -1962,8 +1962,8 @@ static enum pkt_type_e gs2200m_start_server(FAR struct gs2200m_dev_s *dev,
FAR char *port, bool is_tcp,
FAR char *cid)
{
enum pkt_type_e r;
struct pkt_dat_s pkt_dat;
enum pkt_type_e r;
char cmd[40];
char *p;
int n;
@ -2009,10 +2009,10 @@ errout:
static enum pkt_type_e gs2200m_send_bulk(FAR struct gs2200m_dev_s *dev,
FAR struct gs2200m_send_msg *msg)
{
enum pkt_type_e r;
enum spi_status_e s;
enum pkt_type_e r;
int bulk_hdr_size;
char digits[5];
char digits[6];
char cmd[32];
memset(cmd, 0, sizeof(cmd));
@ -2182,7 +2182,7 @@ static enum pkt_type_e gs2200m_get_cstatus(FAR struct gs2200m_dev_s *dev,
FAR struct gs2200m_name_msg *msg)
{
struct pkt_dat_s pkt_dat;
enum pkt_type_e r;
enum pkt_type_e r;
char cmd[16];
int i;
@ -2768,7 +2768,7 @@ static int gs2200m_ioctl_iwreq(FAR struct gs2200m_dev_s *dev,
{
struct iwreq *res = (struct iwreq *)&msg->ifr;
struct pkt_dat_s pkt_dat;
enum pkt_type_e r;
enum pkt_type_e r;
char cmd[64];
char cmd2[64];
int n = 0;