Discussion:
[Linuxptp-devel] [PATCH] Fix data type for return value of vasprintf()
Jesuiter, Henry (ALC NetworX GmbH)
2016-07-08 09:41:16 UTC
Permalink
--
Since size_t is an unsigned data type, it won't evaluate correctly on errors
of vasprintf(). This patch makes 'len2' a signed integer, as expected by
vasprintf().

Signed-off-by: Henry Jesuiter <***@alcnetworx.de>
---
diff -rwbBu a/util.c b/util.c
--- a/util.c 2015-09-19 16:25:11.000000000 +0200
+++ b/util.c 2016-07-08 11:33:09.843328724 +0200
@@ -448,7 +448,8 @@
void string_appendf(char **s, const char *format, ...)
{
va_list ap;
- size_t len1, len2;
+ size_t len1;
+ int len2;
char *s2;

len1 = strlen(*s);
---

Best regards
Henry Jesuiter
Miroslav Lichvar
2016-07-12 12:25:37 UTC
Permalink
Post by Jesuiter, Henry (ALC NetworX GmbH)
diff -rwbBu a/util.c b/util.c
--- a/util.c 2015-09-19 16:25:11.000000000 +0200
+++ b/util.c 2016-07-08 11:33:09.843328724 +0200
@@ -448,7 +448,8 @@
void string_appendf(char **s, const char *format, ...)
{
va_list ap;
- size_t len1, len2;
+ size_t len1;
+ int len2;
char *s2;
len1 = strlen(*s);
This looks good to me. I've actually had an item in my todo list to
fix this as it was reported by a static analyzer. Thanks :).
--
Miroslav Lichvar
Richard Cochran
2016-07-12 13:17:20 UTC
Permalink
Post by Jesuiter, Henry (ALC NetworX GmbH)
--
Since size_t is an unsigned data type, it won't evaluate correctly on errors
of vasprintf(). This patch makes 'len2' a signed integer, as expected by
vasprintf().
Patch applied. I took the liberty and added a bit more text to the
commit message from your other mail.

Thanks,
Richard

Loading...