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            },
 };

Attachment: signature.asc
Description: This is a digitally signed message part.

------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to