From: Frank Rowand <frowand.list@gmail.com>
To: Stefan M Schaeckeler <sschaeck@cisco.com>,
Rob Herring <robh+dt@kernel.org>,
devicetree@vger.kernel.org
Subject: Re: [PATCH] of: unittest: for strings, account for trailing \0 in property length field
Date: Mon, 21 May 2018 10:26:42 -0700 [thread overview]
Message-ID: <f48467c4-d3f6-10de-48f9-1cd208ee3b55@gmail.com> (raw)
In-Reply-To: <20180519232943.GA12474@sjc-ads-587.cisco.com>
On 05/19/18 16:29, Stefan M Schaeckeler wrote:
> For strings, account for trailing \0 in property length field:
>
> This is consistent with how dtc builds string properties.
>
> Function __of_prop_dup() would misbehave on such properties as it duplicates
> properties based on the property length field creating new string values
> without trailing \0s.
>
> Signed-off-by: Stefan M Schaeckeler <sschaeck@cisco.com>
> ---
> drivers/of/unittest.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
> index 6bb37c1..75a2abe 100644
> --- a/drivers/of/unittest.c
> +++ b/drivers/of/unittest.c
> @@ -165,20 +165,20 @@ static void __init of_unittest_dynamic(void)
> /* Add a new property - should pass*/
> prop->name = "new-property";
> prop->value = "new-property-data";
> - prop->length = strlen(prop->value);
> + prop->length = strlen(prop->value)+1;
Please put a space before and after the plus sign: ... strlen(prop->value) + 1;
Same for each of the changes below.
With those changes, you can add:
Reviewed-by: Frank Rowand <frank.rowand@sony.com>
Tested-by: Frank Rowand <frank.rowand@sony.com>
-Frank
> unittest(of_add_property(np, prop) == 0, "Adding a new property failed\n");
>
> /* Try to add an existing property - should fail */
> prop++;
> prop->name = "new-property";
> prop->value = "new-property-data-should-fail";
> - prop->length = strlen(prop->value);
> + prop->length = strlen(prop->value)+1;
> unittest(of_add_property(np, prop) != 0,
> "Adding an existing property should have failed\n");
>
> /* Try to modify an existing property - should pass */
> prop->value = "modify-property-data-should-pass";
> - prop->length = strlen(prop->value);
> + prop->length = strlen(prop->value)+1;
> unittest(of_update_property(np, prop) == 0,
> "Updating an existing property should have passed\n");
>
> @@ -186,7 +186,7 @@ static void __init of_unittest_dynamic(void)
> prop++;
> prop->name = "modify-property";
> prop->value = "modify-missing-property-data-should-pass";
> - prop->length = strlen(prop->value);
> + prop->length = strlen(prop->value)+1;
> unittest(of_update_property(np, prop) == 0,
> "Updating a missing property should have passed\n");
>
>
prev parent reply other threads:[~2018-05-21 17:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-19 23:29 [PATCH] of: unittest: for strings, account for trailing \0 in property length field Stefan M Schaeckeler
2018-05-21 17:26 ` Frank Rowand [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f48467c4-d3f6-10de-48f9-1cd208ee3b55@gmail.com \
--to=frowand.list@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=sschaeck@cisco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox