* Fix util_is_printable_string
@ 2013-01-04 19:12 Pantelis Antoniou
[not found] ` <1357326778-12725-1-git-send-email-panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Pantelis Antoniou @ 2013-01-04 19:12 UTC (permalink / raw)
To: Jon Loeliger
Cc: Grant Likely, Rob Herring, devicetree-discuss, linux-kernel,
Matt Porter, Russ Dill, Pantelis Antoniou
The method used did not account for multi-part strings.
Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
---
util.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/util.c b/util.c
index 2422c34..45f186b 100644
--- a/util.c
+++ b/util.c
@@ -72,7 +72,7 @@ char *join_path(const char *path, const char *name)
int util_is_printable_string(const void *data, int len)
{
const char *s = data;
- const char *ss;
+ const char *ss, *se;
/* zero length is not */
if (len == 0)
@@ -82,13 +82,19 @@ int util_is_printable_string(const void *data, int len)
if (s[len - 1] != '\0')
return 0;
- ss = s;
- while (*s && isprint(*s))
- s++;
+ se = s + len;
- /* not zero, or not done yet */
- if (*s != '\0' || (s + 1 - ss) < len)
- return 0;
+ while (s < se) {
+ ss = s;
+ while (s < se && *s && isprint(*s))
+ s++;
+
+ /* not zero, or not done yet */
+ if (*s != '\0' || s == ss)
+ return 0;
+
+ s++;
+ }
return 1;
}
--
1.7.12
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: Fix util_is_printable_string
[not found] ` <1357326778-12725-1-git-send-email-panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
@ 2013-01-05 12:49 ` David Gibson
2013-01-06 21:38 ` Jon Loeliger
1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2013-01-05 12:49 UTC (permalink / raw)
To: Pantelis Antoniou
Cc: Matt Porter, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Russ Dill
[-- Attachment #1.1: Type: text/plain, Size: 794 bytes --]
On Fri, Jan 04, 2013 at 09:12:58PM +0200, Pantelis Antoniou wrote:
> The method used did not account for multi-part strings.
>
> Signed-off-by: Pantelis Antoniou <panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
I think it could do with some more commenting of exactly what it's
considering a printable string(s). I'm pretty sure it's doing the
right thing, but if you're not already familiar with the OF
multi-string convention, it would be easy to get confused by the
code. Other than that
Acked-by: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 192 bytes --]
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix util_is_printable_string
[not found] ` <1357326778-12725-1-git-send-email-panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
2013-01-05 12:49 ` David Gibson
@ 2013-01-06 21:38 ` Jon Loeliger
1 sibling, 0 replies; 3+ messages in thread
From: Jon Loeliger @ 2013-01-06 21:38 UTC (permalink / raw)
To: Pantelis Antoniou
Cc: Matt Porter, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Russ Dill
> The method used did not account for multi-part strings.
>
> Signed-off-by: Pantelis Antoniou <panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
Applied.
Plese consider a follow-up patch to address David's concerns.
Thanks,
jdl
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-01-06 21:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-04 19:12 Fix util_is_printable_string Pantelis Antoniou
[not found] ` <1357326778-12725-1-git-send-email-panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
2013-01-05 12:49 ` David Gibson
2013-01-06 21:38 ` Jon Loeliger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).