From patchwork Fri Mar 19 20:37:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 89574 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AC59BA0524; Fri, 19 Mar 2021 21:37:51 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 388D9140FC2; Fri, 19 Mar 2021 21:37:51 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id CB2EE40143 for ; Fri, 19 Mar 2021 21:37:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616186268; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wZE+KaPLACRs04MkpMIhObq5If3Z4fulQ3YmBRitKXg=; b=Hpsz98HAikFFCC9AQ3IMq1iYGmYIBivZkuEyYKlbOTT15eBgtJZns+ooqwlbxPOzNxmmJ5 e2Qy3q77SAZj5n0l+yw4MSHJdfKCLD55fbhcb7Xt0QGRPWhYwjjphuw38D3oU0MfVin+Mr /YBaJoQKdig271pAvJJ+D2zlkXAVB5k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-249-SBWtTqSxOr-pM8RjoWFAwA-1; Fri, 19 Mar 2021 16:37:45 -0400 X-MC-Unique: SBWtTqSxOr-pM8RjoWFAwA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C0B831084C9D; Fri, 19 Mar 2021 20:37:43 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.193.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F5E05C1BB; Fri, 19 Mar 2021 20:37:42 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Thomas Monjalon Date: Fri, 19 Mar 2021 21:37:37 +0100 Message-Id: <20210319203737.13526-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH] devtools: check logtype format X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Enforce that added logtypes follow the convention: - for lib/librte_XXX: lib.XXX and lib.XXX.* - for drivers/class/XXX: pmd.class.XXX and pmd.class.XXX.* Signed-off-by: David Marchand --- devtools/checkpatches.sh | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh index 78a408ef98..11ad4bee8d 100755 --- a/devtools/checkpatches.sh +++ b/devtools/checkpatches.sh @@ -199,6 +199,42 @@ check_internal_tags() { # return $res } +check_logtypes() { # + res=0 + + cat "$1" |awk ' + BEGIN { + pattern = ""; + ret = 0; + } + /^+++ b\// { + count = split($2, path, "/") + if (count >= 4 && path[2] == "lib") { + pattern = "lib\\." gensub(/librte_(.*)/, "\\1", "", path[3]) + } else if (count >= 5 && path[2] == "drivers") { + pattern = "pmd\\." path[3] "\\." path[4] + } else { + pattern = ""; + } + } + /^+.*RTE_LOG_REGISTER\([^,]+,[^,]+,/ { + if (pattern == "") { + next; + } + if (!($0 ~ "RTE_LOG_REGISTER\\([^,]+, " pattern "(|\\.[^,]+),")) { + print $0 + print "Added logtype does not comply with pattern: " \ + gensub(/\\/, "", "g", pattern) + ret = 1; + } + } + END { + exit ret; + }' || res=1 + + return $res +} + number=0 range='origin/main..' quiet=false @@ -290,6 +326,14 @@ check () { # ret=1 fi + ! $verbose || printf '\nChecking RTE_LOG_REGISTER:\n' + report=$(check_logtypes "$tmpinput") + if [ $? -ne 0 ] ; then + $headline_printed || print_headline "$3" + printf '%s\n' "$report" + ret=1 + fi + if [ "$tmpinput" != "$1" ]; then rm -f "$tmpinput" trap - INT