[Xcb] [PATCH 2/2] auth: use snprintf() return value
Julien Danjou
julien at danjou.info
Tue Apr 7 02:56:17 PDT 2009
That save us from a strlen().
Signed-off-by: Julien Danjou <julien at danjou.info>
---
src/xcb_auth.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/xcb_auth.c b/src/xcb_auth.c
index 1645ce8..7730c18 100644
--- a/src/xcb_auth.c
+++ b/src/xcb_auth.c
@@ -94,6 +94,7 @@ 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 dispbuflen;
family = FamilyLocal; /* 256 */
switch(sockname->sa_family)
@@ -124,7 +125,7 @@ static Xauth *get_authptr(struct sockaddr *sockname, unsigned int socknamelen,
return 0; /* cannot authenticate this family */
}
- snprintf(dispbuf, sizeof(dispbuf), "%d", display);
+ dispbuflen = snprintf(dispbuf, sizeof(dispbuf), "%d", display);
if (family == FamilyLocal) {
if (gethostname(hostnamebuf, sizeof(hostnamebuf)) == -1)
@@ -135,7 +136,7 @@ static Xauth *get_authptr(struct sockaddr *sockname, unsigned int socknamelen,
return XauGetBestAuthByAddr (family,
(unsigned short) addrlen, addr,
- (unsigned short) strlen(dispbuf), dispbuf,
+ (unsigned short) dispbuflen, dispbuf,
N_AUTH_PROTOS, authnames, authnamelens);
}
--
1.6.2.2
More information about the Xcb
mailing list