From 484acdad88fd307cf53942fe8297d74640380292 Mon Sep 17 00:00:00 2001 From: Latchesar Ionkov Date: Fri, 3 Feb 2006 03:04:18 -0800 Subject: [PATCH] --- yaml --- r: 19649 b: refs/heads/master c: 05818a004a84951fd383694f3b35d89eb49fa308 h: refs/heads/master i: 19647: 83e5caee0c24a8cd3a8a072fb8e824f0a08f64be v: v3 --- [refs] | 2 +- trunk/fs/9p/conv.c | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/[refs] b/[refs] index 90f74b9d729b..d37ba7122598 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 93c615feffbcea4f09ecee154f46062f6041776e +refs/heads/master: 05818a004a84951fd383694f3b35d89eb49fa308 diff --git a/trunk/fs/9p/conv.c b/trunk/fs/9p/conv.c index 32a9f99154e2..bf1f10067960 100644 --- a/trunk/fs/9p/conv.c +++ b/trunk/fs/9p/conv.c @@ -116,13 +116,19 @@ static void buf_put_int64(struct cbuf *buf, u64 val) } } -static void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) +static char *buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) { + char *ret; + + ret = NULL; if (buf_check_size(buf, slen + 2)) { buf_put_int16(buf, slen); + ret = buf->p; memcpy(buf->p, s, slen); buf->p += slen; } + + return ret; } static inline void buf_put_string(struct cbuf *buf, const char *s) @@ -430,15 +436,19 @@ static inline void v9fs_put_int64(struct cbuf *bufp, u64 val, u64 * p) static void v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str) { - if (data) { - str->len = strlen(data); - str->str = bufp->p; - } else { - str->len = 0; - str->str = NULL; - } + int len; + char *s; + + if (data) + len = strlen(data); + else + len = 0; - buf_put_stringn(bufp, data, str->len); + s = buf_put_stringn(bufp, data, len); + if (str) { + str->len = len; + str->str = s; + } } static int