From patchwork Tue Jan 24 17:45:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 92381 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1829795qgi; Tue, 24 Jan 2017 09:45:39 -0800 (PST) X-Received: by 10.98.21.131 with SMTP id 125mr40760048pfv.110.1485279939726; Tue, 24 Jan 2017 09:45:39 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u5si19984577pgh.266.2017.01.24.09.45.39; Tue, 24 Jan 2017 09:45:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750788AbdAXRpi (ORCPT + 7 others); Tue, 24 Jan 2017 12:45:38 -0500 Received: from mail-ot0-f195.google.com ([74.125.82.195]:35841 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750765AbdAXRph (ORCPT ); Tue, 24 Jan 2017 12:45:37 -0500 Received: by mail-ot0-f195.google.com with SMTP id 36so20452335otx.3; Tue, 24 Jan 2017 09:45:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+LpwoiI7kD3jnBmIudfUsRjIFfhdBmnXp5NM2+FTZ/8=; b=fj9OWBW+XGOij2isvy0VA2UnfJaQliUvzyabF0HkXSsIVKa9HvGci+O3U+Uzn36dVX Tf36j1Y7xX3vTIbG69YAt87jst5v0f3aliZveqDUBSCk5R07DvHBMRnbsAmmZ9YwgxSE Gg4ZyVkSX1bSfyVP6TX+P242UdTm2igJq7Ca/+jrFMq3TYm5Flchu/bIDjpxQLAZBPqk lnqbtZHyAhoDWoJrDwhZV3yAMZHBNixfRTOWYH0AhejWM1S0lftOj/SRIQBpHNKLN6NG 3ghUZ55mUmNUhq+x5fs8+OGMk1/fxvXsnZnVvudQTNRxU5ieK96a9mjlsAKzr7jIOe4w dFjQ== X-Gm-Message-State: AIkVDXJt7PVbYSvnDctxs6aN6yeHfuvjH0YZFonjpVt5rAQVj3Uy3ds1AkHyYOOQHjSjZA== X-Received: by 10.157.38.237 with SMTP id i42mr19341358otd.76.1485279936575; Tue, 24 Jan 2017 09:45:36 -0800 (PST) Received: from rob-hp-laptop.herring.priv (72-48-98-129.dyn.grandenetworks.net. [72.48.98.129]) by smtp.googlemail.com with ESMTPSA id w84sm10736088oiw.21.2017.01.24.09.45.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 09:45:36 -0800 (PST) From: Rob Herring To: David Gibson Cc: devicetree@vger.kernel.org, devicetree-compiler@vger.kernel.org Subject: [PATCH 1/5] checks: Add Warning for stricter property name character checking Date: Tue, 24 Jan 2017 11:45:30 -0600 Message-Id: <20170124174534.3865-2-robh@kernel.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170124174534.3865-1-robh@kernel.org> References: <20170124174534.3865-1-robh@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org While '?', '.', '+', '*', and '_' are considered valid characters their use is discouraged in recommended practices. '#' is also only recommended to be used at the beginning of property names. Testing this found one typo error with '.' used instead of ','. The rest of the warnings were all from underscores. Signed-off-by: Rob Herring --- checks.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) -- 2.10.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/checks.c b/checks.c index 3d18e45374c8..a0d4a9d968d7 100644 --- a/checks.c +++ b/checks.c @@ -239,6 +239,7 @@ ERROR(duplicate_property_names, check_duplicate_property_names, NULL); #define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #define DIGITS "0123456789" #define PROPNODECHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-" +#define PROPNODECHARSSTRICT LOWERCASE UPPERCASE DIGITS ",-" static void check_node_name_chars(struct check *c, struct dt_info *dti, struct node *node) @@ -299,6 +300,38 @@ static void check_property_name_chars(struct check *c, struct dt_info *dti, } ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS); +static void check_property_name_chars_strict(struct check *c, + struct dt_info *dti, + struct node *node) +{ + struct property *prop; + + for_each_property(node, prop) { + const char *name = prop->name; + int n = strspn(name, c->data); + + if (n == strlen(prop->name)) + continue; + + /* Certain names are whitelisted */ + if (strcmp(name, "device_type") == 0) + continue; + + /* + * # is only allowed at the beginning of property names not counting + * the vendor prefix. + */ + if (name[n] == '#' && ((n == 0) || (name[n-1] == ','))) { + name += n + 1; + n = strspn(name, c->data); + } + if (n < strlen(name)) + FAIL(c, "Character '%c' not recommended in property name \"%s\", node %s", + name[n], prop->name, node->fullpath); + } +} +WARNING(property_name_chars_strict, check_property_name_chars_strict, PROPNODECHARSSTRICT); + #define DESCLABEL_FMT "%s%s%s%s%s" #define DESCLABEL_ARGS(node,prop,mark) \ ((mark) ? "value of " : ""), \ @@ -703,6 +736,8 @@ static struct check *check_table[] = { &address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell, &device_type_is_string, &model_is_string, &status_is_string, + &property_name_chars_strict, + &addr_size_cells, ®_format, &ranges_format, &unit_address_vs_reg,