Commit 1b2e122d authored by Andy Shevchenko's avatar Andy Shevchenko Committed by J. Bruce Fields

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
[bfields@redhat.com: fix length calculation]
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent acf06a7f
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string_helpers.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
...@@ -1067,30 +1068,15 @@ void qword_add(char **bpp, int *lp, char *str) ...@@ -1067,30 +1068,15 @@ void qword_add(char **bpp, int *lp, char *str)
{ {
char *bp = *bpp; char *bp = *bpp;
int len = *lp; int len = *lp;
char c; int ret;
if (len < 0) return; if (len < 0) return;
while ((c=*str++) && len) ret = string_escape_str(str, &bp, len, ESCAPE_OCTAL, "\\ \n\t");
switch(c) { if (ret < 0 || ret == len)
case ' ': len = -1;
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;
else { else {
len -= ret;
*bp++ = ' '; *bp++ = ' ';
len--; len--;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment