[Xcb] [PATCH] auth: precompute authnamelens

Julien Danjou julien at danjou.info
Tue Apr 7 02:51:08 PDT 2009


Signed-off-by: Julien Danjou <julien at danjou.info>
---
I think that's a better practice and that is harmless, but
I would be really glad if someone can review this patch as it
is very trivial.

 src/xcb_auth.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/xcb_auth.c b/src/xcb_auth.c
index 93a6f68..1645ce8 100644
--- a/src/xcb_auth.c
+++ b/src/xcb_auth.c
@@ -56,6 +56,13 @@ static char *authnames[N_AUTH_PROTOS] = {
     "MIT-MAGIC-COOKIE-1",
 };
 
+static int authnamelens[N_AUTH_PROTOS] = {
+#ifdef HASXDMAUTH
+    sizeof("XDM-AUTHORIZATION-1") - 1,
+#endif
+    sizeof("MIT-MAGIC-COOKIE-1") - 1,
+};
+
 static size_t memdup(char **dst, void *src, size_t len)
 {
     if(len)
@@ -87,8 +94,6 @@ static Xauth *get_authptr(struct sockaddr *sockname, unsigned int socknamelen,
     unsigned short family;
     char hostnamebuf[256];   /* big enough for max hostname */
     char dispbuf[40];   /* big enough to hold more than 2^64 base 10 */
-    int authnamelens[N_AUTH_PROTOS];
-    int i;
 
     family = FamilyLocal; /* 256 */
     switch(sockname->sa_family)
@@ -128,8 +133,6 @@ static Xauth *get_authptr(struct sockaddr *sockname, unsigned int socknamelen,
         addrlen = strlen(addr);
     }
 
-    for (i = 0; i < N_AUTH_PROTOS; i++)
-	authnamelens[i] = strlen(authnames[i]);
     return XauGetBestAuthByAddr (family,
                                  (unsigned short) addrlen, addr,
                                  (unsigned short) strlen(dispbuf), dispbuf,
-- 
1.6.2.2



More information about the Xcb mailing list