diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-26 12:52:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-26 12:52:05 -0400 |
commit | 47a469421d792dcb91a1e73319d26134241953d2 (patch) | |
tree | 6a388381a434ebe87fed2fbb10a53ced7a7ce8b5 /lib/bitmap.c | |
parent | c13c81006314ad76c2b31824960a900385601b8b (diff) | |
parent | 51229b495340bd7a02ce3622d1966829b67054ea (diff) |
Merge branch 'akpm' (patches from Andrew)
Merge second patchbomb from Andrew Morton:
- most of the rest of MM
- lots of misc things
- procfs updates
- printk feature work
- updates to get_maintainer, MAINTAINERS, checkpatch
- lib/ updates
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (96 commits)
exit,stats: /* obey this comment */
coredump: add __printf attribute to cn_*printf functions
coredump: use from_kuid/kgid when formatting corename
fs/reiserfs: remove unneeded cast
NILFS2: support NFSv2 export
fs/befs/btree.c: remove unneeded initializations
fs/minix: remove unneeded cast
init/do_mounts.c: add create_dev() failure log
kasan: remove duplicate definition of the macro KASAN_FREE_PAGE
fs/efs: femove unneeded cast
checkpatch: emit "NOTE: <types>" message only once after multiple files
checkpatch: emit an error when there's a diff in a changelog
checkpatch: validate MODULE_LICENSE content
checkpatch: add multi-line handling for PREFER_ETHER_ADDR_COPY
checkpatch: suggest using eth_zero_addr() and eth_broadcast_addr()
checkpatch: fix processing of MEMSET issues
checkpatch: suggest using ether_addr_equal*()
checkpatch: avoid NOT_UNIFIED_DIFF errors on cover-letter.patch files
checkpatch: remove local from codespell path
checkpatch: add --showfile to allow input via pipe to show filenames
...
Diffstat (limited to 'lib/bitmap.c')
-rw-r--r-- | lib/bitmap.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index 64c0926f5dd8..a578a0189199 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -462,19 +462,20 @@ EXPORT_SYMBOL(bitmap_parse_user); | |||
462 | * Output format is a comma-separated list of decimal numbers and | 462 | * Output format is a comma-separated list of decimal numbers and |
463 | * ranges if list is specified or hex digits grouped into comma-separated | 463 | * ranges if list is specified or hex digits grouped into comma-separated |
464 | * sets of 8 digits/set. Returns the number of characters written to buf. | 464 | * sets of 8 digits/set. Returns the number of characters written to buf. |
465 | * | ||
466 | * It is assumed that @buf is a pointer into a PAGE_SIZE area and that | ||
467 | * sufficient storage remains at @buf to accommodate the | ||
468 | * bitmap_print_to_pagebuf() output. | ||
465 | */ | 469 | */ |
466 | int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp, | 470 | int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp, |
467 | int nmaskbits) | 471 | int nmaskbits) |
468 | { | 472 | { |
469 | ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf - 2; | 473 | ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf; |
470 | int n = 0; | 474 | int n = 0; |
471 | 475 | ||
472 | if (len > 1) { | 476 | if (len > 1) |
473 | n = list ? scnprintf(buf, len, "%*pbl", nmaskbits, maskp) : | 477 | n = list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) : |
474 | scnprintf(buf, len, "%*pb", nmaskbits, maskp); | 478 | scnprintf(buf, len, "%*pb\n", nmaskbits, maskp); |
475 | buf[n++] = '\n'; | ||
476 | buf[n] = '\0'; | ||
477 | } | ||
478 | return n; | 479 | return n; |
479 | } | 480 | } |
480 | EXPORT_SYMBOL(bitmap_print_to_pagebuf); | 481 | EXPORT_SYMBOL(bitmap_print_to_pagebuf); |
@@ -506,12 +507,12 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen, | |||
506 | unsigned a, b; | 507 | unsigned a, b; |
507 | int c, old_c, totaldigits; | 508 | int c, old_c, totaldigits; |
508 | const char __user __force *ubuf = (const char __user __force *)buf; | 509 | const char __user __force *ubuf = (const char __user __force *)buf; |
509 | int exp_digit, in_range; | 510 | int at_start, in_range; |
510 | 511 | ||
511 | totaldigits = c = 0; | 512 | totaldigits = c = 0; |
512 | bitmap_zero(maskp, nmaskbits); | 513 | bitmap_zero(maskp, nmaskbits); |
513 | do { | 514 | do { |
514 | exp_digit = 1; | 515 | at_start = 1; |
515 | in_range = 0; | 516 | in_range = 0; |
516 | a = b = 0; | 517 | a = b = 0; |
517 | 518 | ||
@@ -540,11 +541,10 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen, | |||
540 | break; | 541 | break; |
541 | 542 | ||
542 | if (c == '-') { | 543 | if (c == '-') { |
543 | if (exp_digit || in_range) | 544 | if (at_start || in_range) |
544 | return -EINVAL; | 545 | return -EINVAL; |
545 | b = 0; | 546 | b = 0; |
546 | in_range = 1; | 547 | in_range = 1; |
547 | exp_digit = 1; | ||
548 | continue; | 548 | continue; |
549 | } | 549 | } |
550 | 550 | ||
@@ -554,16 +554,18 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen, | |||
554 | b = b * 10 + (c - '0'); | 554 | b = b * 10 + (c - '0'); |
555 | if (!in_range) | 555 | if (!in_range) |
556 | a = b; | 556 | a = b; |
557 | exp_digit = 0; | 557 | at_start = 0; |
558 | totaldigits++; | 558 | totaldigits++; |
559 | } | 559 | } |
560 | if (!(a <= b)) | 560 | if (!(a <= b)) |
561 | return -EINVAL; | 561 | return -EINVAL; |
562 | if (b >= nmaskbits) | 562 | if (b >= nmaskbits) |
563 | return -ERANGE; | 563 | return -ERANGE; |
564 | while (a <= b) { | 564 | if (!at_start) { |
565 | set_bit(a, maskp); | 565 | while (a <= b) { |
566 | a++; | 566 | set_bit(a, maskp); |
567 | a++; | ||
568 | } | ||
567 | } | 569 | } |
568 | } while (buflen && c == ','); | 570 | } while (buflen && c == ','); |
569 | return 0; | 571 | return 0; |