2023-11-15 15:51:24

by David Howells

[permalink] [raw]
Subject: [PATCH v3 01/10] iov_iter: Fix some checkpatch complaints in kunit tests

Fix some checkpatch complaints in the new iov_iter kunit tests:

(1) Some lines had eight spaces instead of a tab at the start.

(2) Checkpatch doesn't like (void*)(unsigned long)0xnnnnnULL, so switch to
using POISON_POINTER_DELTA plus an offset instead.

Reported-by: Johannes Thumshirn <[email protected]>
Signed-off-by: David Howells <[email protected]>
cc: Christoph Hellwig <[email protected]>
cc: Christian Brauner <[email protected]>
cc: Jens Axboe <[email protected]>
cc: Al Viro <[email protected]>
cc: David Hildenbrand <[email protected]>
cc: John Hubbard <[email protected]>
cc: Brendan Higgins <[email protected]>
cc: David Gow <[email protected]>
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
---
lib/kunit_iov_iter.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/kunit_iov_iter.c b/lib/kunit_iov_iter.c
index 859b67c4d697..4a6c0efd33f5 100644
--- a/lib/kunit_iov_iter.c
+++ b/lib/kunit_iov_iter.c
@@ -53,7 +53,7 @@ static void *__init iov_kunit_create_buffer(struct kunit *test,
void *buffer;

pages = kunit_kcalloc(test, npages, sizeof(struct page *), GFP_KERNEL);
- KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pages);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pages);
*ppages = pages;

got = alloc_pages_bulk_array(GFP_KERNEL, npages, pages);
@@ -63,7 +63,7 @@ static void *__init iov_kunit_create_buffer(struct kunit *test,
}

buffer = vmap(pages, npages, VM_MAP | VM_MAP_PUT_PAGES, PAGE_KERNEL);
- KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buffer);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buffer);

kunit_add_action_or_reset(test, iov_kunit_unmap, buffer);
return buffer;
@@ -548,7 +548,7 @@ static void __init iov_kunit_extract_pages_kvec(struct kunit *test)
size_t offset0 = LONG_MAX;

for (i = 0; i < ARRAY_SIZE(pagelist); i++)
- pagelist[i] = (void *)(unsigned long)0xaa55aa55aa55aa55ULL;
+ pagelist[i] = (void *)POISON_POINTER_DELTA + 0x5a;

len = iov_iter_extract_pages(&iter, &pages, 100 * 1024,
ARRAY_SIZE(pagelist), 0, &offset0);
@@ -626,7 +626,7 @@ static void __init iov_kunit_extract_pages_bvec(struct kunit *test)
size_t offset0 = LONG_MAX;

for (i = 0; i < ARRAY_SIZE(pagelist); i++)
- pagelist[i] = (void *)(unsigned long)0xaa55aa55aa55aa55ULL;
+ pagelist[i] = (void *)POISON_POINTER_DELTA + 0x5a;

len = iov_iter_extract_pages(&iter, &pages, 100 * 1024,
ARRAY_SIZE(pagelist), 0, &offset0);
@@ -709,7 +709,7 @@ static void __init iov_kunit_extract_pages_xarray(struct kunit *test)
size_t offset0 = LONG_MAX;

for (i = 0; i < ARRAY_SIZE(pagelist); i++)
- pagelist[i] = (void *)(unsigned long)0xaa55aa55aa55aa55ULL;
+ pagelist[i] = (void *)POISON_POINTER_DELTA + 0x5a;

len = iov_iter_extract_pages(&iter, &pages, 100 * 1024,
ARRAY_SIZE(pagelist), 0, &offset0);


2023-11-16 04:01:02

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH v3 01/10] iov_iter: Fix some checkpatch complaints in kunit tests

On Wed, 2023-11-15 at 15:49 +0000, David Howells wrote:
> Fix some checkpatch complaints in the new iov_iter kunit tests:
>
> (1) Some lines had eight spaces instead of a tab at the start.
>
> (2) Checkpatch doesn't like (void*)(unsigned long)0xnnnnnULL, so switch to
> using POISON_POINTER_DELTA plus an offset instead.

That's because checkpatch is fundamentally stupid and
that's a false positive.

> diff --git a/lib/kunit_iov_iter.c b/lib/kunit_iov_iter.c
[]
> @@ -548,7 +548,7 @@ static void __init iov_kunit_extract_pages_kvec(struct kunit *test)
> size_t offset0 = LONG_MAX;
>
> for (i = 0; i < ARRAY_SIZE(pagelist); i++)
> - pagelist[i] = (void *)(unsigned long)0xaa55aa55aa55aa55ULL;
> + pagelist[i] = (void *)POISON_POINTER_DELTA + 0x5a;

I think the original is easier to understand
or would best be replaced by a single #define
without the addition.

> @@ -626,7 +626,7 @@ static void __init iov_kunit_extract_pages_bvec(struct kunit *test)
> size_t offset0 = LONG_MAX;
>
> for (i = 0; i < ARRAY_SIZE(pagelist); i++)
> - pagelist[i] = (void *)(unsigned long)0xaa55aa55aa55aa55ULL;
> + pagelist[i] = (void *)POISON_POINTER_DELTA + 0x5a;

etc...