netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] net: convert lists of macros to enumerations
@ 2013-06-23 21:56 Jean Sacren
  2013-06-23 21:56 ` [PATCH net-next 2/2] net: uapi: do not manually set the first enumerator to zero Jean Sacren
  2013-06-24 15:14 ` [PATCH net-next 1/2] net: convert lists of macros to enumerations Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Jean Sacren @ 2013-06-23 21:56 UTC (permalink / raw)
  To: netdev

Use enumerations to replace macros for simpler preprocessing. Map numeric
values to enumerators. Where required, prepend the list with an additional
enumerator to accommodate the rest.

Signed-off-by: Jean Sacren <sakiwit@gmail.com>
---
 include/linux/net.h      | 15 +++++++++------
 include/uapi/linux/net.h | 43 +++++++++++++++++++++++--------------------
 2 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index 4f27575..84444bb 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -32,12 +32,15 @@ struct inode;
 struct file;
 struct net;
 
-#define SOCK_ASYNC_NOSPACE	0
-#define SOCK_ASYNC_WAITDATA	1
-#define SOCK_NOSPACE		2
-#define SOCK_PASSCRED		3
-#define SOCK_PASSSEC		4
-#define SOCK_EXTERNALLY_ALLOCATED 5
+/* Bit value for {set,clear,test{,_and_clear}}_bit() */
+enum {
+	SOCK_ASYNC_NOSPACE,		/* 0 */
+	SOCK_ASYNC_WAITDATA,		/* 1 */
+	SOCK_NOSPACE,			/* 2 */
+	SOCK_PASSCRED,			/* 3 */
+	SOCK_PASSSEC,			/* 4 */
+	SOCK_EXTERNALLY_ALLOCATED,	/* 5 */
+};
 
 #ifndef ARCH_HAS_SOCKET_TYPES
 /**
diff --git a/include/uapi/linux/net.h b/include/uapi/linux/net.h
index 9457239..9136b54 100644
--- a/include/uapi/linux/net.h
+++ b/include/uapi/linux/net.h
@@ -23,26 +23,29 @@
 
 #define NPROTO		AF_MAX
 
-#define SYS_SOCKET	1		/* sys_socket(2)		*/
-#define SYS_BIND	2		/* sys_bind(2)			*/
-#define SYS_CONNECT	3		/* sys_connect(2)		*/
-#define SYS_LISTEN	4		/* sys_listen(2)		*/
-#define SYS_ACCEPT	5		/* sys_accept(2)		*/
-#define SYS_GETSOCKNAME	6		/* sys_getsockname(2)		*/
-#define SYS_GETPEERNAME	7		/* sys_getpeername(2)		*/
-#define SYS_SOCKETPAIR	8		/* sys_socketpair(2)		*/
-#define SYS_SEND	9		/* sys_send(2)			*/
-#define SYS_RECV	10		/* sys_recv(2)			*/
-#define SYS_SENDTO	11		/* sys_sendto(2)		*/
-#define SYS_RECVFROM	12		/* sys_recvfrom(2)		*/
-#define SYS_SHUTDOWN	13		/* sys_shutdown(2)		*/
-#define SYS_SETSOCKOPT	14		/* sys_setsockopt(2)		*/
-#define SYS_GETSOCKOPT	15		/* sys_getsockopt(2)		*/
-#define SYS_SENDMSG	16		/* sys_sendmsg(2)		*/
-#define SYS_RECVMSG	17		/* sys_recvmsg(2)		*/
-#define SYS_ACCEPT4	18		/* sys_accept4(2)		*/
-#define SYS_RECVMMSG	19		/* sys_recvmmsg(2)		*/
-#define SYS_SENDMMSG	20		/* sys_sendmmsg(2)		*/
+enum {
+	SYS_DUMMY,			/* 0  - place holder		*/
+	SYS_SOCKET,			/* 1  - sys_socket(2)		*/
+	SYS_BIND,			/* 2  - sys_bind(2)		*/
+	SYS_CONNECT,			/* 3  - sys_connect(2)		*/
+	SYS_LISTEN,			/* 4  - sys_listen(2)		*/
+	SYS_ACCEPT,			/* 5  - sys_accept(2)		*/
+	SYS_GETSOCKNAME,		/* 6  - sys_getsockname(2)	*/
+	SYS_GETPEERNAME,		/* 7  - sys_getpeername(2)	*/
+	SYS_SOCKETPAIR,			/* 8  - sys_socketpair(2)	*/
+	SYS_SEND,			/* 9  - sys_send(2)		*/
+	SYS_RECV,			/* 10 - sys_recv(2)		*/
+	SYS_SENDTO,			/* 11 - sys_sendto(2)		*/
+	SYS_RECVFROM,			/* 12 - sys_recvfrom(2)		*/
+	SYS_SHUTDOWN,			/* 13 - sys_shutdown(2)		*/
+	SYS_SETSOCKOPT,			/* 14 - sys_setsockopt(2)	*/
+	SYS_GETSOCKOPT,			/* 15 - sys_getsockopt(2)	*/
+	SYS_SENDMSG,			/* 16 - sys_sendmsg(2)		*/
+	SYS_RECVMSG,			/* 17 - sys_recvmsg(2)		*/
+	SYS_ACCEPT4,			/* 18 - sys_accept4(2)		*/
+	SYS_RECVMMSG,			/* 19 - sys_recvmmsg(2)		*/
+	SYS_SENDMMSG,			/* 20 - sys_sendmmsg(2)		*/
+};
 
 typedef enum {
 	SS_FREE = 0,			/* not allocated		*/

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 2/2] net: uapi: do not manually set the first enumerator to zero
  2013-06-23 21:56 [PATCH net-next 1/2] net: convert lists of macros to enumerations Jean Sacren
@ 2013-06-23 21:56 ` Jean Sacren
  2013-06-24 15:14 ` [PATCH net-next 1/2] net: convert lists of macros to enumerations Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: Jean Sacren @ 2013-06-23 21:56 UTC (permalink / raw)
  To: netdev

Clean up the unnecessary assignment of the first enumerator to zero.

Signed-off-by: Jean Sacren <sakiwit@gmail.com>
---
 include/uapi/linux/net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/net.h b/include/uapi/linux/net.h
index 9136b54..9177fd3 100644
--- a/include/uapi/linux/net.h
+++ b/include/uapi/linux/net.h
@@ -48,7 +48,7 @@ enum {
 };
 
 typedef enum {
-	SS_FREE = 0,			/* not allocated		*/
+	SS_FREE,			/* not allocated		*/
 	SS_UNCONNECTED,			/* unconnected to any socket	*/
 	SS_CONNECTING,			/* in process of connecting	*/
 	SS_CONNECTED,			/* connected to socket		*/

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next 1/2] net: convert lists of macros to enumerations
  2013-06-23 21:56 [PATCH net-next 1/2] net: convert lists of macros to enumerations Jean Sacren
  2013-06-23 21:56 ` [PATCH net-next 2/2] net: uapi: do not manually set the first enumerator to zero Jean Sacren
@ 2013-06-24 15:14 ` Stephen Hemminger
  2013-06-25 23:26   ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2013-06-24 15:14 UTC (permalink / raw)
  To: Jean Sacren; +Cc: netdev

On Sun, 23 Jun 2013 15:56:16 -0600
Jean Sacren <sakiwit@gmail.com> wrote:

> Use enumerations to replace macros for simpler preprocessing. Map numeric
> values to enumerators. Where required, prepend the list with an additional
> enumerator to accommodate the rest.
> 
> Signed-off-by: Jean Sacren <sakiwit@gmail.com>

Converting the network based header files is easy and safe as long
as you test it. Not sure if it is worth the effort.

But changing the uapi exported header risks breaking applications that
were doing:

#ifdef SIOCXXXX
       do some code to enable that
#endif

Since enum values don't show up in the CPP namespace.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next 1/2] net: convert lists of macros to enumerations
  2013-06-24 15:14 ` [PATCH net-next 1/2] net: convert lists of macros to enumerations Stephen Hemminger
@ 2013-06-25 23:26   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-06-25 23:26 UTC (permalink / raw)
  To: stephen; +Cc: sakiwit, netdev

From: Stephen Hemminger <stephen@networkplumber.org>
Date: Mon, 24 Jun 2013 08:14:14 -0700

> On Sun, 23 Jun 2013 15:56:16 -0600
> Jean Sacren <sakiwit@gmail.com> wrote:
> 
>> Use enumerations to replace macros for simpler preprocessing. Map numeric
>> values to enumerators. Where required, prepend the list with an additional
>> enumerator to accommodate the rest.
>> 
>> Signed-off-by: Jean Sacren <sakiwit@gmail.com>
> 
> Converting the network based header files is easy and safe as long
> as you test it. Not sure if it is worth the effort.
> 
> But changing the uapi exported header risks breaking applications that
> were doing:
> 
> #ifdef SIOCXXXX
>        do some code to enable that
> #endif
> 
> Since enum values don't show up in the CPP namespace.

Agreed, these patches aren't to be considered seriously.  Too much
potential breakage, and even without that risk I see pretty much
zero value to these changes.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-25 23:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-23 21:56 [PATCH net-next 1/2] net: convert lists of macros to enumerations Jean Sacren
2013-06-23 21:56 ` [PATCH net-next 2/2] net: uapi: do not manually set the first enumerator to zero Jean Sacren
2013-06-24 15:14 ` [PATCH net-next 1/2] net: convert lists of macros to enumerations Stephen Hemminger
2013-06-25 23:26   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).