diff options
| author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-01-11 16:05:41 +0300 | 
|---|---|---|
| committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-01-18 03:37:37 +0300 | 
| commit | 01b5cbe7012fb1eeffc5c143865569835bcd405e (patch) | |
| tree | ba0a4ee6db6079ea3eeec7e35a9c942380e8f518 /scripts/gcc-plugins/structleak_plugin.c | |
| parent | 41f92cffba1908bc7acc847e498e34368be29dc7 (diff) | |
| download | linux-01b5cbe7012fb1eeffc5c143865569835bcd405e.tar.xz | |
fixdep: use malloc() and read() to load dep_file to buffer
Commit dee81e988674 ("fixdep: faster CONFIG_ search") changed how to
read files in which CONFIG options are searched.  It used malloc()
and read() instead of mmap() because it needed to zero-terminate the
buffer in order to use strstr().  print_deps() was left untouched
since there was no reason to change it.
Now, I have two motivations to change it in the same way.
 - do_config_file() and print_deps() do quite similar things; they
   open a file, load it onto memory, and pass it to a parser function.
   If we use malloc() and read() for print_deps() too, we can factor
   out the common code.  (I will do this in the next commit.)
 - parse_dep_file() copies each token to a temporary buffer because
   it needs to zero-terminate it to be passed to printf().  It is not
   possible to modify the buffer directly because it is mmap'ed with
   O_RDONLY.  If we load the file content into a malloc'ed buffer, we
   can insert '\0' after each token, and save memcpy().  (I will do
   this in the commit after next.)
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/gcc-plugins/structleak_plugin.c')
0 files changed, 0 insertions, 0 deletions
