Skip to content

Commit 2383530

Browse files
James-A-Clarkmasahir0y
authored andcommitted
scripts/kallsyms: Fix build failure by setting errno before calling getline()
getline() returns -1 at EOF as well as on error. It also doesn't set errno to 0 on success, so initialize it to 0 before using errno to check for an error condition. See the paragraph here [1]: For some system calls and library functions (e.g., getpriority(2)), -1 is a valid return on success. In such cases, a successful return can be distinguished from an error return by setting errno to zero before the call, and then, if the call returns a status that indicates that an error may have occurred, checking to see if errno has a nonzero value. Bear has a bug [2] that launches processes with errno set and causes the following build failure: $ bear -- make LLVM=1 ... LD .tmp_vmlinux.kallsyms1 NM .tmp_vmlinux.kallsyms1.syms KSYMS .tmp_vmlinux.kallsyms1.S read_symbol: Invalid argument [1]: https://linux.die.net/man/3/errno [2]: rizsotto/Bear#469 Fixes: 1c975da ("scripts/kallsyms: remove KSYM_NAME_LEN_BUFFER") Reviewed-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: James Clark <james.clark@arm.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 6eaae19 commit 2383530

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

scripts/kallsyms.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ static struct sym_entry *read_symbol(FILE *in, char **buf, size_t *buf_len)
129129
ssize_t readlen;
130130
struct sym_entry *sym;
131131

132+
errno = 0;
132133
readlen = getline(buf, buf_len, in);
133134
if (readlen < 0) {
134135
if (errno) {

0 commit comments

Comments
 (0)