[PATCH] net: add more sockopt options

Mike Frysinger vapier at gentoo.org
Fri Jan 31 06:27:14 UTC 2014


On Thursday, January 30, 2014 22:13:29 Mike Frysinger wrote:
> On Friday, January 31, 2014 04:24:50 Dmitry V. Levin wrote:
> > On Thu, Jan 30, 2014 at 06:53:43PM -0500, Mike Frysinger wrote:
> > > This syncs with the defines as available in linux-3.13.
> > 
> > Applied, thanks.
> > 
> > Wouldn't it be better to keep these constants sorted the same way as
> > they are sorted in uapi/linux/in.h?
> 
> they mostly are.  at least, that's how i imported them.  the problem is that
> strace supports more than just Linux which means there are more defines
> than just what's in uapi/linux/in.h.  we also can't sort it alphabetically
> because there are some compat defines that Linux carries but we don't want
> to decode first (e.g. IP_ORIGDSTADDR and IP_RECVORIGDSTADDR).
> 
> what would help i think with maintaining these files is a little macro that
> i use in other projects of mine:
> 	#define Q(x) { x, #x },
> then the lists become:
> static const struct xlat domains[] = {
> 	Q(PF_UNSPEC)
> 	Q(PF_LOCAL)
> 	Q(PF_UNIX)
> 	...
> };

blah i'm dumb and forgot about the #ifdef part.  it's still a bit cleaner 
though:

--- a/defs.h
+++ b/defs.h
@@ -503,6 +503,7 @@ struct xlat {
 	int val;
 	const char *str;
 };
+#define XLAT(x) { x, #x }
 
 extern const struct xlat open_mode_flags[];
 extern const struct xlat addrfams[];

--- a/mem.c
+++ b/mem.c

 static const struct xlat mmap_prot[] = {
-	{ PROT_NONE,	"PROT_NONE",	},
-	{ PROT_READ,	"PROT_READ"	},
-	{ PROT_WRITE,	"PROT_WRITE"	},
-	{ PROT_EXEC,	"PROT_EXEC"	},
+	XLAT(PROT_NONE),
+	XLAT(PROT_NONE),
+	XLAT(PROT_READ),
+	XLAT(PROT_WRITE),
+	XLAT(PROT_EXEC),
 #ifdef PROT_SEM
-	{ PROT_SEM,	"PROT_SEM"	},
+	XLAT(PROT_SEM),
 #endif
 #ifdef PROT_GROWSDOWN
-	{ PROT_GROWSDOWN,"PROT_GROWSDOWN"},
+	XLAT(PROT_GROWSDOWN),
 #endif
 #ifdef PROT_GROWSUP
-	{ PROT_GROWSUP, "PROT_GROWSUP"	},
+	XLAT(PROT_GROWSUP),
 #endif
 #ifdef PROT_SAO
-	{ PROT_SAO,	"PROT_SAO"	},
+	XLAT(PROT_SAO),
 #endif
 	{ 0,		NULL		},
 };
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20140131/4acfa7aa/attachment.bin>


More information about the Strace-devel mailing list