mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-05-27 17:30:43 +08:00
format: format sal socket code
This commit is contained in:
@@ -95,44 +95,52 @@ static struct sal_netdev_res_table sal_dev_res_tbl[SAL_SOCKETS_NUM];
|
||||
#define SAL_SOCKOPS_PROTO_TLS_VALID(sock, name) (proto_tls && (proto_tls->ops->name) && IS_SOCKET_PROTO_TLS(sock))
|
||||
|
||||
#define SAL_SOCKOPT_PROTO_TLS_EXEC(sock, name, optval, optlen) \
|
||||
do { \
|
||||
if (SAL_SOCKOPS_PROTO_TLS_VALID(sock, name)){ \
|
||||
do \
|
||||
{ \
|
||||
if (SAL_SOCKOPS_PROTO_TLS_VALID(sock, name)) \
|
||||
{ \
|
||||
return proto_tls->ops->name((sock)->user_data_tls, (optval), (optlen)); \
|
||||
} \
|
||||
}while(0) \
|
||||
} while (0)
|
||||
|
||||
#define SAL_SOCKET_OBJ_GET(sock, socket) \
|
||||
do { \
|
||||
do \
|
||||
{ \
|
||||
(sock) = sal_get_socket(socket); \
|
||||
if ((sock) == RT_NULL) { \
|
||||
if ((sock) == RT_NULL) \
|
||||
{ \
|
||||
return -1; \
|
||||
} \
|
||||
}while(0) \
|
||||
} while (0)
|
||||
|
||||
#define SAL_NETDEV_IS_UP(netdev) \
|
||||
do { \
|
||||
if (!netdev_is_up(netdev)) { \
|
||||
do \
|
||||
{ \
|
||||
if (!netdev_is_up(netdev)) \
|
||||
{ \
|
||||
return -1; \
|
||||
} \
|
||||
}while(0) \
|
||||
} while (0)
|
||||
|
||||
#define SAL_NETDEV_SOCKETOPS_VALID(netdev, pf, ops) \
|
||||
do { \
|
||||
do \
|
||||
{ \
|
||||
(pf) = (struct sal_proto_family *)netdev->sal_user_data; \
|
||||
if ((pf)->skt_ops->ops == RT_NULL){ \
|
||||
if ((pf)->skt_ops->ops == RT_NULL) \
|
||||
{ \
|
||||
return -1; \
|
||||
} \
|
||||
}while(0) \
|
||||
} while (0)
|
||||
|
||||
#define SAL_NETDEV_NETDBOPS_VALID(netdev, pf, ops) \
|
||||
((netdev) && netdev_is_up(netdev) && \
|
||||
((pf) = (struct sal_proto_family *)(netdev)->sal_user_data) != RT_NULL && \
|
||||
(pf)->netdb_ops->ops) \
|
||||
(pf)->netdb_ops->ops)
|
||||
|
||||
#define SAL_NETDBOPS_VALID(netdev, pf, ops) \
|
||||
((netdev) && \
|
||||
((pf) = (struct sal_proto_family *)(netdev)->sal_user_data) != RT_NULL && \
|
||||
(pf)->netdb_ops->ops) \
|
||||
(pf)->netdb_ops->ops)
|
||||
|
||||
/**
|
||||
* SAL (Socket Abstraction Layer) initialize.
|
||||
@@ -426,8 +434,7 @@ int sal_netdev_cleanup(struct netdev *netdev)
|
||||
{
|
||||
rt_thread_mdelay(100);
|
||||
}
|
||||
}
|
||||
while (find_dev);
|
||||
} while (find_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1623,7 +1630,6 @@ int sal_getaddrinfo(const char *nodename,
|
||||
}
|
||||
|
||||
RT_ASSERT((i < SAL_SOCKETS_NUM));
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user