Re: [PATCH 02/28] include: remove unnecessary #include directives

From: kernel test robot
Date: Fri Feb 02 2024 - 18:59:48 EST


Hi Max,

kernel test robot noticed the following build warnings:

[auto build test WARNING on next-20240131]
[cannot apply to mkp-scsi/for-next jejb-scsi/for-next axboe-block/for-next linus/master v6.8-rc2 v6.8-rc1 v6.7 v6.8-rc2]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Max-Kellermann/include-add-missing-includes/20240131-231042
base: next-20240131
patch link: https://lore.kernel.org/r/20240131145008.1345531-3-max.kellermann%40ionos.com
patch subject: [PATCH 02/28] include: remove unnecessary #include directives
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20240203/202402030722.nMzDpW9K-lkp@xxxxxxxxx/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240203/202402030722.nMzDpW9K-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402030722.nMzDpW9K-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

lib/kunit/string-stream-test.c: In function 'string_stream_variable_length_line_test':
lib/kunit/string-stream-test.c:230:26: error: storage size of 'rnd' isn't known
230 | struct rnd_state rnd;
| ^~~
lib/kunit/string-stream-test.c:243:9: error: implicit declaration of function 'prandom_seed_state' [-Werror=implicit-function-declaration]
243 | prandom_seed_state(&rnd, 3141592653589793238ULL);
| ^~~~~~~~~~~~~~~~~~
lib/kunit/string-stream-test.c:246:26: error: implicit declaration of function 'prandom_u32_state' [-Werror=implicit-function-declaration]
246 | offset = prandom_u32_state(&rnd) % (sizeof(line) - 1);
| ^~~~~~~~~~~~~~~~~
>> lib/kunit/string-stream-test.c:230:26: warning: unused variable 'rnd' [-Wunused-variable]
230 | struct rnd_state rnd;
| ^~~
cc1: some warnings being treated as errors


vim +/rnd +230 lib/kunit/string-stream-test.c

4551caca6ab67f Richard Fitzgerald 2023-08-28 222
4551caca6ab67f Richard Fitzgerald 2023-08-28 223 /* Add a series of lines of variable length to a string_stream. */
4551caca6ab67f Richard Fitzgerald 2023-08-28 224 static void string_stream_variable_length_line_test(struct kunit *test)
4551caca6ab67f Richard Fitzgerald 2023-08-28 225 {
4551caca6ab67f Richard Fitzgerald 2023-08-28 226 static const char line[] =
4551caca6ab67f Richard Fitzgerald 2023-08-28 227 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
4551caca6ab67f Richard Fitzgerald 2023-08-28 228 " 0123456789!$%^&*()_-+={}[]:;@'~#<>,.?/|";
4551caca6ab67f Richard Fitzgerald 2023-08-28 229 struct string_stream *stream;
4551caca6ab67f Richard Fitzgerald 2023-08-28 @230 struct rnd_state rnd;
4551caca6ab67f Richard Fitzgerald 2023-08-28 231 char *concat_string, *pos, *string_end;
4551caca6ab67f Richard Fitzgerald 2023-08-28 232 size_t offset, total_len;
4551caca6ab67f Richard Fitzgerald 2023-08-28 233 int num_lines, i;
4551caca6ab67f Richard Fitzgerald 2023-08-28 234
20631e154c78f4 Richard Fitzgerald 2023-08-28 235 stream = kunit_alloc_string_stream(test, GFP_KERNEL);
4551caca6ab67f Richard Fitzgerald 2023-08-28 236 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream);
4551caca6ab67f Richard Fitzgerald 2023-08-28 237
4551caca6ab67f Richard Fitzgerald 2023-08-28 238 /*
4551caca6ab67f Richard Fitzgerald 2023-08-28 239 * Log many lines of varying lengths until we have created
4551caca6ab67f Richard Fitzgerald 2023-08-28 240 * many fragments.
4551caca6ab67f Richard Fitzgerald 2023-08-28 241 * The "randomness" must be repeatable.
4551caca6ab67f Richard Fitzgerald 2023-08-28 242 */
4551caca6ab67f Richard Fitzgerald 2023-08-28 243 prandom_seed_state(&rnd, 3141592653589793238ULL);
4551caca6ab67f Richard Fitzgerald 2023-08-28 244 total_len = 0;
4551caca6ab67f Richard Fitzgerald 2023-08-28 245 for (i = 0; i < 100; ++i) {
4551caca6ab67f Richard Fitzgerald 2023-08-28 246 offset = prandom_u32_state(&rnd) % (sizeof(line) - 1);
4551caca6ab67f Richard Fitzgerald 2023-08-28 247 string_stream_add(stream, "%s\n", &line[offset]);
4551caca6ab67f Richard Fitzgerald 2023-08-28 248 total_len += sizeof(line) - offset;
4551caca6ab67f Richard Fitzgerald 2023-08-28 249 }
4551caca6ab67f Richard Fitzgerald 2023-08-28 250 num_lines = i;
4551caca6ab67f Richard Fitzgerald 2023-08-28 251
4551caca6ab67f Richard Fitzgerald 2023-08-28 252 concat_string = get_concatenated_string(test, stream);
4551caca6ab67f Richard Fitzgerald 2023-08-28 253 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, concat_string);
4551caca6ab67f Richard Fitzgerald 2023-08-28 254 KUNIT_EXPECT_EQ(test, strlen(concat_string), total_len);
4551caca6ab67f Richard Fitzgerald 2023-08-28 255
4551caca6ab67f Richard Fitzgerald 2023-08-28 256 /*
4551caca6ab67f Richard Fitzgerald 2023-08-28 257 * Split the concatenated string at the newlines and check that
4551caca6ab67f Richard Fitzgerald 2023-08-28 258 * all the original added strings are present.
4551caca6ab67f Richard Fitzgerald 2023-08-28 259 */
4551caca6ab67f Richard Fitzgerald 2023-08-28 260 prandom_seed_state(&rnd, 3141592653589793238ULL);
4551caca6ab67f Richard Fitzgerald 2023-08-28 261 pos = concat_string;
4551caca6ab67f Richard Fitzgerald 2023-08-28 262 for (i = 0; i < num_lines; ++i) {
4551caca6ab67f Richard Fitzgerald 2023-08-28 263 string_end = strchr(pos, '\n');
4551caca6ab67f Richard Fitzgerald 2023-08-28 264 KUNIT_EXPECT_NOT_NULL(test, string_end);
4551caca6ab67f Richard Fitzgerald 2023-08-28 265
4551caca6ab67f Richard Fitzgerald 2023-08-28 266 /* Convert to NULL-terminated string */
4551caca6ab67f Richard Fitzgerald 2023-08-28 267 *string_end = '\0';
4551caca6ab67f Richard Fitzgerald 2023-08-28 268
4551caca6ab67f Richard Fitzgerald 2023-08-28 269 offset = prandom_u32_state(&rnd) % (sizeof(line) - 1);
4551caca6ab67f Richard Fitzgerald 2023-08-28 270 KUNIT_EXPECT_STREQ(test, pos, &line[offset]);
4551caca6ab67f Richard Fitzgerald 2023-08-28 271
4551caca6ab67f Richard Fitzgerald 2023-08-28 272 pos = string_end + 1;
4551caca6ab67f Richard Fitzgerald 2023-08-28 273 }
4551caca6ab67f Richard Fitzgerald 2023-08-28 274
4551caca6ab67f Richard Fitzgerald 2023-08-28 275 /* There shouldn't be any more data after this */
4551caca6ab67f Richard Fitzgerald 2023-08-28 276 KUNIT_EXPECT_EQ(test, strlen(pos), 0);
4551caca6ab67f Richard Fitzgerald 2023-08-28 277 }
4551caca6ab67f Richard Fitzgerald 2023-08-28 278

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki