From patchwork Thu Apr 16 05:01:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 1271490 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.a=rsa-sha256 header.s=dec2015msa header.b=yEEDj0na; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 492nCR5Fktz9sPF for ; Thu, 16 Apr 2020 15:02:27 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1CF0E81352; Thu, 16 Apr 2020 07:02:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="yEEDj0na"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DA38D81352; Thu, 16 Apr 2020 07:02:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from conuserg-09.nifty.com (conuserg-09.nifty.com [210.131.2.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F23EA804D5 for ; Thu, 16 Apr 2020 07:02:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=masahiroy@kernel.org Received: from oscar.flets-west.jp (softbank060142179096.bbtec.net [60.142.179.96]) (authenticated) by conuserg-09.nifty.com with ESMTP id 03G51pVa004851; Thu, 16 Apr 2020 14:01:54 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com 03G51pVa004851 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1587013314; bh=rA3X7oQDZFs/BZVe2tJKwuIGR2dcCL644lbkCRjrGxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yEEDj0naS6BlfDMHsdXneNV+L/diCyW8e5vhZWGJ2PZuSuRwVAOtUdvnKmpw28+Rc 0071/IeFuN4XcxiDG8Pm2OnlBZAI+1+M+cHRFL73TXG4Cg2ntAqAU323k4tqpNvicX Q9KzOYhabXmRDAG9r4D//Mpmg9LuXQQNbt70NA+CXgZt5GsUkstPPAJU9piVM38ypR bO7+dEE/UlCO6+4UXRuu/8GAvzojPWIcwFjtE3H616H4GweXaQ5bnU2IK+rsJ6FLjb N22l1WJNhEnZGVqp2NcV6v6aHNJ7Kja2SJC7Wf8T1qqvR4x4YvFE8U4WcU6YtK4efs I3Lfn5t8vGS9Q== X-Nifty-SrcIP: [60.142.179.96] From: Masahiro Yamada To: u-boot@lists.denx.de Cc: Masahiro Yamada Subject: [PATCH 2/2] fixdep: Re-sync with Linux 5.7-rc1 Date: Thu, 16 Apr 2020 14:01:45 +0900 Message-Id: <20200416050145.492334-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200416050145.492334-1-masahiroy@kernel.org> References: <20200416050145.492334-1-masahiroy@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean fixdep is a standalone host program, so we can just re-sync it with the latest Linux in one commit. I kept the U-Boot own code block surrounded by /* hack for U-Boot */ ... /* U-boot hack end */. Signed-off-by: Masahiro Yamada --- scripts/basic/fixdep.c | 92 +++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 555dada47a..24be244d5e 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -77,11 +77,6 @@ * dependencies on include/config/my/option.h for every * CONFIG_MY_OPTION encountered in any of the prerequisites. * - * It will also filter out all the dependencies on *.ver. We need - * to make sure that the generated version checksum are globally up - * to date before even starting the recursive build, so it's too late - * at this point anyway. - * * We don't even try to really parse the header files, but * merely grep, i.e. if CONFIG_FOO is mentioned in a comment, it will * be picked up as well. It's not a problem with respect to @@ -99,6 +94,7 @@ #include #include #include +#include #include #include #include @@ -107,11 +103,40 @@ char tmp_buf[256]; /* hack for U-Boot */ static void usage(void) { - fprintf(stderr, "Usage: fixdep [-e] \n"); - fprintf(stderr, " -e insert extra dependencies given on stdin\n"); + fprintf(stderr, "Usage: fixdep \n"); exit(1); } +/* + * In the intended usage of this program, the stdout is redirected to .*.cmd + * files. The return value of printf() and putchar() must be checked to catch + * any error, e.g. "No space left on device". + */ +static void xprintf(const char *format, ...) +{ + va_list ap; + int ret; + + va_start(ap, format); + ret = vprintf(format, ap); + if (ret < 0) { + perror("fixdep"); + exit(1); + } + va_end(ap); +} + +static void xputchar(int c) +{ + int ret; + + ret = putchar(c); + if (ret == EOF) { + perror("fixdep"); + exit(1); + } +} + /* * Print out a dependency path from a symbol name */ @@ -119,7 +144,7 @@ static void print_dep(const char *m, int slen, const char *dir) { int c, prev_c = '/', i; - printf(" $(wildcard %s/", dir); + xprintf(" $(wildcard %s/", dir); for (i = 0; i < slen; i++) { c = m[i]; if (c == '_') @@ -127,25 +152,10 @@ static void print_dep(const char *m, int slen, const char *dir) else c = tolower(c); if (c != '/' || prev_c != '/') - putchar(c); + xputchar(c); prev_c = c; } - printf(".h) \\\n"); -} - -static void do_extra_deps(void) -{ - char buf[80]; - - while (fgets(buf, sizeof(buf), stdin)) { - int len = strlen(buf); - - if (len < 2 || buf[len - 1] != '\n') { - fprintf(stderr, "fixdep: bad data on stdin\n"); - exit(1); - } - print_dep(buf, len - 1, "include/ksym"); - } + xprintf(".h) \\\n"); } struct item { @@ -238,7 +248,7 @@ static void parse_config_file(const char *p) } p += 7; q = p; - while (*q && (isalnum(*q) || *q == '_')) + while (isalnum(*q) || *q == '_') q++; if (str_ends_with(p, q - p, "_MODULE")) r = q - 7; @@ -309,8 +319,7 @@ static void *read_file(const char *filename) static int is_ignored_file(const char *s, int len) { return str_ends_with(s, len, "include/generated/autoconf.h") || - str_ends_with(s, len, "include/generated/autoksyms.h") || - str_ends_with(s, len, ".ver"); + str_ends_with(s, len, "include/generated/autoksyms.h"); } /* @@ -318,7 +327,7 @@ static int is_ignored_file(const char *s, int len) * assignments are parsed not only by make, but also by the rather simple * parser in scripts/mod/sumversion.c. */ -static void parse_dep_file(char *m, const char *target, int insert_extra_deps) +static void parse_dep_file(char *m, const char *target) { char *p; int is_last, is_target; @@ -365,13 +374,13 @@ static void parse_dep_file(char *m, const char *target, int insert_extra_deps) */ if (!saw_any_target) { saw_any_target = 1; - printf("source_%s := %s\n\n", - target, m); - printf("deps_%s := \\\n", target); + xprintf("source_%s := %s\n\n", + target, m); + xprintf("deps_%s := \\\n", target); } is_first_dep = 0; } else { - printf(" %s \\\n", m); + xprintf(" %s \\\n", m); } buf = read_file(m); @@ -394,23 +403,16 @@ static void parse_dep_file(char *m, const char *target, int insert_extra_deps) exit(1); } - if (insert_extra_deps) - do_extra_deps(); - - printf("\n%s: $(deps_%s)\n\n", target, target); - printf("$(deps_%s):\n", target); + xprintf("\n%s: $(deps_%s)\n\n", target, target); + xprintf("$(deps_%s):\n", target); } int main(int argc, char *argv[]) { const char *depfile, *target, *cmdline; - int insert_extra_deps = 0; void *buf; - if (argc == 5 && !strcmp(argv[1], "-e")) { - insert_extra_deps = 1; - argv++; - } else if (argc != 4) + if (argc != 4) usage(); depfile = argv[1]; @@ -424,10 +426,10 @@ int main(int argc, char *argv[]) strcpy(tmp_buf, "TPL_"); /* end U-Boot hack */ - printf("cmd_%s := %s\n\n", target, cmdline); + xprintf("cmd_%s := %s\n\n", target, cmdline); buf = read_file(depfile); - parse_dep_file(buf, target, insert_extra_deps); + parse_dep_file(buf, target); free(buf); return 0;