From patchwork Tue Jan 9 08:30:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 123809 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3749853qgn; Tue, 9 Jan 2018 00:32:16 -0800 (PST) X-Google-Smtp-Source: ACJfBosWqdnpN8lwhYTnWgg08OY4nQc7zNO6QJK5flTo4LMCWLKbugkMy4eBwA/90HC0YMnOTNX7 X-Received: by 10.101.65.136 with SMTP id a8mr11434813pgq.363.1515486736855; Tue, 09 Jan 2018 00:32:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515486736; cv=none; d=google.com; s=arc-20160816; b=WtBs6A/rQtuOeG+38YwzuldkFu5I571xH+SUqqfuuVYbdm2QL4aFY3GCPPMSUB9e3w 92mc8KoPSJ7Y7Z5bMn6LcrvDdwWuUblcCuDNbmVYN1DhhhONg6qGIIrN+1t8svJxa2Ox iyEi1pi6zdg6oC+f2L2UO6c0h9BCI9as+6reYzgz6EyFnKh700EpVag1iRRHUFWNaGZl yr9E5uOG7T7jYCVDQC4uU+K51dDz9BIocELLIwa5aE2YvWG7eqYMX4V0IiflR+Ntyg/+ KoYxN3z5MJioU4NVeDkbcnMTrJEUpp7fk2MpzNEk/JJjR953zKcCp8V5zBHALmmIhxvz mViw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=LrFNKyFPpj8wWsQU2ha3UwSEuZKFoYfCXb+WzqfOflE=; b=pRxo6nV32D0KFcdRZu02FYzv7RW5F6QXYiCoBjp6hNqpXUPDpNxbc9nTiNVpM4acKi AwmmZeHOwkFN1EJypHdH/7AFhN2/++wjq90i+4l8PafdTFVNYgS0JsPE3PJMXghVhLq5 5C9CVyt/O2hnZ14h2CpUFt5+WIfmrOw0s7gzNEB3tS4220MBqjhs4fbLUC8n65l01PAb qlLyTWChgSNEm6vjIuR7ftz6HuC96cP2j0akv7fta7xSvByfzlSAhMlUkCxVJCfhFe38 Y3PpRNzxE7JvymS1+xAdDARPtxi3OwWjD5c70YnKAa/elPtbCrsX/2smpxWADit2lN5x bn+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=bBKhCLdF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si10025924plb.153.2018.01.09.00.32.16; Tue, 09 Jan 2018 00:32:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=bBKhCLdF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751579AbeAIIcO (ORCPT + 28 others); Tue, 9 Jan 2018 03:32:14 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:27464 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbeAIIcD (ORCPT ); Tue, 9 Jan 2018 03:32:03 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id w098Uugu024960; Tue, 9 Jan 2018 17:30:57 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com w098Uugu024960 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1515486658; bh=LrFNKyFPpj8wWsQU2ha3UwSEuZKFoYfCXb+WzqfOflE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bBKhCLdFyKNryN35B0LVHntwZEfutu+Rqpol8haAYIOIvbTAEQ02Svje7wPkU25NV jvegFKbvJznn1QAn89/eDQqe+skIFlwW97QwK44h2a1gf7lCaETfOdrj8hcdHWB18x pIv1xxHfP6EEE/4nny+WHzsfoSbe8crsQ6R39t57HRLUT7gPW0rT0Pihuy9/H3kQcu umskr2DuL+B4eJZspGigtzzThrFn3NzkS8AhfmNMwMkX69dQSsh/m/6ws7QQGFQGCI /l2a4Cp6MTDXHtD3uMvlduobzOhYnHjytAx2eqAyHMnlBVKrn3aPGMznZ3eJDwuTs7 Maagz8jzaooOA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Michal Marek , Lukas Bulwahn , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 3/6] fixdep: remove unneeded memcpy() in parse_dep_file() Date: Tue, 9 Jan 2018 17:30:47 +0900 Message-Id: <1515486650-1141-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515486650-1141-1-git-send-email-yamada.masahiro@socionext.com> References: <1515486650-1141-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Each token in the depfile is copied to the temporary buffer 's' to terminate the token with zero. We do not need to do this any more because the parsed buffer is now writable. Insert '\0' directly in the buffer without calling memcpy(). Signed-off-by: Masahiro Yamada --- scripts/basic/fixdep.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index f954f226..bc2364e 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -306,7 +306,6 @@ static void *load_file(const char *filename) static void parse_dep_file(char *m) { char *p; - char s[PATH_MAX]; int is_last, is_target; int saw_any_target = 0; int is_first_dep = 0; @@ -332,16 +331,14 @@ static void parse_dep_file(char *m) /* The /next/ file is the first dependency */ is_first_dep = 1; } else { - /* Save this token/filename */ - memcpy(s, m, p-m); - s[p - m] = 0; + *p = '\0'; /* Ignore certain dependencies */ - if (strrcmp(s, "include/generated/autoconf.h") && - strrcmp(s, "include/generated/autoksyms.h") && - strrcmp(s, "arch/um/include/uml-config.h") && - strrcmp(s, "include/linux/kconfig.h") && - strrcmp(s, ".ver")) { + if (strrcmp(m, "include/generated/autoconf.h") && + strrcmp(m, "include/generated/autoksyms.h") && + strrcmp(m, "arch/um/include/uml-config.h") && + strrcmp(m, "include/linux/kconfig.h") && + strrcmp(m, ".ver")) { /* * Do not list the source file as dependency, * so that kbuild is not confused if a .c file @@ -362,15 +359,15 @@ static void parse_dep_file(char *m) if (!saw_any_target) { saw_any_target = 1; printf("source_%s := %s\n\n", - target, s); + target, m); printf("deps_%s := \\\n", target); } is_first_dep = 0; } else - printf(" %s \\\n", s); + printf(" %s \\\n", m); - buf = load_file(s); + buf = load_file(m); parse_config_file(buf); free(buf); }