{"thread":{"id":"52073","subject":"[PATCH v3] userdiff: Fix some corner cases in dts regex","startedAt":"2019-10-20T18:52:33Z","lastAt":"2019-10-20T19:54:41Z","messageCount":2,"participants":["Stephen Boyd","Johannes Sixt"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"384476","messageId":"20191020185230.212875-1-sboyd@kernel.org","threadId":"52073","inReplyTo":null,"subject":"[PATCH v3] userdiff: Fix some corner cases in dts regex","fromName":"Stephen Boyd","fromEmail":"sboyd@kernel.org","sentAt":"2019-10-20T18:52:30Z","receivedAt":"2019-10-20T18:52:33Z","isPatch":true,"sender":{"key":"sboyd@kernel.org","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"While reviewing some dts diffs recently I noticed that the hunk header\nlogic was failing to find the containing node. This is because the regex\ndoesn't consider properties that may span multiple lines, i.e.\n\n\tproperty = <something>,\n\t\t   <something_else>;\n\nand it got hung up on comments inside nodes that look like the root node\nbecause they start with '/*'. Add tests for these cases and update the\nregex to find them. Maybe detecting the root node is too complicated but\nforcing it to be a backslash with any amount of whitespace up to an open\nbracket seemed OK. I tried to detect that a comment is in-between the\ntwo parts but I wasn't happy so I just dropped it.\n\nCc: Rob Herring <robh+dt@kernel.org>\nCc: Frank Rowand <frowand.list@gmail.com>\nSigned-off-by: Stephen Boyd <sboyd@kernel.org>\n---\n\nChanges from v2:\n * Updated test to be really multiline.\n\nChanges from v1:\n * Added a new boolean property unit test\n * Updated the regex to simplify multi-line property skipping\n * Added some space to multieline prop test between cells in\n   first property\n\n t/t4018/dts-nodes-boolean-prop   |  9 +++++++++\n t/t4018/dts-nodes-multiline-prop | 13 +++++++++++++\n t/t4018/dts-root                 |  2 +-\n t/t4018/dts-root-comment         |  8 ++++++++\n userdiff.c                       |  3 ++-\n 5 files changed, 33 insertions(+), 2 deletions(-)\n create mode 100644 t/t4018/dts-nodes-boolean-prop\n create mode 100644 t/t4018/dts-nodes-multiline-prop\n create mode 100644 t/t4018/dts-root-comment\n\ndiff --git a/t/t4018/dts-nodes-boolean-prop b/t/t4018/dts-nodes-boolean-prop\nnew file mode 100644\nindex 000000000000..afc6b5b404e4\n--- /dev/null\n+++ b/t/t4018/dts-nodes-boolean-prop\n@@ -0,0 +1,9 @@\n+/ {\n+\tlabel_1: node1@ff00 {\n+\t\tRIGHT@deadf00,4000 {\n+\t\t\tboolean-prop1;\n+\n+\t\t\tChangeMe;\n+\t\t};\n+\t};\n+};\ndiff --git a/t/t4018/dts-nodes-multiline-prop b/t/t4018/dts-nodes-multiline-prop\nnew file mode 100644\nindex 000000000000..072d58b69dc2\n--- /dev/null\n+++ b/t/t4018/dts-nodes-multiline-prop\n@@ -0,0 +1,13 @@\n+/ {\n+\tlabel_1: node1@ff00 {\n+\t\tRIGHT@deadf00,4000 {\n+\t\t\tmultilineprop = <3>,\n+\t\t\t\t\t<4>,\n+\t\t\t\t\t<5>,\n+\t\t\t\t\t<6>,\n+\t\t\t\t\t<7>;\n+\n+\t\t\tChangeMe = <0xffeedd00>;\n+\t\t};\n+\t};\n+};\ndiff --git a/t/t4018/dts-root b/t/t4018/dts-root\nindex 2ef9e6ffaa2c..4353b8220c91 100644\n--- a/t/t4018/dts-root\n+++ b/t/t4018/dts-root\n@@ -1,4 +1,4 @@\n-/RIGHT { /* Technically just supposed to be a slash */\n+/ { RIGHT /* Technically just supposed to be a slash and brace */\n \t#size-cells = <1>;\n \n \tChangeMe = <0xffeedd00>;\ndiff --git a/t/t4018/dts-root-comment b/t/t4018/dts-root-comment\nnew file mode 100644\nindex 000000000000..333a625c7007\n--- /dev/null\n+++ b/t/t4018/dts-root-comment\n@@ -0,0 +1,8 @@\n+/ { RIGHT /* Technically just supposed to be a slash and brace */\n+\t#size-cells = <1>;\n+\n+\t/* This comment should be ignored */\n+\n+\tsome-property = <40+2>;\n+\tChangeMe = <0xffeedd00>;\n+};\ndiff --git a/userdiff.c b/userdiff.c\nindex 86e3244e15dd..e187d356f6ff 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -25,8 +25,9 @@ IPATTERN(\"ada\",\n \t \"|=>|\\\\.\\\\.|\\\\*\\\\*|:=|/=|>=|<=|<<|>>|<>\"),\n PATTERNS(\"dts\",\n \t \"!;\\n\"\n+\t \"!=\\n\"\n \t /* lines beginning with a word optionally preceded by '&' or the root */\n-\t \"^[ \\t]*((/|&?[a-zA-Z_]).*)\",\n+\t \"^[ \\t]*((/[ \\t]*\\\\{|&?[a-zA-Z_]).*)\",\n \t /* -- */\n \t /* Property names and math operators */\n \t \"[a-zA-Z0-9,._+?#-]+\"\n-- \nSent by a computer through tubes\n\n"},{"id":"384477","messageId":"21271a81-5273-ad8e-be06-7a2242aa57cf@kdbg.org","threadId":"52073","inReplyTo":"20191020185230.212875-1-sboyd@kernel.org","subject":"Re: [PATCH v3] userdiff: Fix some corner cases in dts regex","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2019-10-20T19:54:33Z","receivedAt":"2019-10-20T19:54:41Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 20.10.19 um 20:52 schrieb Stephen Boyd:\n> --- /dev/null\n> +++ b/t/t4018/dts-nodes-multiline-prop\n> @@ -0,0 +1,13 @@\n> +/ {\n> +\tlabel_1: node1@ff00 {\n> +\t\tRIGHT@deadf00,4000 {\n> +\t\t\tmultilineprop = <3>,\n> +\t\t\t\t\t<4>,\n> +\t\t\t\t\t<5>,\n> +\t\t\t\t\t<6>,\n> +\t\t\t\t\t<7>;\n\nThere is little variation in the lines, but if that is what occurs in\nreal life, so be it.\n\nThis patch is good. Thanks!\n\nReviewed-by: Johannes Sixt <j6t@kdbg.org>\n\n-- Hannes\n"}]}