Thread View: linux.kernel.git
1 messages
1 total messages
Started by Andy Koppe
Sun, 22 Nov 2026 07:25
Re: [PATCH v4 1/5] utf8: introduce bounds for display_mode_esc_sequence_len()
Author: Andy Koppe
Date: Sun, 22 Nov 2026 07:25
Date: Sun, 22 Nov 2026 07:25
23 lines
12354 bytes
12354 bytes
On Fri, 20 Nov 2026 at 15:11, Dirk Gouders wrote:
> +void test_utf8_ansi__sgr_len_end_ptr(void)
> +{
> + char *sgr_1 = (char *)"\033[m";
> + char *sgr_2 = (char *)"\033[31m";
> + char *sgr_3 = (char *)"\033[31;m";
> + char *sgr_4 = (char *)"\033[31;0m";
> +
> + cl_assert_equal_i(0, display_mode_esc_sequence_len("", ""));
Strictly speaking, that's undefined behaviour, because it makes
display_mode_esc_sequence_len() compare pointers to different objects.
In practice, the compiler will pass a pointer to the same empty string
for both arguments, but the test should not rely on that.
> + cl_assert_equal_i(6, display_mode_esc_sequence_len(sgr_3, sgr_3 + sizeof(sgr_3) - 1));
> + cl_assert_equal_i(7, display_mode_esc_sequence_len(sgr_4, sgr_4 + sizeof(sgr_4) - 1));
Those sizeofs return the sizes of the pointers rather than the strings
as intended. (And the lines are a bit long.)
Andy
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads