diff options
| author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2013-04-30 18:27:32 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-30 20:04:03 -0400 |
| commit | d338b1379f96b20e63aa65082e19e9a18a93b608 (patch) | |
| tree | fce537cd0f14c8664de42be3cc7f6465adf15b79 | |
| parent | 576d742e4a0d0f1bab7950012addccb82fbc172a (diff) | |
dynamic_debug: reuse generic string_unescape function
There is kernel function to do the job in generic way. Let's use it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Jason Baron <jbaron@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | lib/dynamic_debug.c | 48 |
1 files changed, 5 insertions, 43 deletions
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 46032453abd5..99fec3ae405a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/sysctl.h> | 24 | #include <linux/sysctl.h> |
| 25 | #include <linux/ctype.h> | 25 | #include <linux/ctype.h> |
| 26 | #include <linux/string.h> | 26 | #include <linux/string.h> |
| 27 | #include <linux/string_helpers.h> | ||
| 27 | #include <linux/uaccess.h> | 28 | #include <linux/uaccess.h> |
| 28 | #include <linux/dynamic_debug.h> | 29 | #include <linux/dynamic_debug.h> |
| 29 | #include <linux/debugfs.h> | 30 | #include <linux/debugfs.h> |
| @@ -276,47 +277,6 @@ static inline int parse_lineno(const char *str, unsigned int *val) | |||
| 276 | return 0; | 277 | return 0; |
| 277 | } | 278 | } |
| 278 | 279 | ||
| 279 | /* | ||
| 280 | * Undo octal escaping in a string, inplace. This is useful to | ||
| 281 | * allow the user to express a query which matches a format | ||
| 282 | * containing embedded spaces. | ||
| 283 | */ | ||
| 284 | static char *unescape(char *str) | ||
| 285 | { | ||
| 286 | char *in = str; | ||
| 287 | char *out = str; | ||
| 288 | |||
| 289 | while (*in) { | ||
| 290 | if (*in == '\\') { | ||
| 291 | if (in[1] == '\\') { | ||
| 292 | *out++ = '\\'; | ||
| 293 | in += 2; | ||
| 294 | continue; | ||
| 295 | } else if (in[1] == 't') { | ||
| 296 | *out++ = '\t'; | ||
| 297 | in += 2; | ||
| 298 | continue; | ||
| 299 | } else if (in[1] == 'n') { | ||
| 300 | *out++ = '\n'; | ||
| 301 | in += 2; | ||
| 302 | continue; | ||
| 303 | } else if (isodigit(in[1]) && | ||
| 304 | isodigit(in[2]) && | ||
| 305 | isodigit(in[3])) { | ||
| 306 | *out++ = (((in[1] - '0') << 6) | | ||
| 307 | ((in[2] - '0') << 3) | | ||
| 308 | (in[3] - '0')); | ||
| 309 | in += 4; | ||
| 310 | continue; | ||
| 311 | } | ||
| 312 | } | ||
| 313 | *out++ = *in++; | ||
| 314 | } | ||
| 315 | *out = '\0'; | ||
| 316 | |||
| 317 | return str; | ||
| 318 | } | ||
| 319 | |||
| 320 | static int check_set(const char **dest, char *src, char *name) | 280 | static int check_set(const char **dest, char *src, char *name) |
| 321 | { | 281 | { |
| 322 | int rc = 0; | 282 | int rc = 0; |
| @@ -370,8 +330,10 @@ static int ddebug_parse_query(char *words[], int nwords, | |||
| 370 | } else if (!strcmp(words[i], "module")) { | 330 | } else if (!strcmp(words[i], "module")) { |
| 371 | rc = check_set(&query->module, words[i+1], "module"); | 331 | rc = check_set(&query->module, words[i+1], "module"); |
| 372 | } else if (!strcmp(words[i], "format")) { | 332 | } else if (!strcmp(words[i], "format")) { |
| 373 | rc = check_set(&query->format, unescape(words[i+1]), | 333 | string_unescape_inplace(words[i+1], UNESCAPE_SPACE | |
| 374 | "format"); | 334 | UNESCAPE_OCTAL | |
| 335 | UNESCAPE_SPECIAL); | ||
| 336 | rc = check_set(&query->format, words[i+1], "format"); | ||
| 375 | } else if (!strcmp(words[i], "line")) { | 337 | } else if (!strcmp(words[i], "line")) { |
| 376 | char *first = words[i+1]; | 338 | char *first = words[i+1]; |
| 377 | char *last = strchr(first, '-'); | 339 | char *last = strchr(first, '-'); |
