diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2014-11-28 17:50:28 +0200 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-12-09 11:30:20 -0500 |
commit | 1b2e122d167d8983775eb57d55349c331e6aa6c7 (patch) | |
tree | fdddc65373252c4ba53a97e7ffafd8c43ac6f2a5 /net/sunrpc | |
parent | acf06a7fa12070abb3eab24fc4bc30e361a7c416 (diff) | |
download | blackbird-op-linux-1b2e122d167d8983775eb57d55349c331e6aa6c7.tar.gz blackbird-op-linux-1b2e122d167d8983775eb57d55349c331e6aa6c7.zip |
sunrpc/cache: convert to use string_escape_str()
There is nice kernel helper to escape a given strings by provided rules. Let's
use it instead of custom approach.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
[bfields@redhat.com: fix length calculation]
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/cache.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 066362141133..33fb105d4352 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -20,6 +20,7 @@ #include <linux/list.h> #include <linux/module.h> #include <linux/ctype.h> +#include <linux/string_helpers.h> #include <asm/uaccess.h> #include <linux/poll.h> #include <linux/seq_file.h> @@ -1067,30 +1068,15 @@ void qword_add(char **bpp, int *lp, char *str) { char *bp = *bpp; int len = *lp; - char c; + int ret; if (len < 0) return; - while ((c=*str++) && len) - switch(c) { - case ' ': - case '\t': - case '\n': - case '\\': - if (len >= 4) { - *bp++ = '\\'; - *bp++ = '0' + ((c & 0300)>>6); - *bp++ = '0' + ((c & 0070)>>3); - *bp++ = '0' + ((c & 0007)>>0); - } - len -= 4; - break; - default: - *bp++ = c; - len--; - } - if (c || len <1) len = -1; + ret = string_escape_str(str, &bp, len, ESCAPE_OCTAL, "\\ \n\t"); + if (ret < 0 || ret == len) + len = -1; else { + len -= ret; *bp++ = ' '; len--; } |