[PATCH v7 03/10] drm/xe/devcoredump: Add ASCII85 dump helper function
Julia Filipchuk
julia.filipchuk at intel.com
Tue Sep 10 19:33:27 UTC 2024
> + if (prefix) {
> + strscpy(line_buff, prefix, DMESG_MAX_LINE_LEN - MIN_SPACE - 3);
> + line_pos = strlen(line_buff);
> +
> + line_buff[line_pos++] = ':';
> + line_buff[line_pos++] = ' ';
> + }
Since 2 characters are added to the end of prefix should the computation
for n be "DMESG_MAX_LINE_LEN - MIN_SPACE - 2"? MIN_SPACE already
accounts for space of trailing newline and null terminator.
Also, prefix is only added to the first line. Is that the intended behavior?
> + strscpy(line_buff + line_pos, ascii85_encode(val, buff),
> + DMESG_MAX_LINE_LEN - line_pos);
> + line_pos += strlen(line_buff + line_pos);
Since space for ASCII85_BUFSZ bytes is guaranteed by checks against
MIN_SPACE output of strscpy can be used to increment line_pos. Although
I do like this safer style that would work even if the checks failed.
> +#undef MIN_SPACE
Suggest to also #undef DMESG_MAX_LINE_LEN here.
Reviewed-by: Julia Filipchuk <julia.filipchuk at intel.com>
More information about the Intel-xe
mailing list