Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: kunit: use const qualifier for immutable data

Some data for testing is immutable. In the case, the const qualifier is
available for any loader to place it to read-only segment.

Fixes: 3e39acf56ede ("ALSA: core: Add sound core KUnit test")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <20240425233653.218434-1-o-takashi@sakamocchi.jp>

authored by

Takashi Sakamoto and committed by
Takashi Iwai
078c95fe 957a36c4

+4 -4
+4 -4
sound/core/sound_kunit.c
··· 45 45 snd_pcm_uframes_t expected_avail; 46 46 }; 47 47 48 - static struct snd_format_test_data valid_fmt[] = { 48 + static const struct snd_format_test_data valid_fmt[] = { 49 49 DEFINE_FORMAT(S8, 8, 8, -1, 1, SILENCE()), 50 50 DEFINE_FORMAT(U8, 8, 8, -1, 0, SILENCE(0x80)), 51 51 DEFINE_FORMAT(S16_LE, 16, 16, 1, 1, SILENCE()), ··· 154 154 KUNIT_EXPECT_EQ(test, snd_pcm_format_big_endian(WRONG_FORMAT_2), -EINVAL); 155 155 } 156 156 157 - static void _test_fill_silence(struct kunit *test, struct snd_format_test_data *data, 157 + static void _test_fill_silence(struct kunit *test, const struct snd_format_test_data *data, 158 158 u8 *buffer, size_t samples_count) 159 159 { 160 160 size_t sample_bytes = data->physical_bits >> 3; ··· 191 191 return boundary; 192 192 } 193 193 194 - static struct avail_test_data p_avail_data[] = { 194 + static const struct avail_test_data p_avail_data[] = { 195 195 /* buf_size + hw_ptr < appl_ptr => avail = buf_size + hw_ptr - appl_ptr + boundary */ 196 196 { 128, 1000, 1129, 1073741824UL - 1 }, 197 197 /* ··· 220 220 } 221 221 } 222 222 223 - static struct avail_test_data c_avail_data[] = { 223 + static const struct avail_test_data c_avail_data[] = { 224 224 /* hw_ptr - appl_ptr < 0 => avail = hw_ptr - appl_ptr + boundary */ 225 225 { 128, 1000, 1001, 1073741824UL - 1 }, 226 226 /* standard case: avail = hw_ptr - appl_ptr */