From patchwork Fri Feb 10 16:47:14 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: 93796 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp590509qgi; Fri, 10 Feb 2017 08:48:22 -0800 (PST) X-Received: by 10.98.27.8 with SMTP id b8mr6611363pfb.82.1486745302441; Fri, 10 Feb 2017 08:48:22 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si2133340ply.217.2017.02.10.08.48.22; Fri, 10 Feb 2017 08:48:22 -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 S1753414AbdBJQsI (ORCPT + 7 others); Fri, 10 Feb 2017 11:48:08 -0500 Received: from mail-ot0-f196.google.com ([74.125.82.196]:33473 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751504AbdBJQsE (ORCPT ); Fri, 10 Feb 2017 11:48:04 -0500 Received: by mail-ot0-f196.google.com with SMTP id f9so4382582otd.0; Fri, 10 Feb 2017 08:47:21 -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=mUl3LiAd0RCbx5Y7DKdJdZpDnUN/xHqVJsXH8VWllfw=; b=g1FoSDKMlBEdfndFaMJUT4AY//kx97oSjI0HZaNFb0JKjCxYbZkAdbY4LL/iLXydaG V9e8y0yKnUfwx4OWQOouAiIfXe4Hw6uP3QbAiJsVCET7GMLDsthFt3ybi9vDXGpgqHNE PUl3SdCs2zn9CYs6qTwZFcNVcROJ7OpLMjTycKwZHtsCYX4dqN46h35ijs9bAROD2M7F +cSrg7EnPkenTef27ZAl5ai1PFjGX127BPpVdcR3WZZpBOgsmkDYKzgeFtpe+fn/pypE CyOXp1C4R0cLSbzYCAwH/ghgUIOMc1eqGT5BCtT3hpX3fd4cZEvGunzKaMJk2g7Y+BPh 3MDA== X-Gm-Message-State: AMke39kQCA+KduBRVmFdEdMirKMS1R9Sxy5x1RacqqgXrKrCIazOMOKTlyFbkVV8fUUgOQ== X-Received: by 10.157.44.253 with SMTP id e58mr4977186otd.172.1486745240487; Fri, 10 Feb 2017 08:47:20 -0800 (PST) Received: from rob-hp-laptop.herring.priv (66-90-148-125.dyn.grandenetworks.net. [66.90.148.125]) by smtp.googlemail.com with ESMTPSA id r41sm1141714otc.40.2017.02.10.08.47.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Feb 2017 08:47:19 -0800 (PST) From: Rob Herring To: David Gibson Cc: devicetree@vger.kernel.org, devicetree-compiler@vger.kernel.org Subject: [PATCH v2 1/4] checks: Add Warning for stricter property name character checking Date: Fri, 10 Feb 2017 10:47:14 -0600 Message-Id: <20170210164717.1234-2-robh@kernel.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170210164717.1234-1-robh@kernel.org> References: <20170210164717.1234-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 --- v2: - Disable check by default 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..22ef4748d7be 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); + } +} +CHECK(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,