diff options
author | Stefan M Schaeckeler <sschaeck@cisco.com> | 2018-05-21 19:26:14 -0400 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2018-05-22 13:27:28 -0400 |
commit | 3b9cf7905fe3ab35ab437b5072c883e609d3498d (patch) | |
tree | fde01d816d211ba02040f0e5fec62d5b338b2a43 /drivers/of/unittest.c | |
parent | 3098e5b7eebc5dd923562fcbf8acc5990c9e3c64 (diff) |
of: unittest: for strings, account for trailing \0 in property length field
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>
Reviewed-by: Frank Rowand <frank.rowand@sony.com>
Tested-by: Frank Rowand <frank.rowand@sony.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of/unittest.c')
-rw-r--r-- | drivers/of/unittest.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 6bb37c18292a..ecee50d10d14 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c | |||
@@ -165,20 +165,20 @@ static void __init of_unittest_dynamic(void) | |||
165 | /* Add a new property - should pass*/ | 165 | /* Add a new property - should pass*/ |
166 | prop->name = "new-property"; | 166 | prop->name = "new-property"; |
167 | prop->value = "new-property-data"; | 167 | prop->value = "new-property-data"; |
168 | prop->length = strlen(prop->value); | 168 | prop->length = strlen(prop->value) + 1; |
169 | unittest(of_add_property(np, prop) == 0, "Adding a new property failed\n"); | 169 | unittest(of_add_property(np, prop) == 0, "Adding a new property failed\n"); |
170 | 170 | ||
171 | /* Try to add an existing property - should fail */ | 171 | /* Try to add an existing property - should fail */ |
172 | prop++; | 172 | prop++; |
173 | prop->name = "new-property"; | 173 | prop->name = "new-property"; |
174 | prop->value = "new-property-data-should-fail"; | 174 | prop->value = "new-property-data-should-fail"; |
175 | prop->length = strlen(prop->value); | 175 | prop->length = strlen(prop->value) + 1; |
176 | unittest(of_add_property(np, prop) != 0, | 176 | unittest(of_add_property(np, prop) != 0, |
177 | "Adding an existing property should have failed\n"); | 177 | "Adding an existing property should have failed\n"); |
178 | 178 | ||
179 | /* Try to modify an existing property - should pass */ | 179 | /* Try to modify an existing property - should pass */ |
180 | prop->value = "modify-property-data-should-pass"; | 180 | prop->value = "modify-property-data-should-pass"; |
181 | prop->length = strlen(prop->value); | 181 | prop->length = strlen(prop->value) + 1; |
182 | unittest(of_update_property(np, prop) == 0, | 182 | unittest(of_update_property(np, prop) == 0, |
183 | "Updating an existing property should have passed\n"); | 183 | "Updating an existing property should have passed\n"); |
184 | 184 | ||
@@ -186,7 +186,7 @@ static void __init of_unittest_dynamic(void) | |||
186 | prop++; | 186 | prop++; |
187 | prop->name = "modify-property"; | 187 | prop->name = "modify-property"; |
188 | prop->value = "modify-missing-property-data-should-pass"; | 188 | prop->value = "modify-missing-property-data-should-pass"; |
189 | prop->length = strlen(prop->value); | 189 | prop->length = strlen(prop->value) + 1; |
190 | unittest(of_update_property(np, prop) == 0, | 190 | unittest(of_update_property(np, prop) == 0, |
191 | "Updating a missing property should have passed\n"); | 191 | "Updating a missing property should have passed\n"); |
192 | 192 | ||