Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bitmap: add test_zero_nbits()

In most real-life cases, 0-length bitmap provided by user is a sign of
an error. The API doesn't provide any guarantees on returned value, and
the bitmap pointers are not dereferenced.

Signed-off-by: Yury Norov <ynorov@nvidia.com>

+59
+2
lib/bitmap.c
··· 69 69 tmp = (bitmap1[k] | bitmap2[k]) ^ bitmap3[k]; 70 70 return (tmp & BITMAP_LAST_WORD_MASK(bits)) == 0; 71 71 } 72 + EXPORT_SYMBOL(__bitmap_or_equal); 72 73 73 74 void __bitmap_complement(unsigned long *dst, const unsigned long *src, unsigned int bits) 74 75 { ··· 361 360 { 362 361 return BITMAP_WEIGHT(({dst[idx] = bitmap1[idx] | bitmap2[idx]; dst[idx]; }), bits); 363 362 } 363 + EXPORT_SYMBOL(__bitmap_weighted_or); 364 364 365 365 void __bitmap_set(unsigned long *map, unsigned int start, int len) 366 366 {
+57
lib/test_bitmap.c
··· 1467 1467 pr_info("%s:\t\t%llu\n", __func__, time); 1468 1468 } 1469 1469 1470 + /* 1471 + * nbits == 0 is most commonly not a valid case. Bitmap users should revisit 1472 + * the caller logic. Bitmap API doesn't provide any guarantees on returned 1473 + * value. The pointers are not dereferenced. The return value is intentionally 1474 + * ignored. 1475 + */ 1476 + static void __init test_zero_nbits(void) 1477 + { 1478 + static volatile __always_used unsigned long ret __initdata; 1479 + 1480 + bitmap_clear(NULL, 0, 0); 1481 + bitmap_complement(NULL, NULL, 0); 1482 + bitmap_copy(NULL, NULL, 0); 1483 + bitmap_copy_clear_tail(NULL, NULL, 0); 1484 + bitmap_fill(NULL, 0); 1485 + bitmap_from_arr32(NULL, NULL, 0); 1486 + bitmap_from_arr64(NULL, NULL, 0); 1487 + bitmap_or(NULL, NULL, NULL, 0); 1488 + bitmap_set(NULL, 0, 0); 1489 + bitmap_shift_left(NULL, NULL, 0, 0); 1490 + bitmap_shift_right(NULL, NULL, 0, 0); 1491 + bitmap_to_arr32(NULL, NULL, 0); 1492 + bitmap_to_arr64(NULL, NULL, 0); 1493 + bitmap_write(NULL, 0, 0, 0); 1494 + bitmap_xor(NULL, NULL, NULL, 0); 1495 + bitmap_zero(NULL, 0); 1496 + 1497 + ret = bitmap_and(NULL, NULL, NULL, 0); 1498 + ret = bitmap_empty(NULL, 0); 1499 + ret = bitmap_equal(NULL, NULL, 0); 1500 + ret = bitmap_full(NULL, 0); 1501 + ret = bitmap_or_equal(NULL, NULL, NULL, 0); 1502 + ret = bitmap_read(NULL, 0, 0); 1503 + ret = bitmap_subset(NULL, NULL, 0); 1504 + ret = bitmap_weight(NULL, 0); 1505 + ret = bitmap_weight_and(NULL, NULL, 0); 1506 + ret = bitmap_weight_andnot(NULL, NULL, 0); 1507 + ret = bitmap_weight_from(NULL, 0, 0); 1508 + ret = bitmap_weighted_or(NULL, NULL, NULL, 0); 1509 + 1510 + ret = find_first_and_and_bit(NULL, NULL, NULL, 0); 1511 + ret = find_first_and_bit(NULL, NULL, 0); 1512 + ret = find_first_andnot_bit(NULL, NULL, 0); 1513 + ret = find_first_bit(NULL, 0); 1514 + ret = find_first_zero_bit(NULL, 0); 1515 + ret = find_last_bit(NULL, 0); 1516 + ret = find_next_and_bit(NULL, NULL, 0, 0); 1517 + ret = find_next_andnot_bit(NULL, NULL, 0, 0); 1518 + ret = find_next_bit(NULL, 0, 0); 1519 + ret = find_next_clump8(NULL, NULL, 0, 0); 1520 + ret = find_next_zero_bit(NULL, 0, 0); 1521 + ret = find_nth_and_bit(NULL, NULL, 0, 0); 1522 + ret = find_nth_bit(NULL, 0, 0); 1523 + ret = find_random_bit(NULL, 0); 1524 + } 1525 + 1470 1526 #undef TEST_BIT_LEN 1471 1527 1472 1528 static void __init selftest(void) ··· 1546 1490 test_bitmap_read_perf(); 1547 1491 test_bitmap_weight(); 1548 1492 test_bitmap_write_perf(); 1493 + test_zero_nbits(); 1549 1494 1550 1495 test_find_nth_bit(); 1551 1496 test_for_each_set_bit();