Re: [PATCH v8 1/6] selftests/mm: make file helpers return errors
From: Sarthak Sharma
Date: Mon Aug 31 2026 - 01:17:11 EST
Hi Lance!
On 8/31/26 10:22 AM, Lance Yang wrote:
>
> On Mon, Aug 31, 2026 at 09:50:56AM +0530, Sarthak Sharma wrote:
> [...]
>> diff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftests/mm/vm_util.h
>> index 9a49af88702e..62f6f5b42649 100644
>> --- a/tools/testing/selftests/mm/vm_util.h
>> +++ b/tools/testing/selftests/mm/vm_util.h
>> @@ -166,11 +166,11 @@ int unpoison_memory(unsigned long pfn);
>> #define PAGEMAP_PRESENT(ent) (((ent) & (1ull << 63)) != 0)
>> #define PAGEMAP_PFN(ent) ((ent) & ((1ull << 55) - 1))
>>
>> -void write_file(const char *path, const char *buf, size_t buflen);
>> +int write_file(const char *path, const char *buf, size_t buflen);
>> int read_file(const char *path, char *buf, size_t buflen);
>> -unsigned long read_num(const char *path);
>> -void write_num(const char *path, unsigned long num);
>> -void write_num_ignore_einval(const char *path, unsigned long num);
>> +int read_num(const char *path, unsigned long *num);
>> +int write_num(const char *path, unsigned long num);
>> +int write_num_ignore_einval(const char *path, unsigned long num);
>
> Ouch ...
>
> Looks like this conversion misses hugetlb-soft-offline.c ...
>
> TEST_GEN_FILES += hugetlb-soft-offline
>
> int main(int argc, char **argv)
> {
> ...
> orig_enable_soft_offline = read_num(ENABLE_SOFT_OFFLINE_PATH);
Thanks for pointing it out.
This call was added very recently, and I missed to update it while
rebasing. I'll fix this.
> ...
> }
>
> And the compiler isn't happy:
>
> tools/testing/selftests/mm/hugetlb-soft-offline.c:199:36:
> error: too few arguments to function 'read_num'
> 199 | orig_enable_soft_offline = read_num(ENABLE_SOFT_OFFLINE_PATH);
> tools/lib/mm/file_utils.h:9:5: note: declared here
> 9 | int read_num(const char *path, unsigned long *num);
>
> Cheers, Lance
>
> [...]