From patchwork Tue Dec 11 11:00:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 153438 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp476518ljp; Tue, 11 Dec 2018 03:03:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/VhcUUk96m1oaeH829mcq3XsogXibKUDwEDFB65HBKMonk/LymuyrdJxViCv4KKRaUHW4y9 X-Received: by 2002:a63:8149:: with SMTP id t70mr14516523pgd.172.1544526210318; Tue, 11 Dec 2018 03:03:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544526210; cv=none; d=google.com; s=arc-20160816; b=rnjXg8tDQUJmdJgZpoPbu0aj3ACMfprbcAWVm0ByEqcEBa9cNRRaa4LfyN3qLYSePg bfKzWZmfHyYHP3FXb3becwrIA31B6e6WtUIrHrEvS6HQTouBKhKV6p9W4QrIhwari5BY qNQLVqvddV5uDIh1LPIi08qSSLy5TWkfU+qjKzgIbEmNrzst9kX1j2VPPVsAtgKjD/zb RU1dbOREyJVa7kseWoa/IuTD2uBa5A8RgDNTPBBR1ucsOIQuYpZeLezf2oZKzLmn8T8K GuYXcXW9DboSWsXLmq6AFnGaWAhcoJ3VPq1G8N4GBoLYC+UhEt4QpKXnz/BJu8FFd2uE M+Pg== 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; bh=MlQs798fD3HimILsVIH/RMuv643LnBHtKXQ4IW5SZaA=; b=gJECqrFgBc6HVrpNvFly+N8OZ/RM/rO8u+yV8nb78IFjZbanC+bbfjC5DUzIR9Em9i yy4MuC4ufIIe6XyTyiqBRQuGcBuo9LGx8HxuVdwhjN+O06Ads28qYeIwA6vCkYSldYbV AzALj11lDuloymlE5SrZeqIVh1a2vzQnbWLw0A0XY5m4M6U2ApHbdq2pARQgGGJDqUzl 6VOr4tTCTn641Vofa104LoL9GRHpaZws4k+DjgGOAio5+402qVb4WS7qvcvGnssRAN0Y MYci7g1IieT/nRARcAwM4qUJzDbh/uSWJ/rMOT5W9074C5NYvibQa6BXKpD0GSw4GIXU Axfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=eVPfCaXP; 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 4si12406084plc.320.2018.12.11.03.03.30; Tue, 11 Dec 2018 03:03:30 -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=eVPfCaXP; 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 S1726405AbeLKLD2 (ORCPT + 31 others); Tue, 11 Dec 2018 06:03:28 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:36641 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbeLKLBm (ORCPT ); Tue, 11 Dec 2018 06:01:42 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id wBBB1C5j017210; Tue, 11 Dec 2018 20:01:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com wBBB1C5j017210 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544526079; bh=MlQs798fD3HimILsVIH/RMuv643LnBHtKXQ4IW5SZaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eVPfCaXPPe7n1cnw+Knr9Zsq/PwgTsxnsnIO5JAD4eHK/rYj0WDkkaK40Kp0rxyIg muVXnZI3Ns4yE5N7y+ntHxoycTkegNmRZz5CTUT94jAAp2yvnGcq5TrcnyzZxCQJcX ri7UlEK76wP/224x5G01yaW9VCUadESFBq8+BVTZblzNPtA8h0fqzKVit+IP8Am1pg j97Yalx81TBg5Gdy+mDFFVqfCDo5ppNwo3WolTchGo36DFrg09UCYvzzPJ9ZvSWUYV 9Wngqbp0WRqENMXNSoV+Bw2tyKtPDNoZu6wLNZIDxP+FRXNj1CbY/4Bsz28e9W6aFu Lvx8vVgCKILNA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Ulf Magnusson , linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 08/27] kconfig: warn no new line at end of file Date: Tue, 11 Dec 2018 20:00:51 +0900 Message-Id: <1544526070-16690-9-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544526070-16690-1-git-send-email-yamada.masahiro@socionext.com> References: <1544526070-16690-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 It would be nice to warn if a new line is missing at end of file. We could do this by checkpatch.pl for arbitrary files, but new line is rather essential as a statement terminator in Kconfig. The warning message looks like this: kernel/Kconfig.preempt:60:warning: no new line at end of file Currently, kernel/Kconfig.preempt is the only file with no new line at end of file. Fix it. I know there are some false negative cases. For example, no warning is displayed when the last line contains some whitespaces/comments, but no new line. Yet, this commit works well for most cases. Signed-off-by: Masahiro Yamada --- kernel/Kconfig.preempt | 2 +- scripts/kconfig/zconf.l | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt index cd16551..0fee5fe 100644 --- a/kernel/Kconfig.preempt +++ b/kernel/Kconfig.preempt @@ -57,4 +57,4 @@ config PREEMPT endchoice config PREEMPT_COUNT - bool \ No newline at end of file + bool diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 9038e97..5046d3c 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -78,6 +78,13 @@ static void warn_ignored_character(char chr) "%s:%d:warning: ignoring unsupported character '%c'\n", current_file->name, yylineno, chr); } + +static void warn_no_newline(void) +{ + fprintf(stderr, "%s:%d:warning: no new line at end of file\n", + current_file->name, yylineno); +} + %} n [A-Za-z0-9_-] @@ -261,6 +268,9 @@ n [A-Za-z0-9_-] <> { BEGIN(INITIAL); + if (prev_token != T_EOL && prev_token != T_HELPTEXT) + warn_no_newline(); + if (current_file) { zconf_endfile(); return T_EOL;