This is an automated email from the ASF dual-hosted git repository. gnutt pushed a commit to branch SocketCAN in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit ca3925b077d862e4da9dd0a3740c25288c0ff155 Author: Jari van Ewijk <jari.vanew...@nxp.com> AuthorDate: Mon Mar 16 09:03:03 2020 +0100 Code style fixes 4 --- include/nuttx/net/net.h | 17 +++++--- net/can/can_setsockopt.c | 40 +++++++++++------- net/devif/devif.h | 87 ++++++++++++++++++++------------------ net/devif/devif_poll.c | 37 +++++++++------- net/icmp/icmp_sockif.c | 14 +++--- net/icmpv6/icmpv6_sockif.c | 28 ++++++------ net/ieee802154/ieee802154_sockif.c | 47 +++++++++++--------- net/inet/inet_sockif.c | 18 +++++--- net/local/local_sockif.c | 8 ++-- net/netdev/netdev_register.c | 6 +-- net/netlink/netlink_sockif.c | 15 +++++++ net/socket/getsockopt.c | 3 +- net/socket/recvmsg.c | 44 ++++++++++--------- net/socket/sendmsg.c | 43 ++++++++++--------- net/socket/setsockopt.c | 14 +++--- 15 files changed, 242 insertions(+), 179 deletions(-) diff --git a/include/nuttx/net/net.h b/include/nuttx/net/net.h index 1c661b1..52e15de 100644 --- a/include/nuttx/net/net.h +++ b/include/nuttx/net/net.h @@ -212,9 +212,11 @@ struct sock_intf_s CODE ssize_t (*si_recvfrom)(FAR struct socket *psock, FAR void *buf, size_t len, int flags, FAR struct sockaddr *from, FAR socklen_t *fromlen); -#ifdef CONFIG_NET_RECVMSG_CMSG +#ifdef CONFIG_NET_CMSG CODE ssize_t (*si_recvmsg)(FAR struct socket *psock, - FAR struct msghdr *msg, int flags); + FAR struct msghdr *msg, int flags); + CODE ssize_t (*si_sendmsg)(FAR struct socket *psock, + FAR struct msghdr *msg, int flags); #endif CODE int (*si_close)(FAR struct socket *psock); #ifdef CONFIG_NET_USRSOCK @@ -504,9 +506,9 @@ FAR struct iob_s *net_ioballoc(bool throttled, enum iob_user_e consumerid); * Description: * Check if the socket descriptor is valid for the provided TCB and if it * supports the requested access. This trivial operation is part of the - * fdopen() operation when the fdopen() is performed on a socket descriptor. - * It simply performs some sanity checking before permitting the socket - * descriptor to be wrapped as a C FILE stream. + * fdopen() operation when the fdopen() is performed on a socket + * descriptor. It simply performs some sanity checking before permitting + * the socket descriptor to be wrapped as a C FILE stream. * ****************************************************************************/ @@ -739,7 +741,8 @@ int psock_listen(FAR struct socket *psock, int backlog); * Input Parameters: * psock Reference to the listening socket structure * addr Receives the address of the connecting client - * addrlen Input: allocated size of 'addr', Return: returned size of 'addr' + * addrlen Input: allocated size of 'addr', + * Return: returned size of 'addr' * newsock Location to return the accepted socket information. * * Returned Value: @@ -1563,7 +1566,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap); * * Input Parameters: * dev - The device driver structure to be registered. - * lltype - Link level protocol used by the driver (Ethernet, SLIP, TUN, ... + * lltype - Link level protocol used by driver (Ethernet, SLIP, TUN, ... * * Returned Value: * 0:Success; negated errno on failure diff --git a/net/can/can_setsockopt.c b/net/can/can_setsockopt.c index ac9f912..3359e40 100644 --- a/net/can/can_setsockopt.c +++ b/net/can/can_setsockopt.c @@ -121,40 +121,48 @@ int can_setsockopt(FAR struct socket *psock, int option, break; case CAN_RAW_LOOPBACK: - if (value_len != sizeof(conn->loopback)) - return -EINVAL; + if (value_len != sizeof(conn->loopback)) + { + return -EINVAL; + } - conn->loopback = *(FAR int32_t *)value; + conn->loopback = *(FAR int32_t *)value; - break; + break; case CAN_RAW_RECV_OWN_MSGS: - if (value_len != sizeof(conn->recv_own_msgs)) - return -EINVAL; + if (value_len != sizeof(conn->recv_own_msgs)) + { + return -EINVAL; + } - conn->recv_own_msgs = *(FAR int32_t *)value; + conn->recv_own_msgs = *(FAR int32_t *)value; - break; + break; case CAN_RAW_FD_FRAMES: - if (value_len != sizeof(conn->fd_frames)) - return -EINVAL; + if (value_len != sizeof(conn->fd_frames)) + { + return -EINVAL; + } - conn->fd_frames = *(FAR int32_t *)value; + conn->fd_frames = *(FAR int32_t *)value; - break; + break; case CAN_RAW_JOIN_FILTERS: break; #ifdef CONFIG_NET_CAN_RAW_TX_DEADLINE case CAN_RAW_TX_DEADLINE: - if (value_len != sizeof(conn->tx_deadline)) - return -EINVAL; + if (value_len != sizeof(conn->tx_deadline)) + { + return -EINVAL; + } - conn->tx_deadline = *(FAR int32_t *)value; + conn->tx_deadline = *(FAR int32_t *)value; - break; + break; #endif default: diff --git a/net/devif/devif.h b/net/devif/devif.h index f924ebc..1a95011 100644 --- a/net/devif/devif.h +++ b/net/devif/devif.h @@ -68,31 +68,32 @@ * * TCP_ACKDATA IN: Signifies that the outstanding data was ACKed and * the socket layer should send out new data instead - * of retransmitting the last data (TCP only) + * of retransmitting the last data. (TCP only) * OUT: Input state must be preserved on output. * * TCP_NEWDATA IN: Set to indicate that the peer has sent us new data. - * UDP_NEWDATA OUT: Cleared (only) by the socket layer logic to indicate - * ICMP_NEWDATA that the new data was consumed, suppressing further - * ICMPv6_NEWDATA attempts to process the new data. - * PKT_NEWDATA + * UDP_NEWDATA OUT: Cleared (only) by the socket layer logic to + * ICMP_NEWDATA indicate that the new data was consumed, + * ICMPv6_NEWDATA suppressing further attempts to process the new + * PKT_NEWDATA data. * BLUETOOTH_NEWDATA * IEEE802154_NEWDATA * * TCP_SNDACK IN: Not used; always zero - * OUT: Set by the socket layer if the new data was consumed - * and an ACK should be sent in the response. (TCP only) + * OUT: Set by the socket layer if the new data was + * consumed and an ACK should be sent in the response. + * (TCP only) * * TCP_REXMIT IN: Tells the socket layer to retransmit the data that * was last sent. (TCP only) * OUT: Not used * - * TCP_POLL IN: Used for polling the socket layer. This is provided - * UDP_POLL periodically from the drivers to support (1) timed - * PKT_POLL operations, and (2) to check if the socket layer has - * BLUETOOTH_POLL data that it wants to send. These are socket oriented - * IEEE802154_POLL callbacks where the context depends on the specific - * set + * TCP_POLL IN: Used for polling the socket layer. This is + * UDP_POLL provided periodically from the drivers to support + * PKT_POLL (1) timed operations, and (2) to check if the + * BLUETOOTH_POLL socket layer has data that it wants to send. + * IEEE802154_POLL These are socket oriented callbacks where the + * context depends on the specific set. * OUT: Not used * * TCP_BACKLOG IN: There is a new connection in the backlog list set @@ -104,14 +105,15 @@ * OUT: The socket layer signals that it wants to close the * connection. (TCP only) * - * TCP_ABORT IN: The remote host has aborted the connection, thus the - * connection has gone away. (TCP only) + * TCP_ABORT IN: The remote host has aborted the connection, thus + * the connection has gone away. (TCP only) * OUT: The socket layer signals that it wants to abort the * connection. (TCP only) * - * TCP_CONNECTED IN: We have got a connection from a remote host and have - * set up a new connection for it, or an active connection - * has been successfully established. (TCP only) + * TCP_CONNECTED IN: We have got a connection from a remote host and + * have set up a new connection for it, or an active + * connection has been successfully established. + * (TCP only) * OUT: Not used * * TCP_TIMEDOUT IN: The connection has been aborted due to too many @@ -121,37 +123,38 @@ * Device Specific Events: These are events that may be notified through * callback lists residing in the network device structure. * - * ARP_POLL IN: Used for polling the socket layer. This is provided - * periodically from the drivers to support (1) timed - * operations, and (2) to check if the ARP layer needs - * to send an ARP request. This is a device oriented - * event, not associated with a socket. + * ARP_POLL IN: Used for polling the socket layer. This is + * provided periodically from the drivers to support + * (1) timed operations, and (2) to check if the ARP + * layer needs to send an ARP request. This is a + * device oriented event, not associated with a + * socket. * OUT: Not used * - * ICMP_POLL IN: Used for polling the socket layer. This is provided - * periodically from the drivers to support (1) timed - * operations, and (2) to check if the ICMP layer needs - * to send an ARP request. This is a device oriented - * event, not associated with a socket. This differs - * from ICMPv6_POLL only in that the appdata pointer - * is set differently + * ICMP_POLL IN: Used for polling the socket layer. This is + * provided periodically from the drivers to support + * (1) timed operations, and (2) to check if the ICMP + * layer needs to send an ARP request. This is a + * device oriented event, not associated with a + * socket. This differs from ICMPv6_POLL only in that + * the appdata pointer is set differently. * OUT: Not used * - * ICMPv6_POLL IN: Used for polling the socket layer. This is provided - * periodically from the drivers to support (1) timed - * operations, and (2) to check if the ICMP layer needs - * to send an ARP request. This is a device oriented - * event, not associated with a socket. This differs - * from ICMP_POLL only in that the appdata pointer - * is set differently + * ICMPv6_POLL IN: Used for polling the socket layer. This is + * provided periodically from the drivers to support + * (1) timed operations, and (2) to check if the ICMP + * layer needs to send an ARP request. This is a + * device oriented event, not associated with a + * socket. This differs from ICMP_POLL only in that + * the appdata pointer is set differently. * OUT: Not used * * IPFWD_POLL IN: Used for polling for forwarded packets layer. This - * is provided periodically from the drivers to support - * to check if there is a packet waiting to be forward - * on the device. This is a device oriented event, - * not associated with a socket. The appdata pointer - * The appdata pointer is not used in this case. + * is provided periodically from the drivers to + * support to check if there is a packet waiting to be + * forward on the device. This is a device oriented + * event, not associated with a socket. The appdata + * pointer is not used in this case. * OUT: Not used * * NETDEV_DOWN: IN: The network device has been taken down. diff --git a/net/devif/devif_poll.c b/net/devif/devif_poll.c index e997a6f..803d741 100644 --- a/net/devif/devif_poll.c +++ b/net/devif/devif_poll.c @@ -173,15 +173,17 @@ static void devif_packet_conversion(FAR struct net_driver_s *dev, } else { - nerr("ERROR: ICMPv6 protocol error: %u... Packet dropped\n", - ipv6->proto); + nerr( + "ERROR: ICMPv6 protocol error: %u... Packet dropped\n", + ipv6->proto); } } else #endif { - nerr("ERROR: Unhandled packet dropped. pkttype=%u protocol=%u\n", - pkttype, ipv6->proto); + nerr( + "ERROR: Unhandled packet dropped. pkttype=%u protocol=%u\n", + pkttype, ipv6->proto); } UNUSED(ipv6); @@ -396,14 +398,16 @@ static inline int devif_poll_icmpv6(FAR struct net_driver_s *dev, FAR struct icmpv6_conn_s *conn = NULL; int bstop = 0; - /* Traverse all of the allocated ICMPV6 connections and perform the poll action */ + /* Traverse all of the allocated ICMPV6 connections and perform + * the poll action + */ do { /* Perform the ICMPV6 poll - * Note: conn equal NULL in the first iteration means poll dev's callback list - * since icmpv6_autoconfig and icmpv6_neighbor still append it's callback into - * this list. + * Note: conn equal NULL in the first iteration means poll dev's + * callback list since icmpv6_autoconfig and icmpv6_neighbor still + * append it's callback into this list. */ icmpv6_poll(dev, conn); @@ -654,9 +658,9 @@ static inline int devif_poll_tcp_timer(FAR struct net_driver_s *dev, * should do only if it cannot accept further write data). * * When the callback function is called, there may be an outbound packet - * waiting for service in the device packet buffer, and if so the d_len field - * is set to a value larger than zero. The device driver should then send - * out the packet. + * waiting for service in the device packet buffer, and if so the d_len + * field is set to a value larger than zero. The device driver should then + * send out the packet. * * Assumptions: * This function is called from the MAC device driver with the network @@ -690,6 +694,7 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) #ifdef CONFIG_NET_CAN { /* Check for pending packet socket transfer */ + bstop = devif_poll_can_connections(dev, callback); } @@ -791,8 +796,8 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) * Name: devif_timer * * Description: - * These function will traverse each active network connection structure and - * perform network timer operations. The Ethernet driver MUST implement + * These function will traverse each active network connection structure + * and perform network timer operations. The Ethernet driver MUST implement * logic to periodically call devif_timer(). * * This function will call the provided callback function for every active @@ -801,9 +806,9 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) * should do only if it cannot accept further write data). * * When the callback function is called, there may be an outbound packet - * waiting for service in the device packet buffer, and if so the d_len field - * is set to a value larger than zero. The device driver should then send - * out the packet. + * waiting for service in the device packet buffer, and if so the d_len + * field is set to a value larger than zero. The device driver should then + * send out the packet. * * Assumptions: * This function is called from the MAC device driver with the network diff --git a/net/icmp/icmp_sockif.c b/net/icmp/icmp_sockif.c index ebe2bab..2b1e179 100644 --- a/net/icmp/icmp_sockif.c +++ b/net/icmp/icmp_sockif.c @@ -284,7 +284,8 @@ static int icmp_connect(FAR struct socket *psock, * Input Parameters: * psock Reference to the listening socket structure * addr Receives the address of the connecting client - * addrlen Input: allocated size of 'addr', Return: returned size of 'addr' + * addrlen Input: allocated size of 'addr', + * Return: returned size of 'addr' * newsock Location to return the accepted socket information. * * Returned Value: @@ -322,7 +323,8 @@ static int icmp_accept(FAR struct socket *psock, FAR struct sockaddr *addr, * ****************************************************************************/ -static int icmp_bind(FAR struct socket *psock, FAR const struct sockaddr *addr, +static int icmp_bind(FAR struct socket *psock, + FAR const struct sockaddr *addr, socklen_t addrlen) { /* An ICMP socket cannot be bound to a local address */ @@ -368,10 +370,10 @@ static int icmp_getsockname(FAR struct socket *psock, * Name: icmp_getpeername * * Description: - * The icmp_getpeername() function retrieves the remote-connected name of the - * specified packet socket, stores this address in the sockaddr structure - * pointed to by the 'addr' argument, and stores the length of this - * address in the object pointed to by the 'addrlen' argument. + * The icmp_getpeername() function retrieves the remote-connected name of + * the specified packet socket, stores this address in the sockaddr + * structure pointed to by the 'addr' argument, and stores the length of + * this address in the object pointed to by the 'addrlen' argument. * * If the actual length of the address is greater than the length of the * supplied sockaddr structure, the stored address will be truncated. diff --git a/net/icmpv6/icmpv6_sockif.c b/net/icmpv6/icmpv6_sockif.c index 5adae60..3dbb5c8 100644 --- a/net/icmpv6/icmpv6_sockif.c +++ b/net/icmpv6/icmpv6_sockif.c @@ -284,7 +284,8 @@ static int icmpv6_connect(FAR struct socket *psock, * Input Parameters: * psock Reference to the listening socket structure * addr Receives the address of the connecting client - * addrlen Input: allocated size of 'addr', Return: returned size of 'addr' + * addrlen Input: allocated size of 'addr', + * Return: returned size of 'addr' * newsock Location to return the accepted socket information. * * Returned Value: @@ -322,8 +323,9 @@ static int icmpv6_accept(FAR struct socket *psock, FAR struct sockaddr *addr, * ****************************************************************************/ -static int icmpv6_bind(FAR struct socket *psock, FAR const struct sockaddr *addr, - socklen_t addrlen) +static int icmpv6_bind(FAR struct socket *psock, + FAR const struct sockaddr *addr, + socklen_t addrlen) { /* An ICMPv6 socket cannot be bound to a local address */ @@ -334,10 +336,10 @@ static int icmpv6_bind(FAR struct socket *psock, FAR const struct sockaddr *addr * Name: icmpv6_getsockname * * Description: - * The icmpv6_getsockname() function retrieves the locally-bound name of the - * specified packet socket, stores this address in the sockaddr structure - * pointed to by the 'addr' argument, and stores the length of this - * address in the object pointed to by the 'addrlen' argument. + * The icmpv6_getsockname() function retrieves the locally-bound name of + * the specified packet socket, stores this address in the sockaddr + * structure pointed to by the 'addr' argument, and stores the length of + * this address in the object pointed to by the 'addrlen' argument. * * If the actual length of the address is greater than the length of the * supplied sockaddr structure, the stored address will be truncated. @@ -368,10 +370,10 @@ static int icmpv6_getsockname(FAR struct socket *psock, * Name: icmpv6_getpeername * * Description: - * The icmpv6_getpeername() function retrieves the remote-connected name of the - * specified packet socket, stores this address in the sockaddr structure - * pointed to by the 'addr' argument, and stores the length of this - * address in the object pointed to by the 'addrlen' argument. + * The icmpv6_getpeername() function retrieves the remote-connected name of + * the specified packet socket, stores this address in the sockaddr + * structure pointed to by the 'addr' argument, and stores the length of + * this address in the object pointed to by the 'addrlen' argument. * * If the actual length of the address is greater than the length of the * supplied sockaddr structure, the stored address will be truncated. @@ -487,8 +489,8 @@ static int icmpv6_netpoll(FAR struct socket *psock, FAR struct pollfd *fds, static ssize_t icmpv6_send(FAR struct socket *psock, FAR const void *buf, size_t len, int flags) { - /* ICMPv6 sockets cannot be bound and, hence, cannot support any connection- - * oriented data transfer. + /* ICMPv6 sockets cannot be bound and, hence, cannot support any + * connection-oriented data transfer. */ return -EDESTADDRREQ; diff --git a/net/ieee802154/ieee802154_sockif.c b/net/ieee802154/ieee802154_sockif.c index 6c0f88a..03db4fb 100644 --- a/net/ieee802154/ieee802154_sockif.c +++ b/net/ieee802154/ieee802154_sockif.c @@ -245,10 +245,10 @@ static void ieee802154_addref(FAR struct socket *psock) * Name: ieee802154_connect * * Description: - * ieee802154_connect() connects the local socket referred to by the structure - * 'psock' to the address specified by 'addr'. The addrlen argument - * specifies the size of 'addr'. The format of the address in 'addr' is - * determined by the address space of the socket 'psock'. + * ieee802154_connect() connects the local socket referred to by the + * structure 'psock' to the address specified by 'addr'. The addrlen + * argument specifies the size of 'addr'. The format of the address in + * 'addr' is determined by the address space of the socket 'psock'. * * If the socket 'psock' is of type SOCK_DGRAM then 'addr' is the address * to which datagrams are sent by default, and the only address from which @@ -311,8 +311,8 @@ static int ieee802154_connect(FAR struct socket *psock, * Name: ieee802154_accept * * Description: - * The ieee802154_accept function is used with connection-based socket types - * (SOCK_STREAM, SOCK_SEQPACKET and SOCK_RDM). It extracts the first + * The ieee802154_accept function is used with connection-based socket + * types (SOCK_STREAM, SOCK_SEQPACKET and SOCK_RDM). It extracts the first * connection request on the queue of pending connections, creates a new * connected socket with mostly the same properties as 'sockfd', and * allocates a new socket descriptor for the socket, which is returned. The @@ -338,7 +338,8 @@ static int ieee802154_connect(FAR struct socket *psock, * Input Parameters: * psock Reference to the listening socket structure * addr Receives the address of the connecting client - * addrlen Input: allocated size of 'addr', Return: returned size of 'addr' + * addrlen Input: allocated size of 'addr', + * Return: returned size of 'addr' * newsock Location to return the accepted socket information. * * Returned Value: @@ -380,7 +381,8 @@ static int ieee802154_accept(FAR struct socket *psock, ****************************************************************************/ static int ieee802154_bind(FAR struct socket *psock, - FAR const struct sockaddr *addr, socklen_t addrlen) + FAR const struct sockaddr *addr, + socklen_t addrlen) { FAR const struct sockaddr_ieee802154_s *iaddr; FAR struct radio_driver_s *radio; @@ -450,10 +452,10 @@ static int ieee802154_bind(FAR struct socket *psock, * Name: ieee802154_getsockname * * Description: - * The ieee802154_getsockname() function retrieves the locally-bound name of the - * specified packet socket, stores this address in the sockaddr structure - * pointed to by the 'addr' argument, and stores the length of this - * address in the object pointed to by the 'addrlen' argument. + * The ieee802154_getsockname() function retrieves the locally-bound name + * of the specified packet socket, stores this address in the sockaddr + * structure pointed to by the 'addr' argument, and stores the length of + * this address in the object pointed to by the 'addrlen' argument. * * If the actual length of the address is greater than the length of the * supplied sockaddr structure, the stored address will be truncated. @@ -512,10 +514,10 @@ static int ieee802154_getsockname(FAR struct socket *psock, * Name: ieee802154_getpeername * * Description: - * The ieee802154_getpeername() function retrieves the remote-connectd name of the - * specified packet socket, stores this address in the sockaddr structure - * pointed to by the 'addr' argument, and stores the length of this - * address in the object pointed to by the 'addrlen' argument. + * The ieee802154_getpeername() function retrieves the remote-connectd name + * of the specified packet socket, stores this address in the sockaddr + * structure pointed to by the 'addr' argument, and stores the length of + * this address in the object pointed to by the 'addrlen' argument. * * If the actual length of the address is greater than the length of the * supplied sockaddr structure, the stored address will be truncated. @@ -680,7 +682,8 @@ static ssize_t ieee802154_send(FAR struct socket *psock, FAR const void *buf, ret = psock_ieee802154_sendto(psock, buf, len, flags, (FAR const struct sockaddr *)&to, - sizeof(struct sockaddr_ieee802154_s)); + sizeof( + struct sockaddr_ieee802154_s)); } } else @@ -717,9 +720,11 @@ static ssize_t ieee802154_send(FAR struct socket *psock, FAR const void *buf, * ****************************************************************************/ -static ssize_t ieee802154_sendto(FAR struct socket *psock, FAR const void *buf, +static ssize_t ieee802154_sendto(FAR struct socket *psock, + FAR const void *buf, size_t len, int flags, - FAR const struct sockaddr *to, socklen_t tolen) + FAR const struct sockaddr *to, + socklen_t tolen) { ssize_t ret; @@ -777,8 +782,8 @@ static int ieee802154_close(FAR struct socket *psock) { /* Yes... free the connection structure */ - conn->crefs = 0; /* No more references on the connection */ - ieee802154_conn_free(psock->s_conn); /* Free network resources */ + conn->crefs = 0; /* No more references on the connection */ + ieee802154_conn_free(psock->s_conn); /* Free network resources */ } else { diff --git a/net/inet/inet_sockif.c b/net/inet/inet_sockif.c index abdef2e..6221f01 100644 --- a/net/inet/inet_sockif.c +++ b/net/inet/inet_sockif.c @@ -212,7 +212,8 @@ static int inet_udp_alloc(FAR struct socket *psock) * families. * * Input Parameters: - * psock A pointer to a user allocated socket structure to be initialized. + * psock A pointer to a user allocated socket structure + * to be initialized. * protocol (see sys/socket.h) * * Returned Value: @@ -432,7 +433,8 @@ static int inet_bind(FAR struct socket *psock, ret = udp_bind(psock->s_conn, addr); #else - nwarn("WARNING: UDP stack is not available in this configuration\n"); + nwarn( + "WARNING: UDP stack is not available in this configuration\n"); ret = -ENOSYS; #endif } @@ -673,7 +675,8 @@ int inet_listen(FAR struct socket *psock, int backlog) static int inet_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, socklen_t addrlen) { - FAR const struct sockaddr_in *inaddr = (FAR const struct sockaddr_in *)addr; + FAR const struct sockaddr_in *inaddr = + (FAR const struct sockaddr_in *)addr; /* Verify that a valid address has been provided */ @@ -799,7 +802,8 @@ static int inet_connect(FAR struct socket *psock, * Input Parameters: * psock Reference to the listening socket structure * addr Receives the address of the connecting client - * addrlen Input: allocated size of 'addr', Return: returned size of 'addr' + * addrlen Input: allocated size of 'addr' + * Return: returned size of 'addr' * newsock Location to return the accepted socket information. * * Returned Value: @@ -1164,7 +1168,8 @@ static ssize_t inet_send(FAR struct socket *psock, FAR const void *buf, ****************************************************************************/ static ssize_t inet_sendto(FAR struct socket *psock, FAR const void *buf, - size_t len, int flags, FAR const struct sockaddr *to, + size_t len, int flags, + FAR const struct sockaddr *to, socklen_t tolen) { socklen_t minlen; @@ -1304,7 +1309,8 @@ static ssize_t inet_sendfile(FAR struct socket *psock, ****************************************************************************/ static ssize_t inet_recvfrom(FAR struct socket *psock, FAR void *buf, - size_t len, int flags, FAR struct sockaddr *from, + size_t len, int flags, + FAR struct sockaddr *from, FAR socklen_t *fromlen) { ssize_t ret; diff --git a/net/local/local_sockif.c b/net/local/local_sockif.c index cd9bd66..c4f7531 100644 --- a/net/local/local_sockif.c +++ b/net/local/local_sockif.c @@ -165,7 +165,8 @@ static int local_sockif_alloc(FAR struct socket *psock) * specific socket fields. * * Input Parameters: - * psock A pointer to a user allocated socket structure to be initialized. + * psock A pointer to a user allocated socket structure + * to be initialized. * protocol (see sys/socket.h) * * Returned Value: @@ -594,7 +595,8 @@ static int local_connect(FAR struct socket *psock, * Input Parameters: * psock Reference to the listening socket structure * addr Receives the address of the connecting client - * addrlen Input: allocated size of 'addr', Return: returned size of 'addr' + * addrlen Input: allocated size of 'addr', + * Return: returned size of 'addr' * newsock Location to return the accepted socket information. * * Returned Value: @@ -721,7 +723,7 @@ static ssize_t local_send(FAR struct socket *psock, FAR const void *buf, * Name: local_sendto * * Description: - * Implements the sendto() operation for the case of the local, Unix socket. + * Implements the sendto() operation for the case of the local Unix socket. * * Input Parameters: * psock A pointer to a NuttX-specific, internal socket structure diff --git a/net/netdev/netdev_register.c b/net/netdev/netdev_register.c index 6b3e5b8..e9b211f 100644 --- a/net/netdev/netdev_register.c +++ b/net/netdev/netdev_register.c @@ -241,8 +241,8 @@ static int get_ifindex(void) * * Input Parameters: * dev - The device driver structure to be registered. - * lltype - Link level protocol used by the driver (Ethernet, SLIP, TUN, ... - * ... + * lltype - Link level protocol used by the driver + * (Ethernet, SLIP, TUN, ...) * * Returned Value: * 0:Success; negated errno on failure @@ -303,7 +303,7 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype) #endif #ifdef CONFIG_NET_BLUETOOTH - case NET_LL_BLUETOOTH: /* Bluetooth */ + case NET_LL_BLUETOOTH: /* Bluetooth */ dev->d_llhdrlen = BLUETOOTH_MAX_HDRLEN; /* Determined at runtime */ #ifdef CONFIG_NET_6LOWPAN dev->d_pktsize = CONFIG_NET_6LOWPAN_PKTSIZE; diff --git a/net/netlink/netlink_sockif.c b/net/netlink/netlink_sockif.c index b3ef9ad..bb3a96e 100644 --- a/net/netlink/netlink_sockif.c +++ b/net/netlink/netlink_sockif.c @@ -510,8 +510,13 @@ static int netlink_connect(FAR struct socket *psock, ****************************************************************************/ static int netlink_accept(FAR struct socket *psock, +<<<<<<< HEAD FAR struct sockaddr *addr, FAR socklen_t *addrlen, FAR struct socket *newsock) +======= + FAR struct sockaddr *addr, + FAR socklen_t *addrlen, FAR struct socket *newsock) +>>>>>>> Code style fixes 4 { return -EOPNOTSUPP; } @@ -649,8 +654,13 @@ static int netlink_poll(FAR struct socket *psock, FAR struct pollfd *fds, conn->pollsem = fds->sem; conn->pollevent = &fds->revents; +<<<<<<< HEAD ret = netlink_notifier_setup(netlink_response_available, conn, conn); +======= + ret = netlink_notifier_setup(netlink_response_available, conn, + conn); +>>>>>>> Code style fixes 4 if (ret < 0) { nerr("ERROR: netlink_notifier_setup() failed: %d\n", ret); @@ -729,7 +739,12 @@ static ssize_t netlink_send(FAR struct socket *psock, FAR const void *buf, * returned when the socket was not actually connected. * * Input Parameters: +<<<<<<< HEAD * psock A reference to the structure of the socket to be connected +======= + * psock A reference to the socket structure of the socket + * to be connected +>>>>>>> Code style fixes 4 * buf Data to send * len Length of data to send * flags Send flags (ignored) diff --git a/net/socket/getsockopt.c b/net/socket/getsockopt.c index 9c2658b..4c5e7f1 100644 --- a/net/socket/getsockopt.c +++ b/net/socket/getsockopt.c @@ -92,7 +92,8 @@ ****************************************************************************/ static int psock_socketlevel_option(FAR struct socket *psock, int option, - FAR void *value, FAR socklen_t *value_len) + FAR void *value, + FAR socklen_t *value_len) { /* Verify that the socket option if valid (but might not be supported ) */ diff --git a/net/socket/recvmsg.c b/net/socket/recvmsg.c index 800eeb1..9ba5de3 100644 --- a/net/socket/recvmsg.c +++ b/net/socket/recvmsg.c @@ -1,7 +1,8 @@ /**************************************************************************** * net/socket/recvmsg.c * - * Copyright (C) 2007-2009, 2011-2017, 2019 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2017, 2019 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt <gn...@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -86,6 +87,7 @@ ssize_t psock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg, int flags) { /* Verify that non-NULL pointers were passed */ + if (msg == NULL) { return -EINVAL; @@ -111,20 +113,22 @@ ssize_t psock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg, (psock->s_sockif->si_recvmsg != NULL || psock->s_sockif->si_recvfrom != NULL)); - if(psock->s_sockif->si_recvmsg != NULL) + if (psock->s_sockif->si_recvmsg != NULL) { - return psock->s_sockif->si_recvmsg(psock, msg, flags); + return psock->s_sockif->si_recvmsg(psock, msg, flags); } else { - /* Socket doesn't implement si_recvmsg fallback to si_recvfrom */ - FAR void *buf = msg->msg_iov->iov_base; - FAR struct sockaddr *from = msg->msg_name; - FAR socklen_t *fromlen = (FAR socklen_t *)&msg->msg_namelen; - size_t len = msg->msg_iov->iov_len; - return psock->s_sockif->si_recvfrom(psock, buf, len, flags, from, fromlen); - } + /* Socket doesn't implement si_recvmsg fallback to si_recvfrom */ + FAR void *buf = msg->msg_iov->iov_base; + FAR struct sockaddr *from = msg->msg_name; + FAR socklen_t *fromlen = (FAR socklen_t *)&msg->msg_namelen; + size_t len = msg->msg_iov->iov_len; + + return psock->s_sockif->si_recvfrom(psock, buf, len, flags, from, + fromlen); + } } /**************************************************************************** @@ -171,7 +175,8 @@ ssize_t nx_recvmsg(int sockfd, FAR struct msghdr *msg, int flags) * Function: recvmsg * * Description: - * The recvmsg() call is identical to recvfrom() with a NULL from parameter. + * The recvmsg() call is identical to recvfrom() with a NULL from + * parameter. * * Parameters: * sockfd Socket descriptor of socket @@ -184,19 +189,20 @@ ssize_t nx_recvmsg(int sockfd, FAR struct msghdr *msg, int flags) * -1 is returned, and errno is set appropriately: * * EAGAIN - * The socket is marked non-blocking and the receive operation would block, - * or a receive timeout had been set and the timeout expired before data - * was received. + * The socket is marked non-blocking and the receive operation would + * block, or a receive timeout had been set and the timeout expired + * before data was received. * EBADF * The argument sockfd is an invalid descriptor. * ECONNREFUSED - * A remote host refused to allow the network connection (typically because - * it is not running the requested service). + * A remote host refused to allow the network connection (typically + * because it is not running the requested service). * EFAULT - * The receive buffer pointer(s) point outside the process's address space. + * The receive buffer pointer(s) point outside the process's address + * space. * EINTR - * The receive was interrupted by delivery of a signal before any data were - * available. + * The receive was interrupted by delivery of a signal before any data + * were available. * EINVAL * Invalid argument passed. * ENOMEM diff --git a/net/socket/sendmsg.c b/net/socket/sendmsg.c index 3bc32e8..a188b3a 100644 --- a/net/socket/sendmsg.c +++ b/net/socket/sendmsg.c @@ -1,7 +1,8 @@ /**************************************************************************** * net/socket/sendmsg.c * - * Copyright (C) 2007-2009, 2011-2017, 2019 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2017, 2019 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt <gn...@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -86,6 +87,7 @@ ssize_t psock_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg, int flags) { /* Verify that non-NULL pointers were passed */ + if (msg == NULL) { return -EINVAL; @@ -111,20 +113,21 @@ ssize_t psock_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg, (psock->s_sockif->si_sendmsg != NULL || psock->s_sockif->si_sendto != NULL)); - if(psock->s_sockif->si_sendmsg != NULL) + if (psock->s_sockif->si_sendmsg != NULL) { - return psock->s_sockif->si_sendmsg(psock, msg, flags); + return psock->s_sockif->si_sendmsg(psock, msg, flags); } else { - /* Socket doesn't implement si_sendmsg fallback to si_sendto */ - FAR void *buf = msg->msg_iov->iov_base; - FAR struct sockaddr *to = msg->msg_name; - socklen_t tolen = msg->msg_namelen; - size_t len = msg->msg_iov->iov_len; - return psock->s_sockif->si_sendto(psock, buf, len, flags, to, tolen); - } + /* Socket doesn't implement si_sendmsg fallback to si_sendto */ + FAR void *buf = msg->msg_iov->iov_base; + FAR struct sockaddr *to = msg->msg_name; + socklen_t tolen = msg->msg_namelen; + size_t len = msg->msg_iov->iov_len; + + return psock->s_sockif->si_sendto(psock, buf, len, flags, to, tolen); + } } /**************************************************************************** @@ -171,7 +174,8 @@ ssize_t nx_sendmsg(int sockfd, FAR struct msghdr *msg, int flags) * Function: sendmsg * * Description: - * The sendmsg() call is identical to sendfrom() with a NULL from parameter. + * The sendmsg() call is identical to sendfrom() with a NULL from + * parameter. * * Parameters: * sockfd Socket descriptor of socket @@ -184,19 +188,20 @@ ssize_t nx_sendmsg(int sockfd, FAR struct msghdr *msg, int flags) * -1 is returned, and errno is set appropriately: * * EAGAIN - * The socket is marked non-blocking and the receive operation would block, - * or a receive timeout had been set and the timeout expired before data - * was received. + * The socket is marked non-blocking and the receive operation would + * block, or a receive timeout had been set and the timeout expired + * before data was received. * EBADF * The argument sockfd is an invalid descriptor. * ECONNREFUSED - * A remote host refused to allow the network connection (typically because - * it is not running the requested service). + * A remote host refused to allow the network connection (typically + * because it is not running the requested service). * EFAULT - * The receive buffer pointer(s) point outside the process's address space. + * The receive buffer pointer(s) point outside the process's address + * space. * EINTR - * The receive was interrupted by delivery of a signal before any data were - * available. + * The receive was interrupted by delivery of a signal before any data + * were available. * EINVAL * Invalid argument passed. * ENOMEM diff --git a/net/socket/setsockopt.c b/net/socket/setsockopt.c index 3608152..612c2ed 100644 --- a/net/socket/setsockopt.c +++ b/net/socket/setsockopt.c @@ -87,7 +87,8 @@ ****************************************************************************/ static int psock_socketlevel_option(FAR struct socket *psock, int option, - FAR const void *value, socklen_t value_len) + FAR const void *value, + socklen_t value_len) { /* Verify that the socket option if valid (but might not be supported ) */ @@ -280,7 +281,6 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option, #ifdef CONFIG_NET_TIMESTAMP case SO_TIMESTAMP: /* Generates a timestamp for each incoming packet */ { - /* Verify that option is at least the size of an integer. */ if (value_len < sizeof(FAR int32_t)) @@ -294,7 +294,7 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option, net_lock(); - psock->s_timestamp = *((FAR int32_t*)value); + psock->s_timestamp = *((FAR int32_t *)value); net_unlock(); } @@ -339,8 +339,8 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option, * See <sys/socket.h> a complete list of values for the socket level * 'option' argument. * - * Protocol level options, such as SOL_TCP, are defined in protocol-specific - * header files, for example include/netinet/tcp.h + * Protocol level options, such as SOL_TCP, are defined in + * protocol-specific header files, for example include/netinet/tcp.h * * Input Parameters: * psock Socket structure of socket to operate on @@ -449,8 +449,8 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, * See <sys/socket.h> a complete list of values for the socket level * 'option' argument. * - * Protocol level options, such as SOL_TCP, are defined in protocol-specific - * header files, for example include/netinet/tcp.h + * Protocol level options, such as SOL_TCP, are defined in + * protocol-specific header files, for example include/netinet/tcp.h * * Input Parameters: * sockfd Socket descriptor of socket