diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2022-07-03 14:35:49 +0200 |
---|---|---|
committer | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2023-10-31 13:24:32 +0000 |
commit | bc37db5c669f850dc785acd723fdd79cdb7c597b (patch) | |
tree | b6750a4c73c6237e5cd3cfef21decf9cf0e47c94 | |
parent | 9d7024218f80c15465314eb9a07ffcffe5beae50 (diff) | |
download | libdrm-bc37db5c669f850dc785acd723fdd79cdb7c597b.tar.gz libdrm-bc37db5c669f850dc785acd723fdd79cdb7c597b.tar.bz2 libdrm-bc37db5c669f850dc785acd723fdd79cdb7c597b.zip |
modetest: add support for parsing big-endian formats
When specifying a frame buffer format like "RG16_BE" (big-endian RG16),
modetest still uses the little-endian variant, as the format string is
truncated to four characters.
Fix this by increasing the format string size to 8 bytes (7 characters +
NUL terminator).
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- No changes,
v3:
- Update for suffix change from "be" to "_BE", cfr. commit
ffb9375a505700ad ("xf86drm: handle DRM_FORMAT_BIG_ENDIAN in
drmGetFormatName()"),
- Replace hardcoded numbers in code by sizeof(),
v2:
- New.
-rw-r--r-- | tests/modetest/modetest.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 9b1aa537..cc96015f 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -817,7 +817,7 @@ struct pipe_arg { unsigned int num_cons; uint32_t crtc_id; char mode_str[64]; - char format_str[5]; + char format_str[8]; /* need to leave room for "_BE" and terminating \0 */ float vrefresh; unsigned int fourcc; drmModeModeInfo *mode; @@ -841,7 +841,7 @@ struct plane_arg { unsigned int old_fb_id; struct bo *bo; struct bo *old_bo; - char format_str[5]; /* need to leave room for terminating \0 */ + char format_str[8]; /* need to leave room for "_BE" and terminating \0 */ unsigned int fourcc; }; @@ -2032,8 +2032,9 @@ static int parse_connector(struct pipe_arg *pipe, const char *arg) } if (*p == '@') { - strncpy(pipe->format_str, p + 1, 4); - pipe->format_str[4] = '\0'; + len = sizeof(pipe->format_str) - 1; + strncpy(pipe->format_str, p + 1, len); + pipe->format_str[len] = '\0'; } pipe->fourcc = util_format_fourcc(pipe->format_str); @@ -2047,6 +2048,7 @@ static int parse_connector(struct pipe_arg *pipe, const char *arg) static int parse_plane(struct plane_arg *plane, const char *p) { + unsigned int len; char *end; plane->plane_id = strtoul(p, &end, 10); @@ -2085,8 +2087,9 @@ static int parse_plane(struct plane_arg *plane, const char *p) } if (*end == '@') { - strncpy(plane->format_str, end + 1, 4); - plane->format_str[4] = '\0'; + len = sizeof(plane->format_str) - 1; + strncpy(plane->format_str, end + 1, len); + plane->format_str[len] = '\0'; } else { strcpy(plane->format_str, "XR24"); } |