aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/modpost.c
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2020-06-01 14:57:20 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2020-06-06 23:38:13 +0900
commit70f30cfe5b892fcb7f98e7df72ed6ccfe3225628 (patch)
tree5c5026083bab0d89b97a1e9f33a363abd3bd162b /scripts/mod/modpost.c
parentmodpost: avoid false-positive file open error (diff)
downloadlinux-dev-70f30cfe5b892fcb7f98e7df72ed6ccfe3225628.tar.xz
linux-dev-70f30cfe5b892fcb7f98e7df72ed6ccfe3225628.zip
modpost: use read_text_file() and get_line() for reading text files
grab_file() mmaps a file, but it is not so efficient here because get_next_line() copies every line to the temporary buffer anyway. read_text_file() and get_line() are simpler. get_line() exploits the library function strchr(). Going forward, the missing *.symvers or *.cmd is a fatal error. This should not happen because scripts/Makefile.modpost guards the -i option files with $(wildcard $(input-symdump)). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to '')
-rw-r--r--scripts/mod/modpost.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0a844902998e..4fdf992e9729 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2481,15 +2481,16 @@ static void write_if_changed(struct buffer *b, const char *fname)
**/
static void read_dump(const char *fname)
{
- unsigned long size, pos = 0;
- void *file = grab_file(fname, &size);
- char *line;
+ char *buf, *pos, *line;
- if (!file)
+ buf = read_text_file(fname);
+ if (!buf)
/* No symbol versions, silently ignore */
return;
- while ((line = get_next_line(&pos, file, size))) {
+ pos = buf;
+
+ while ((line = get_line(&pos))) {
char *symname, *namespace, *modname, *d, *export;
unsigned int crc;
struct module *mod;
@@ -2524,10 +2525,10 @@ static void read_dump(const char *fname)
sym_set_crc(symname, crc);
sym_update_namespace(symname, namespace);
}
- release_file(file, size);
+ free(buf);
return;
fail:
- release_file(file, size);
+ free(buf);
fatal("parse error in symbol dump file\n");
}