modpost: remove use of non-standard strsep() in HOSTCC code
authorH. Nikolaus Schaller <hns@goldelico.com>
Wed, 1 Jul 2020 06:18:27 +0000 (08:18 +0200)
committerMasahiro Yamada <masahiroy@kernel.org>
Tue, 7 Jul 2020 02:21:00 +0000 (11:21 +0900)
commit736bb11898ef748da1d805f40d485b66ceac9a3c
treeed1b6ca37a65a471fded63ad12655d6ce75af48b
parentdcb7fd82c75ee2d6e6f9d8cc71c52519ed52e258
modpost: remove use of non-standard strsep() in HOSTCC code

strsep() is neither standard C nor POSIX and used outside
the kernel code here. Using it here requires that the
build host supports it out of the box which is e.g.
not true for a Darwin build host and using a cross-compiler.
This leads to:

scripts/mod/modpost.c:145:2: warning: implicit declaration of function 'strsep' [-Wimplicit-function-declaration]
  return strsep(stringp, "\n");
  ^

and a segfault when running MODPOST.

See also: https://stackoverflow.com/a/7219504

So let's replace this by strchr() instead of using strsep().
It does not hurt kernel size or speed since this code is run
on the build host.

Fixes: ac5100f5432967 ("modpost: add read_text_file() and get_line() helpers")
Co-developed-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/mod/modpost.c