From cc31f22213991251c6262a912f5ffb48891f7134 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 21 Aug 2018 12:46:00 -0600 Subject: [PATCH] tools/nxstyle.c: Back out part of a recent addition that was causing too many false alarms. drivers/wireless/ieee80211: Make a couple of files conform to the coding standard (and other cosmetic fixes). --- drivers/wireless/ieee80211/bcmf_driver.c | 68 ++++++++++++------------ drivers/wireless/ieee80211/bcmf_netdev.c | 37 ++++--------- tools/nxstyle.c | 16 +----- 3 files changed, 46 insertions(+), 75 deletions(-) diff --git a/drivers/wireless/ieee80211/bcmf_driver.c b/drivers/wireless/ieee80211/bcmf_driver.c index 819bb6c604..3443a7b95b 100644 --- a/drivers/wireless/ieee80211/bcmf_driver.c +++ b/drivers/wireless/ieee80211/bcmf_driver.c @@ -80,7 +80,7 @@ /* Helper to get iw_event size */ #define BCMF_IW_EVENT_SIZE(field) \ - (offsetof(struct iw_event, u)+sizeof(((union iwreq_data*)0)->field)) + (offsetof(struct iw_event, u) + sizeof(((union iwreq_data *)0)->field)) /* Clm blob marcos */ @@ -135,7 +135,7 @@ static int bcmf_driver_initialize(FAR struct bcmf_dev_s *priv); static int bcmf_driver_download_clm(FAR struct bcmf_dev_s *priv); -// FIXME only for debug purpose +/* FIXME only for debug purpose */ static void bcmf_wl_default_event_handler(FAR struct bcmf_dev_s *priv, struct bcmf_event_s *event, unsigned int len); @@ -461,8 +461,6 @@ void bcmf_wl_default_event_handler(FAR struct bcmf_dev_s *priv, void bcmf_wl_radio_event_handler(FAR struct bcmf_dev_s *priv, struct bcmf_event_s *event, unsigned int len) { - // wlinfo("Got radio event %d from <%s>\n", bcmf_getle32(&event->type), - // event->src_name); } void bcmf_wl_auth_event_handler(FAR struct bcmf_dev_s *priv, @@ -578,7 +576,7 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, while (priv->scan_result_size - check_offset >= offsetof(struct iw_event, u)) { - iwe = (struct iw_event*)&priv->scan_result[check_offset]; + iwe = (struct iw_event *)&priv->scan_result[check_offset]; if (iwe->cmd == SIOCGIWAP) { @@ -604,7 +602,7 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, goto scan_result_full; } - iwe = (struct iw_event*)&priv->scan_result[priv->scan_result_size]; + iwe = (struct iw_event *)&priv->scan_result[priv->scan_result_size]; iwe->len = BCMF_IW_EVENT_SIZE(ap_addr); iwe->cmd = SIOCGIWAP; memcpy(&iwe->u.ap_addr.sa_data, bss->BSSID.ether_addr_octet, @@ -616,7 +614,7 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, /* Copy ESSID */ - essid_len = min(strlen((const char*)bss->SSID), 32); + essid_len = min(strlen((const char *)bss->SSID), 32); essid_len_aligned = (essid_len + 3) & -4; if (result_size < BCMF_IW_EVENT_SIZE(essid)+essid_len_aligned) @@ -624,7 +622,7 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, goto scan_result_full; } - iwe = (struct iw_event*)&priv->scan_result[priv->scan_result_size]; + iwe = (struct iw_event *)&priv->scan_result[priv->scan_result_size]; iwe->len = BCMF_IW_EVENT_SIZE(essid)+essid_len_aligned; iwe->cmd = SIOCGIWESSID; iwe->u.essid.flags = 0; @@ -632,7 +630,7 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, /* Special processing for iw_point, set offset in pointer field */ - iwe->u.essid.pointer = (FAR void*)sizeof(iwe->u.essid); + iwe->u.essid.pointer = (FAR void *)sizeof(iwe->u.essid); memcpy(&iwe->u.essid+1, bss->SSID, essid_len); priv->scan_result_size += BCMF_IW_EVENT_SIZE(essid)+essid_len_aligned; @@ -645,7 +643,7 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, goto scan_result_full; } - iwe = (struct iw_event*)&priv->scan_result[priv->scan_result_size]; + iwe = (struct iw_event *)&priv->scan_result[priv->scan_result_size]; iwe->len = BCMF_IW_EVENT_SIZE(qual); iwe->cmd = IWEVQUAL; iwe->u.qual.qual = bss->SNR; @@ -664,7 +662,7 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, goto scan_result_full; } - iwe = (struct iw_event*)&priv->scan_result[priv->scan_result_size]; + iwe = (struct iw_event *)&priv->scan_result[priv->scan_result_size]; iwe->len = BCMF_IW_EVENT_SIZE(mode); iwe->cmd = SIOCGIWMODE; if (bss->capability & DOT11_CAP_ESS) @@ -690,7 +688,7 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, goto scan_result_full; } - iwe = (struct iw_event*)&priv->scan_result[priv->scan_result_size]; + iwe = (struct iw_event *)&priv->scan_result[priv->scan_result_size]; iwe->len = BCMF_IW_EVENT_SIZE(data); iwe->cmd = SIOCGIWENCODE; iwe->u.data.flags = bss->capability & DOT11_CAP_PRIVACY ? @@ -711,7 +709,7 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, } ie_offset = 0; - ie_buffer = (uint8_t*)bss + bss->ie_offset; + ie_buffer = (uint8_t *)bss + bss->ie_offset; while (1) { @@ -720,6 +718,7 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, if (bss->ie_length - ie_offset < 2) { /* Minimum Information element size is 2 bytes */ + break; } @@ -728,6 +727,7 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, if (ie_frame_size > bss->ie_length - ie_offset) { /* Entry too big */ + break; } @@ -735,29 +735,29 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, { case IEEE80211_ELEMID_RSN: { - size_t ie_frame_size_aligned; - ie_frame_size_aligned = (ie_frame_size + 3) & -4; - wlinfo("found RSN\n"); - if (result_size < BCMF_IW_EVENT_SIZE(data) + ie_frame_size_aligned) - { - break; - } + size_t ie_frame_size_aligned; + ie_frame_size_aligned = (ie_frame_size + 3) & -4; - iwe = (struct iw_event*)&priv->scan_result[priv->scan_result_size]; - iwe->len = BCMF_IW_EVENT_SIZE(data)+ie_frame_size_aligned; - iwe->cmd = IWEVGENIE; - iwe->u.data.flags = 0; - iwe->u.data.length = ie_frame_size; - iwe->u.data.pointer = (FAR void*)sizeof(iwe->u.data); - memcpy(&iwe->u.data+1, &ie_buffer[ie_offset], ie_frame_size); + wlinfo("found RSN\n"); + if (result_size < BCMF_IW_EVENT_SIZE(data) + ie_frame_size_aligned) + { + break; + } - priv->scan_result_size += BCMF_IW_EVENT_SIZE(essid)+ie_frame_size_aligned; - result_size -= BCMF_IW_EVENT_SIZE(essid)+ie_frame_size_aligned; - break; + iwe = (struct iw_event *)&priv->scan_result[priv->scan_result_size]; + iwe->len = BCMF_IW_EVENT_SIZE(data)+ie_frame_size_aligned; + iwe->cmd = IWEVGENIE; + iwe->u.data.flags = 0; + iwe->u.data.length = ie_frame_size; + iwe->u.data.pointer = (FAR void *)sizeof(iwe->u.data); + memcpy(&iwe->u.data+1, &ie_buffer[ie_offset], ie_frame_size); + + priv->scan_result_size += BCMF_IW_EVENT_SIZE(essid)+ie_frame_size_aligned; + result_size -= BCMF_IW_EVENT_SIZE(essid)+ie_frame_size_aligned; + break; } + default: - // wlinfo("unhandled IE entry %d %d\n", ie_buffer[ie_offset], - // ie_buffer[ie_offset+1]); break; } @@ -817,6 +817,7 @@ void bcmf_wl_scan_timeout(int argc, wdparm_t arg1, ...) if (priv->scan_status < BCMF_SCAN_RUN) { /* Fatal error, invalid scan status */ + wlerr("Unexpected scan timeout\n"); return; } @@ -829,7 +830,8 @@ void bcmf_wl_scan_timeout(int argc, wdparm_t arg1, ...) int bcmf_wl_get_interface(FAR struct bcmf_dev_s *priv, struct iwreq *iwr) { - // TODO resolve interface using iwr->ifr_name + /* TODO resolve interface using iwr->ifr_name */ + return CHIP_STA_INTERFACE; } diff --git a/drivers/wireless/ieee80211/bcmf_netdev.c b/drivers/wireless/ieee80211/bcmf_netdev.c index 6dcf95ad34..55e5af64f5 100644 --- a/drivers/wireless/ieee80211/bcmf_netdev.c +++ b/drivers/wireless/ieee80211/bcmf_netdev.c @@ -79,7 +79,7 @@ # error Work queue support is required in this configuration (CONFIG_SCHED_WORKQUEUE) #else - /* Use the selected work queue */ + /* Use the selected work queue */ # if defined(CONFIG_IEEE80211_BROADCOM_HPWORK) # define BCMFWORK HPWORK @@ -280,8 +280,8 @@ static void bcmf_receive(FAR struct bcmf_dev_s *priv) */ uint8_t temp_buffer[12]; - memcpy( temp_buffer, frame->data, 12); - memcpy( frame->data + 4, temp_buffer, 12); + memcpy(temp_buffer, frame->data, 12); + memcpy(frame->data + 4, temp_buffer, 12); priv->bc_dev.d_buf = frame->data = frame->data + 4; priv->bc_dev.d_len -= 4; @@ -425,7 +425,8 @@ static void bcmf_receive(FAR struct bcmf_dev_s *priv) * devif_poll() may be called: * * 1. When the preceding TX packet send is complete, - * 2. When the preceding TX packet send timesout and the interface is reset + * 2. When the preceding TX packet send times out and the interface is + * reset * 3. During normal TX polling * * Input Parameters: @@ -444,7 +445,6 @@ static int bcmf_txpoll(FAR struct net_driver_s *dev) { FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; - wlinfo("Entry\n"); /* If the polling resulted in data that should be sent out on the network, * the field d_len is set to a value > 0. */ @@ -477,10 +477,10 @@ static int bcmf_txpoll(FAR struct net_driver_s *dev) bcmf_transmit(priv, priv->cur_tx_frame); - /* Check if there is room in the device to hold another packet. If not, - * return a non-zero value to terminate the poll. + /* TODO: Check if there is room in the device to hold another packet. + * If not, return a non-zero value to terminate the poll. */ - // TODO + priv->cur_tx_frame = NULL; return 1; } @@ -511,7 +511,6 @@ static int bcmf_txpoll(FAR struct net_driver_s *dev) static void bcmf_rxpoll(FAR void *arg) { - // wlinfo("Entry\n"); FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg; /* Lock the network and serialize driver operations if necessary. @@ -545,8 +544,6 @@ static void bcmf_rxpoll(FAR void *arg) void bcmf_netdev_notify_tx_done(FAR struct bcmf_dev_s *priv) { - // wlinfo("Entry\n"); - /* TODO TX buffer may be available, try to send again if needed */ } @@ -586,7 +583,6 @@ void bcmf_netdev_notify_rx(FAR struct bcmf_dev_s *priv) static void bcmf_poll_work(FAR void *arg) { - // wlinfo("Entry\n"); FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg; /* Lock the network and serialize driver operations if necessary. @@ -645,7 +641,6 @@ exit_unlock: static void bcmf_poll_expiry(int argc, wdparm_t arg, ...) { - // wlinfo("Entry\n"); FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg; /* Schedule to perform the interrupt processing on the worker thread. */ @@ -672,7 +667,6 @@ static void bcmf_poll_expiry(int argc, wdparm_t arg, ...) static int bcmf_ifup(FAR struct net_driver_s *dev) { - wlinfo("Entry\n"); FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 @@ -687,8 +681,6 @@ static int bcmf_ifup(FAR struct net_driver_s *dev) dev->d_ipv6addr[6], dev->d_ipv6addr[7]); #endif - /* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */ - /* Instantiate the MAC address from priv->bc_dev.d_mac.ether.ether_addr_octet */ #ifdef CONFIG_NET_ICMPv6 @@ -705,7 +697,6 @@ static int bcmf_ifup(FAR struct net_driver_s *dev) /* Enable the hardware interrupt */ priv->bc_bifup = true; - return OK; } @@ -727,7 +718,6 @@ static int bcmf_ifup(FAR struct net_driver_s *dev) static int bcmf_ifdown(FAR struct net_driver_s *dev) { - wlinfo("Entry\n"); FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; irqstate_t flags; @@ -773,8 +763,6 @@ static void bcmf_txavail_work(FAR void *arg) { FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg; - // wlinfo("Entry\n"); - /* Lock the network and serialize driver operations if necessary. * NOTE: Serialization is only required in the case where the driver work * is performed on an LP worker thread and where more than one LP worker @@ -864,7 +852,6 @@ static int bcmf_txavail(FAR struct net_driver_s *dev) #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) static int bcmf_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) { - wlinfo("Entry\n"); FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; /* Add the MAC address to the hardware multicast routing table */ @@ -894,7 +881,6 @@ static int bcmf_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) #ifdef CONFIG_NET_IGMP static int bcmf_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) { - wlinfo("Entry\n"); FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; /* Add the MAC address to the hardware multicast routing table */ @@ -922,7 +908,6 @@ static int bcmf_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) #ifdef CONFIG_NET_ICMPv6 static void bcmf_ipv6multicast(FAR struct bcmf_dev_s *priv) { - wlinfo("Entry\n"); FAR struct net_driver_s *dev; uint16_t tmp16; uint8_t mac[6]; @@ -963,7 +948,6 @@ static void bcmf_ipv6multicast(FAR struct bcmf_dev_s *priv) */ (void)bcmf_addmac(dev, g_ipv6_ethallnodes.ether_addr_octet); - #endif /* CONFIG_NET_ICMPv6_AUTOCONF */ #ifdef CONFIG_NET_ICMPv6_ROUTER @@ -973,7 +957,6 @@ static void bcmf_ipv6multicast(FAR struct bcmf_dev_s *priv) */ (void)bcmf_addmac(dev, g_ipv6_ethallrouters.ether_addr_octet); - #endif /* CONFIG_NET_ICMPv6_ROUTER */ } #endif /* CONFIG_NET_ICMPv6 */ @@ -1142,8 +1125,8 @@ int bcmf_netdev_register(FAR struct bcmf_dev_s *priv) /* Initialize network stack interface buffer */ - priv->cur_tx_frame = NULL; - priv->bc_dev.d_buf = NULL; + priv->cur_tx_frame = NULL; + priv->bc_dev.d_buf = NULL; /* Put the interface in the down state. This usually amounts to resetting * the device and/or calling bcmf_ifdown(). diff --git a/tools/nxstyle.c b/tools/nxstyle.c index 22dd7295ec..2a5c120f4b 100644 --- a/tools/nxstyle.c +++ b/tools/nxstyle.c @@ -75,7 +75,6 @@ int main(int argc, char **argv, char **envp) int n; int i; int last_oneline_comment; - int last_blank_line; int linelen; instream = fopen(argv[1], "r"); @@ -97,7 +96,6 @@ int main(int argc, char **argv, char **envp) prevncomment = 0; last_oneline_comment = -1; /* Line on which the last one line comment was * closed */ - last_blank_line = -1; /* lineno of last blank line */ while (fgets(line, LINE_SIZE, instream)) { @@ -111,11 +109,7 @@ int main(int argc, char **argv, char **envp) /* Check for a blank line */ - if (line[0] == '\n') - { - last_blank_line = lineno; - } - else /* this line is non-blank */ + if (line[0] != '\n') { if (lineno == last_oneline_comment + 1) { @@ -176,14 +170,6 @@ int main(int argc, char **argv, char **envp) if (line[indent] == '/' && line[indent +1] == '*' && lptr - line == linelen - 3) { - if (last_oneline_comment != lineno - 1 && - last_blank_line != lineno - 1) - { - fprintf(stderr, - "Missing blank line before comment found at line %d\n", - lineno); - } - last_oneline_comment = lineno; } }