diff --git a/net/devif/devif_initialize.c b/net/devif/devif_initialize.c index 40a14332603..864baa64b85 100644 --- a/net/devif/devif_initialize.c +++ b/net/devif/devif_initialize.c @@ -65,7 +65,6 @@ struct net_stats_s g_netstats; #endif - #ifdef CONFIG_NET_IPv4_REASSEMBLY /* Reassembly timer (units: deci-seconds) */ diff --git a/net/icmp/icmp_netpoll.c b/net/icmp/icmp_netpoll.c index 477f0b826c2..3df557448a6 100644 --- a/net/icmp/icmp_netpoll.c +++ b/net/icmp/icmp_netpoll.c @@ -109,18 +109,18 @@ static uint16_t icmp_poll_eventhandler(FAR struct net_driver_s *dev, if (info != NULL) { - /* Is this a response on the same device that we sent the request out - * on? - */ + /* Is this a response on the same device that we sent the request out + * on? + */ - psock = info->psock; - DEBUGASSERT(psock != NULL && psock->s_conn != NULL); - conn = psock->s_conn; - if (dev != conn->dev) - { - ninfo("Wrong device\n"); - return flags; - } + psock = info->psock; + DEBUGASSERT(psock != NULL && psock->s_conn != NULL); + conn = psock->s_conn; + if (dev != conn->dev) + { + ninfo("Wrong device\n"); + return flags; + } /* Check for data or connection availability events. */ diff --git a/net/icmp/icmp_recvfrom.c b/net/icmp/icmp_recvfrom.c index 0bd4c487a0d..fa9573cce05 100644 --- a/net/icmp/icmp_recvfrom.c +++ b/net/icmp/icmp_recvfrom.c @@ -169,18 +169,18 @@ static uint16_t recvfrom_eventhandler(FAR struct net_driver_s *dev, goto end_wait; } - /* Is this a response on the same device that we sent the request out - * on? - */ + /* Is this a response on the same device that we sent the request out + * on? + */ - psock = pstate->recv_sock; - DEBUGASSERT(psock != NULL && psock->s_conn != NULL); - conn = psock->s_conn; - if (dev != conn->dev) - { - ninfo("Wrong device\n"); - return flags; - } + psock = pstate->recv_sock; + DEBUGASSERT(psock != NULL && psock->s_conn != NULL); + conn = psock->s_conn; + if (dev != conn->dev) + { + ninfo("Wrong device\n"); + return flags; + } /* Check if we have just received a ICMP ECHO reply. */ diff --git a/net/icmpv6/icmpv6_netpoll.c b/net/icmpv6/icmpv6_netpoll.c index 3ec551a61ce..55b3e2f89d3 100644 --- a/net/icmpv6/icmpv6_netpoll.c +++ b/net/icmpv6/icmpv6_netpoll.c @@ -109,18 +109,18 @@ static uint16_t icmpv6_poll_eventhandler(FAR struct net_driver_s *dev, if (info != NULL) { - /* Is this a response on the same device that we sent the request out - * on? - */ + /* Is this a response on the same device that we sent the request out + * on? + */ - psock = info->psock; - DEBUGASSERT(psock != NULL && psock->s_conn != NULL); - conn = psock->s_conn; - if (dev != conn->dev) - { - ninfo("Wrong device\n"); - return flags; - } + psock = info->psock; + DEBUGASSERT(psock != NULL && psock->s_conn != NULL); + conn = psock->s_conn; + if (dev != conn->dev) + { + ninfo("Wrong device\n"); + return flags; + } /* Check for data or connection availability events. */ diff --git a/net/icmpv6/icmpv6_recvfrom.c b/net/icmpv6/icmpv6_recvfrom.c index bf943a4f27c..4456ed86340 100644 --- a/net/icmpv6/icmpv6_recvfrom.c +++ b/net/icmpv6/icmpv6_recvfrom.c @@ -172,18 +172,18 @@ static uint16_t recvfrom_eventhandler(FAR struct net_driver_s *dev, goto end_wait; } - /* Is this a response on the same device that we sent the request out - * on? - */ + /* Is this a response on the same device that we sent the request out + * on? + */ - psock = pstate->recv_sock; - DEBUGASSERT(psock != NULL && psock->s_conn != NULL); - conn = psock->s_conn; - if (dev != conn->dev) - { - ninfo("Wrong device\n"); - return flags; - } + psock = pstate->recv_sock; + DEBUGASSERT(psock != NULL && psock->s_conn != NULL); + conn = psock->s_conn; + if (dev != conn->dev) + { + ninfo("Wrong device\n"); + return flags; + } /* Check if we have just received a ICMPv6 ECHO reply. */ diff --git a/net/ieee802154/ieee802154_input.c b/net/ieee802154/ieee802154_input.c index be5f535344f..3207cee9267 100644 --- a/net/ieee802154/ieee802154_input.c +++ b/net/ieee802154/ieee802154_input.c @@ -150,9 +150,9 @@ static int ieee802154_queue_frame(FAR struct ieee802154_conn_s *conn, } #if CONFIG_NET_IEEE802154_BACKLOG > 0 - /* If incrementing the count would exceed the maximum backlog value, then - * delete the oldest frame from the head of the RX queue. - */ + /* If incrementing the count would exceed the maximum backlog value, then + * delete the oldest frame from the head of the RX queue. + */ if (conn->backlog >= CONFIG_NET_IEEE802154_BACKLOG) { diff --git a/net/ieee802154/ieee802154_sockif.c b/net/ieee802154/ieee802154_sockif.c index 525ef32b100..e3723a9093c 100644 --- a/net/ieee802154/ieee802154_sockif.c +++ b/net/ieee802154/ieee802154_sockif.c @@ -674,7 +674,7 @@ static ssize_t ieee802154_send(FAR struct socket *psock, FAR const void *buf, { /* send() may be used only if the socket has been connected. */ - if (!_SS_ISCONNECTED( psock->s_flags) || + if (!_SS_ISCONNECTED(psock->s_flags) || conn->raddr.s_mode == IEEE802154_ADDRMODE_NONE) { ret = -ENOTCONN; diff --git a/net/netdev/netdev.h b/net/netdev/netdev.h index 210bd4f40dd..d79e3f3a05f 100644 --- a/net/netdev/netdev.h +++ b/net/netdev/netdev.h @@ -189,10 +189,11 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg); * (since a "down" device has no meaningful address). * * Input Parameters: - * lipaddr - Local, IPv4 address of assigned to the device + * lipaddr - Local, IPv4 address assigned to the network device. Or any + * IPv4 address on the sub-net served by the network device. * * Returned Value: - * Pointer to driver on success; null on failure + * Pointer to driver on success; null on failure * ****************************************************************************/ @@ -209,10 +210,11 @@ FAR struct net_driver_s *netdev_findby_lipv4addr(in_addr_t lipaddr); * (since a "down" device has no meaningful address). * * Input Parameters: - * lipaddr - Local, IPv6 address of assigned to the device + * lipaddr - Local, IPv6 address assigned to the network device. Or any + * IPv6 address on the sub-net served by the network device. * * Returned Value: - * Pointer to driver on success; null on failure + * Pointer to driver on success; null on failure * ****************************************************************************/ @@ -228,11 +230,12 @@ FAR struct net_driver_s *netdev_findby_lipv6addr(const net_ipv6addr_t lipaddr); * IPv4 address that can be reached by the device. * * Input Parameters: - * lipaddr - Local, bound address of a connection. + * lipaddr - Local, bound address of a connection (used only if ripaddr is + * the broadcast address). * ripaddr - Remote address of a connection to use in the lookup * * Returned Value: - * Pointer to driver on success; null on failure + * Pointer to driver on success; null on failure * ****************************************************************************/ @@ -249,11 +252,12 @@ FAR struct net_driver_s *netdev_findby_ripv4addr(in_addr_t lipaddr, * IPv6 address that can be reached by the device. * * Input Parameters: - * lipaddr - Local, bound address of a connection. + * lipaddr - Local, bound address of a connection (used only if ripaddr is + * a multicast address). * ripaddr - Remote address of a connection to use in the lookup * * Returned Value: - * Pointer to driver on success; null on failure + * Pointer to driver on success; null on failure * ****************************************************************************/ @@ -451,7 +455,7 @@ int netdev_count(void); * Name: netdev_ipv4_ifconf * * Description: - * Return the IPv4 configuration of each network adaptor + * Return the IPv4 configuration of each network adapter * * Input Parameters: * ifc - A reference to the instance of struct ifconf in which to return @@ -475,7 +479,7 @@ int netdev_ipv4_ifconf(FAR struct ifconf *ifc); * Name: netdev_ipv6_ifconf * * Description: - * Return the IPv6 configuration of each network adaptor + * Return the IPv6 configuration of each network adapter * * Input Parameters: * lifc - A reference to the instance of struct lifconf in which to return diff --git a/net/netdev/netdev_findbyaddr.c b/net/netdev/netdev_findbyaddr.c index 0500a2b3a7a..2fa99c68b65 100644 --- a/net/netdev/netdev_findbyaddr.c +++ b/net/netdev/netdev_findbyaddr.c @@ -70,10 +70,11 @@ * (since a "down" device has no meaningful address). * * Input Parameters: - * lipaddr - Local, IPv4 address of assigned to the device + * lipaddr - Local, IPv4 address assigned to the network device. Or any + * IPv4 address on the sub-net served by the network device. * * Returned Value: - * Pointer to driver on success; null on failure + * Pointer to driver on success; null on failure * ****************************************************************************/ @@ -120,10 +121,11 @@ FAR struct net_driver_s *netdev_findby_lipv4addr(in_addr_t lipaddr) * (since a "down" device has no meaningful address). * * Input Parameters: - * lipaddr - Local, IPv6 address of assigned to the device + * lipaddr - Local, IPv6 address assigned to the network device. Or any + * IPv6 address on the sub-net served by the network device. * * Returned Value: - * Pointer to driver on success; null on failure + * Pointer to driver on success; null on failure * ****************************************************************************/ @@ -169,11 +171,12 @@ FAR struct net_driver_s *netdev_findby_lipv6addr(const net_ipv6addr_t lipaddr) * IPv4 address that can be reached by the device. * * Input Parameters: - * lipaddr - Local, bound address of a connection. + * lipaddr - Local, bound address of a connection (used only if ripaddr is + * the broadcast address). * ripaddr - Remote address of a connection to use in the lookup * * Returned Value: - * Pointer to driver on success; null on failure + * Pointer to driver on success; null on failure * ****************************************************************************/ @@ -258,11 +261,12 @@ FAR struct net_driver_s *netdev_findby_ripv4addr(in_addr_t lipaddr, * IPv6 address that can be reached by the device. * * Input Parameters: - * lipaddr - Local, bound address of a connection. + * lipaddr - Local, bound address of a connection (used only if ripaddr is + * a multicast address). * ripaddr - Remote address of a connection to use in the lookup * * Returned Value: - * Pointer to driver on success; null on failure + * Pointer to driver on success; null on failure * ****************************************************************************/ diff --git a/net/netdev/netdev_findbyindex.c b/net/netdev/netdev_findbyindex.c index 7949890ce07..293d8c36a43 100644 --- a/net/netdev/netdev_findbyindex.c +++ b/net/netdev/netdev_findbyindex.c @@ -161,12 +161,12 @@ int netdev_nextindex(int ifindex) { if ((g_devset & (1L << ifindex)) != 0) { - /* NOTE that the index + 1 is returned. Zero is reserved to - * mean no-index in the POSIX standards. - */ + /* NOTE that the index + 1 is returned. Zero is reserved to + * mean no-index in the POSIX standards. + */ - net_unlock(); - return ifindex + 1; + net_unlock(); + return ifindex + 1; } } diff --git a/net/netdev/netdev_ifconf.c b/net/netdev/netdev_ifconf.c index 469974256c5..b6e8c248a36 100644 --- a/net/netdev/netdev_ifconf.c +++ b/net/netdev/netdev_ifconf.c @@ -102,7 +102,7 @@ static int ifconf_ipv4_callback(FAR struct net_driver_s *dev, FAR void *arg) DEBUGASSERT(dev != NULL && info != NULL && info->ifc != NULL); ifc = info->ifc; - /* Check if this adaptor has an IPv4 address assigned and is in the UP + /* Check if this adapter has an IPv4 address assigned and is in the UP * state. */ @@ -124,25 +124,25 @@ static int ifconf_ipv4_callback(FAR struct net_driver_s *dev, FAR void *arg) * cases. */ - if (ifc->ifc_len + sizeof(struct ifreq) <= info->bufsize) - { - FAR struct ifreq *req = - (FAR struct ifreq *)&ifc->ifc_buf[ifc->ifc_len]; - FAR struct sockaddr_in *inaddr = - (FAR struct sockaddr_in *)&req->ifr_addr; + if (ifc->ifc_len + sizeof(struct ifreq) <= info->bufsize) + { + FAR struct ifreq *req = + (FAR struct ifreq *)&ifc->ifc_buf[ifc->ifc_len]; + FAR struct sockaddr_in *inaddr = + (FAR struct sockaddr_in *)&req->ifr_addr; - /* There is space for information about another adaptor. Within - * each ifreq structure, ifr_name will receive the interface name - * and ifr_addr the address. The actual number of bytes - * transferred is returned in ifc_len. - */ + /* There is space for information about another adapter. Within + * each ifreq structure, ifr_name will receive the interface name + * and ifr_addr the address. The actual number of bytes + * transferred is returned in ifc_len. + */ - strncpy(req->ifr_name, dev->d_ifname, IFNAMSIZ); + strncpy(req->ifr_name, dev->d_ifname, IFNAMSIZ); - inaddr->sin_family = AF_INET; - inaddr->sin_port = 0; - net_ipv4addr_copy(inaddr->sin_addr.s_addr, dev->d_ipaddr); - } + inaddr->sin_family = AF_INET; + inaddr->sin_port = 0; + net_ipv4addr_copy(inaddr->sin_addr.s_addr, dev->d_ipaddr); + } /* Increment the size of the buffer in any event */ @@ -179,7 +179,7 @@ static int ifconf_ipv6_callback(FAR struct net_driver_s *dev, FAR void *arg) DEBUGASSERT(dev != NULL && info != NULL && info->lifc != NULL); lifc = info->lifc; - /* Check if this adaptor has an IPv6 address assigned and is in the UP + /* Check if this adapter has an IPv6 address assigned and is in the UP * state. */ @@ -201,25 +201,25 @@ static int ifconf_ipv6_callback(FAR struct net_driver_s *dev, FAR void *arg) * cases. */ - if (lifc->lifc_len + sizeof(struct lifreq) <= info->bufsize) - { - FAR struct lifreq *req = - (FAR struct lifreq *)&lifc->lifc_buf[lifc->lifc_len]; - FAR struct sockaddr_in6 *inaddr = - (FAR struct sockaddr_in6 *)&req->lifr_addr; + if (lifc->lifc_len + sizeof(struct lifreq) <= info->bufsize) + { + FAR struct lifreq *req = + (FAR struct lifreq *)&lifc->lifc_buf[lifc->lifc_len]; + FAR struct sockaddr_in6 *inaddr = + (FAR struct sockaddr_in6 *)&req->lifr_addr; - /* There is space for information about another adaptor. Within - * each ifreq structure, lifr_name will receive the interface - * name and lifr_addr the address. The actual number of bytes - * transferred is returned in lifc_len. - */ + /* There is space for information about another adapter. Within + * each ifreq structure, lifr_name will receive the interface + * name and lifr_addr the address. The actual number of bytes + * transferred is returned in lifc_len. + */ - strncpy(req->lifr_name, dev->d_ifname, IFNAMSIZ); + strncpy(req->lifr_name, dev->d_ifname, IFNAMSIZ); - inaddr->sin6_family = AF_INET6; - inaddr->sin6_port = 0; - net_ipv6addr_copy(inaddr->sin6_addr.s6_addr16, dev->d_ipv6addr); - } + inaddr->sin6_family = AF_INET6; + inaddr->sin6_port = 0; + net_ipv6addr_copy(inaddr->sin6_addr.s6_addr16, dev->d_ipv6addr); + } /* Increment the size of the buffer in any event */ @@ -238,7 +238,7 @@ static int ifconf_ipv6_callback(FAR struct net_driver_s *dev, FAR void *arg) * Name: netdev_ipv4_ifconf * * Description: - * Return the IPv4 configuration of each network adaptor that (1) has + * Return the IPv4 configuration of each network adapter that (1) has * and IPv4 address assigned and (2) is in the UP state * * Input Parameters: @@ -271,7 +271,7 @@ int netdev_ipv4_ifconf(FAR struct ifconf *ifc) * Name: netdev_ipv6_ifconf * * Description: - * Return the IPv6 configuration of each network adaptor that (1) has + * Return the IPv6 configuration of each network adapter that (1) has * and IPv6 address assigned and (2) is in the UP state. * * Input Parameters: diff --git a/net/netdev/netdev_ioctl.c b/net/netdev/netdev_ioctl.c index 36efe4b6b83..4cd26fb79d3 100644 --- a/net/netdev/netdev_ioctl.c +++ b/net/netdev/netdev_ioctl.c @@ -95,6 +95,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* Configuration */ #undef HAVE_WRITABLE_IPv4ROUTE @@ -695,7 +696,6 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd, break; #endif - #ifdef CONFIG_NET_IPv4 case SIOCSIFADDR: /* Set IP address */ { diff --git a/net/netdev/netdev_txnotify.c b/net/netdev/netdev_txnotify.c index 66a1495f22d..bcb5cab6443 100644 --- a/net/netdev/netdev_txnotify.c +++ b/net/netdev/netdev_txnotify.c @@ -87,7 +87,6 @@ void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr) } #endif /* CONFIG_NET_IPv4 */ - /**************************************************************************** * Name: netdev_ipv6_txnotify * diff --git a/tools/nxstyle.c b/tools/nxstyle.c index 39671de8f22..63c203c70c1 100644 --- a/tools/nxstyle.c +++ b/tools/nxstyle.c @@ -112,8 +112,18 @@ int main(int argc, char **argv, char **envp) /* Check for a blank line */ - if (line[0] == '\n') + for (n = 0; line[n] != '\n' && isspace((int)line[n]); n++) { + } + + if (line[n] == '\n') + { + if (n > 0) + { + fprintf(stderr, "Blank line contains whitespace at line %d\n", + lineno); + } + if (lineno == blank_lineno + 1) { fprintf(stderr, "Too many blank lines at line %d\n", lineno); @@ -123,16 +133,20 @@ int main(int argc, char **argv, char **envp) } else /* this line is non-blank */ { + /* Check for a missing blank line after a comment */ + if (lineno == comment_lineno + 1) { - /* TODO: This generates a false alarm if the current line - * contains a right brace or a pre-processor line. No blank line - * should be present in those cases. + /* No blank line should be present if the current line contains + * a right brace or a pre-processor line. */ - fprintf(stderr, - "Missing blank line after comment line. Found at line %d\n", - comment_lineno); + if (line[n] != '}' && line[n] != '#') + { + fprintf(stderr, + "Missing blank line after comment line. Found at line %d\n", + comment_lineno); + } } }