Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch introduces a KUnit test regression by unconditionally appending a human-readable resource size for memory ranges, affecting the raw '%pr' format as well as the decoded '%pR' format. The commit message states it adds the size to '%pR', but the code incorrectly modifies both formats, breaking the printf test suite.
--
--- Patch [1]: [PATCH v1 1/2] vsprintf: Add %pR human-readable size ---
commit d77ec66543a5589a88168c27ffcdb3693182c105
Author: Bjorn Helgaas <[email protected]>
vsprintf: Add %pR human-readable size
Include human-readable size when printing struct resource memory ranges
with the %pR format to make it easier to read.
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 2bc6ef483576c..c49044b6dbeeb 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
[ ... ]
> @@ -1134,6 +1136,14 @@ char *resource_string(char *buf, char *end, struct resource *res,
> } else {
> p = hex_range(p, pend, res->start, res->end, *specp);
> }
> + if (res->flags & IORESOURCE_MEM) {
> + *p++ = ' ';
> + *p++ = '(';
> + string_get_size(resource_size(res), 1, STRING_UNITS_2,
> + size_buf, sizeof(size_buf));
> + p = string_nocheck(p, pend, size_buf, str_spec);
> + *p++ = ')';
> + }
[Severity: Medium]
Does this code inadvertently modify the raw '%pr' format as well?
The commit message states it adds the size to '%pR', but this check doesn't
verify the 'decode' boolean before appending the human-readable size.
This unconditionally appends the human-readable resource size for memory ranges,
which affects the raw '%pr' format and breaks KUnit tests expecting the
unmodified output:
lib/tests/printf_kunit.c:struct_resource() {
...
test("[mem 0xc0ffee00 flags 0x200]",
"%pr", &test_resource);
...
}
> if (decode) {
> if (res->flags & IORESOURCE_MEM_64)
> p = string_nocheck(p, pend, " 64bit", str_spec);
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.