When specifying a frame buffer format like "RG16be" (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 7 bytes (6 characters +
NUL terminator).

Signed-off-by: Geert Uytterhoeven <[email protected]>
---
v2:
  - New.
---
 tests/modetest/modetest.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index f70043d1e6815497..7c6c21ef5174c41a 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -821,7 +821,7 @@ struct pipe_arg {
        unsigned int num_cons;
        uint32_t crtc_id;
        char mode_str[64];
-       char format_str[5];
+       char format_str[7];
        float vrefresh;
        unsigned int fourcc;
        drmModeModeInfo *mode;
@@ -843,7 +843,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[7]; /* need to leave room for "be" and terminating \0 */
        unsigned int fourcc;
 };
 
@@ -1917,8 +1917,8 @@ 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';
+               strncpy(pipe->format_str, p + 1, 6);
+               pipe->format_str[6] = '\0';
        }
 
        pipe->fourcc = util_format_fourcc(pipe->format_str);
@@ -1970,8 +1970,8 @@ 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';
+               strncpy(plane->format_str, end + 1, 6);
+               plane->format_str[6] = '\0';
        } else {
                strcpy(plane->format_str, "XR24");
        }
-- 
2.25.1

Reply via email to