net: convert lists of macros to enumerations
Subsystems (2)
PATCH 1/2 net: convert lists of macros to enumerations
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.
--- include/linux/net.h | 15 +++++++++------ include/uapi/linux/net.h | 43 +++++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 26 deletions(-)
include/linux/net.h +9 -6
@@ -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 /**
include/uapi/linux/net.h +23 -20
49 lines not on this page · raw message
PATCH 2/2 net: uapi: do not manually set the first enumerator to zero
Clean up the unnecessary assignment of the first enumerator to zero.
--- include/uapi/linux/net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/net.h +1 -1
@@ -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 */
Quoted 5 lines · On Sun, 23 Jun 2013 15:56:16 -0600 Jean Sacren <[email protected]> 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 <[email protected]>
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.
David Miller
maintainerFrom: Stephen Hemminger <[email protected]>
Date: Mon, 24 Jun 2013 08:14:14 -0700
Quoted 12 lines
Quoted 5 lines · On Sun, 23 Jun 2013 15:56:16 -0600 Jean Sacren <[email protected]> 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 <[email protected]>Converting the network based header files is easy and safe as long as you test it. Not sure if it is worth the effort.
Quoted 8 lines
But changing the uapi exported header risks breaking applications that were doing:
#ifdef SIOCXXXX
do some code to enable that
#endifSince 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.