You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2019/12/24 14:15:21 UTC
[incubator-nuttx] 01/02: net/: Trivial changes to PR from review.
Biggest difference: type of s_error changed to int16_t to save a byte or
two.
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 50a58d135037aea615fd1b6ff6453ad562e1202b
Author: Gregory Nutt <gn...@nuttx.org>
AuthorDate: Tue Dec 24 08:02:41 2019 -0600
net/: Trivial changes to PR from review. Biggest difference: type of s_error changed to int16_t to save a byte or two.
---
include/nuttx/net/net.h | 4 ++--
net/socket/getsockopt.c | 5 +++--
net/socket/recvfrom.c | 4 ++--
net/socket/socket.h | 13 +++++++++++--
4 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/include/nuttx/net/net.h b/include/nuttx/net/net.h
index a2b8931..5ad141b 100644
--- a/include/nuttx/net/net.h
+++ b/include/nuttx/net/net.h
@@ -1,7 +1,7 @@
/****************************************************************************
* include/nuttx/net/net.h
*
- * Copyright (C) 2007, 2009-2014, 2016-2018 Gregory Nutt. All rights
+ * Copyright (C) 2007, 2009-2014, 2016-2019 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gn...@nuttx.org>
*
@@ -234,10 +234,10 @@ struct socket
/* Socket options */
#ifdef CONFIG_NET_SOCKOPTS
+ int16_t s_error; /* Last error that occurred on this socket */
sockopt_t s_options; /* Selected socket options */
socktimeo_t s_rcvtimeo; /* Receive timeout value (in deciseconds) */
socktimeo_t s_sndtimeo; /* Send timeout value (in deciseconds) */
- int s_error; /* Last error that occurred on this socket */
#ifdef CONFIG_NET_SOLINGER
socktimeo_t s_linger; /* Linger timeout value (in deciseconds) */
#endif
diff --git a/net/socket/getsockopt.c b/net/socket/getsockopt.c
index cb54abb..487642c 100644
--- a/net/socket/getsockopt.c
+++ b/net/socket/getsockopt.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/socket/getsockopt.c
*
- * Copyright (C) 2007-2009, 2012, 2014, 2017-2018 Gregory Nutt. All rights
+ * Copyright (C) 2007-2009, 2012, 2014, 2017-2019 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gn...@nuttx.org>
*
@@ -267,7 +267,8 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
{
return -EINVAL;
}
- *(int *)value = psock->s_error;
+
+ *(FAR int *)value = (int)psock->s_error;
psock->s_error = 0;
}
break;
diff --git a/net/socket/recvfrom.c b/net/socket/recvfrom.c
index c73bbdd..79944c2 100644
--- a/net/socket/recvfrom.c
+++ b/net/socket/recvfrom.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/socket/recvfrom.c
*
- * Copyright (C) 2007-2009, 2011-2017 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
@@ -93,7 +93,7 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
/* Verify that non-NULL pointers were passed */
#ifdef CONFIG_DEBUG_FEATURES
- if (!buf)
+ if (buf == NULL)
{
return -EINVAL;
}
diff --git a/net/socket/socket.h b/net/socket/socket.h
index f1a9082..f826337 100644
--- a/net/socket/socket.h
+++ b/net/socket/socket.h
@@ -134,9 +134,18 @@
/* Macro to set socket errors */
#ifdef CONFIG_NET_SOCKOPTS
-#define _SO_SETERRNO(s,e) if (s != NULL) { s->s_error = e; } set_errno(e)
+# define _SO_SETERRNO(s,e) \
+ do \
+ { \
+ if (s != NULL) \
+ { \
+ s->s_error = (int16_t)e; \
+ } \
+ set_errno(e); \
+ } \
+ while (0)
#else
-#define _SO_SETERRNO(s,e) set_errno(e)
+# define _SO_SETERRNO(s,e) set_errno(e)
#endif /* CONFIG_NET_SOCKOPTS */
/****************************************************************************