aboutsummaryrefslogtreecommitdiff
path: root/scripts/diffconfig
diff options
context:
space:
mode:
authorMasahiro Yamada2018-01-11 22:05:42 +0900
committerMasahiro Yamada2018-01-18 09:37:38 +0900
commit4003fd80cba967e4044ebac96f13746153e87c4d (patch)
tree006b763982e18bb1625de91fd02ddd030d93a545 /scripts/diffconfig
parent01b5cbe7012fb1eeffc5c143865569835bcd405e (diff)
fixdep: factor out common code for reading files
Now, do_config_files() and print_deps() are almost the same. Only the difference is the parser function called (parse_config_file vs parse_dep_file). We can reduce the code duplication by factoring out the common code into read_file() - this function allocates a buffer and loads a file to it. It returns the pointer to the allocated buffer. (As before, it bails out by exit(2) for any error.) The caller must free the buffer when done. Having empty source files is possible; fixdep should simply skip them. I deleted the "st.st_size == 0" check, so read_file() allocates 1-byte buffer for an empty file. strstr() will immediately return NULL, and this is what we expect. On the other hand, an empty dep_file should be treated as an error. In this case, parse_dep_file() will error out with "no targets found" and it is a correct error message. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/diffconfig')
0 files changed, 0 insertions, 0 deletions