Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4334848rwo; Tue, 25 Jul 2023 04:44:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlEoHPlKKBb4kLXGLLb+4mjw0nRbcua9DiFH1HYlaClARa+2lDFeCRwqXvMNOUXSrN4qSyKn X-Received: by 2002:a05:6358:9494:b0:129:df95:f9a9 with SMTP id i20-20020a056358949400b00129df95f9a9mr8588942rwb.2.1690285447143; Tue, 25 Jul 2023 04:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690285447; cv=none; d=google.com; s=arc-20160816; b=Jsw27ntM9HHWvRV/kRf/XbwCVd4EObLCOgTsHiS5Pbqnm8av14Y2Pc2+t2ShST/YKQ F2mz0u3XkYtrurKZKocZVsZUZN7hARsw8TPgdqiCtOlFp7Zziqc2oAYatTqnKQTOulmB lT9eirw7YIQwgEMVh7MoE50mOg2PshjFCzhu7CB+9x0fVAm5qsZHUsO9Te7qF1Fzy6jB CEN6uzuRt7kR3iY1YvoD803qWrVfYFfvaJWOlpE49LVLF4GAk8Krp/M97ePvLvGkUCVn rwRGsAHp0KRFWur7TDVb0s2JM488VpEj9mWMat7qlpvLD/CxuNPT76MS90izxb6Zm8rp rW9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=tCNIj1Yx9sy4DJYSYxkgACxk5ioGaUC3d5la84K9jvs=; fh=jH5M9Pl6mjDq8Ioc8+x0KqJBKIhQEgD6ap3xvyCo/9w=; b=Btqzyag4VMvf2k4UM89lOtvqgiIVr6jxYoaXIsIWtH5O1GqflSDE3uUu5tsZkTYmfZ ZNfcY2t2FadX43wl9dtgJ65Q+wMuwcRb4j4Ww1CWPifjAa1Wc4pOL316oU9cfb9fSjlo N6GK9H0wyb4ruPjSoFJj8kx5rKgWZVGY/Zqbw4ifWYTK/17HlEyXYkcS2MIZxmOqtzuj n8xlNbI7bD4bcZQhyGM1FS6U2qZd84gL/Jrk4ED4oMOvIgwYkN9YLGRW1zGD7fIucWoa f5Aj6JHC8Uv5UptVgLCXJne9pwxNSPR5Jfmc9cl8XiG9DZZ9lHaIJ8eFqz8AQyFu5XAt s/EQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u10-20020a63ef0a000000b005574c3ac68esi10906327pgh.489.2023.07.25.04.43.54; Tue, 25 Jul 2023 04:44:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233785AbjGYLBX (ORCPT + 99 others); Tue, 25 Jul 2023 07:01:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230089AbjGYLBK (ORCPT ); Tue, 25 Jul 2023 07:01:10 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C64DE4C11; Tue, 25 Jul 2023 03:58:41 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4C40B15BF; Tue, 25 Jul 2023 03:59:24 -0700 (PDT) Received: from e127643.arm.com (unknown [10.57.2.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E1E813F67D; Tue, 25 Jul 2023 03:58:38 -0700 (PDT) From: James Clark To: linux-kbuild@vger.kernel.org, masahiroy@kernel.org, miguel.ojeda.sandonis@gmail.com Cc: linux-kernel@vger.kernel.org, James Clark , Miguel Ojeda , Kees Cook , Zhen Lei , Greg Kroah-Hartman , Arnd Bergmann , Boqun Feng , Nicolas Schier Subject: [PATCH v2] scripts/kallsyms: Fix build failure by setting errno before calling getline() Date: Tue, 25 Jul 2023 11:58:26 +0100 Message-Id: <20230725105827.1119167-1-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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]: https://github.com/rizsotto/Bear/issues/469 Fixes: 1c975da56a6f ("scripts/kallsyms: remove KSYM_NAME_LEN_BUFFER") Reviewed-by: Miguel Ojeda Signed-off-by: James Clark --- scripts/kallsyms.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 16c87938b316..653b92f6d4c8 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -129,6 +129,7 @@ static struct sym_entry *read_symbol(FILE *in, char **buf, size_t *buf_len) ssize_t readlen; struct sym_entry *sym; + errno = 0; readlen = getline(buf, buf_len, in); if (readlen < 0) { if (errno) { -- 2.34.1