mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 23:28:29 +08:00
tools/nxstyle.c: Add logic to catch another formatting error and to eliminate some false alarms. Includes cosmetic changes to several files ... mostly as a result of testing nxstyle and finding issues.
This commit is contained in:
@@ -65,7 +65,6 @@
|
||||
struct net_stats_s g_netstats;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_NET_IPv4_REASSEMBLY
|
||||
/* Reassembly timer (units: deci-seconds) */
|
||||
|
||||
|
||||
+11
-11
@@ -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. */
|
||||
|
||||
|
||||
+11
-11
@@ -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. */
|
||||
|
||||
|
||||
+11
-11
@@ -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. */
|
||||
|
||||
|
||||
@@ -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. */
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
+14
-10
@@ -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
|
||||
|
||||
@@ -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
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+36
-36
@@ -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:
|
||||
|
||||
@@ -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 */
|
||||
{
|
||||
|
||||
@@ -87,7 +87,6 @@ void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr)
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_ipv6_txnotify
|
||||
*
|
||||
|
||||
+21
-7
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user