* Move string/testcopy.c to test-driver.c and xmalloc (bug 19667)
@ 2018-02-01 20:36 Joseph Myers
2018-02-06 18:03 ` Ping " Joseph Myers
2018-02-06 19:37 ` Adhemerval Zanella
0 siblings, 2 replies; 3+ messages in thread
From: Joseph Myers @ 2018-02-01 20:36 UTC (permalink / raw)
To: libc-alpha
Bug 19667 reports unchecked malloc calls in the test
string/testcopy.c. This patch makes that test use xmalloc and the
support/test-driver.c test framework.
Tested for x86_64.
2018-02-01 Joseph Myers <joseph@codesourcery.com>
[BZ #19667]
* string/testcopy.c: Include <support/support.h>. Do not include
<malloc.h>. Use <support/test-driver.c>.
(main): Rename to do_test. Make static. Use xmalloc instead of
malloc.
diff --git a/string/testcopy.c b/string/testcopy.c
index 61ede1c..f14917b 100644
--- a/string/testcopy.c
+++ b/string/testcopy.c
@@ -19,10 +19,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <malloc.h>
+#include <support/support.h>
-int
-main (void)
+static int
+do_test (void)
{
char *mem, *memp;
char *rand_mem;
@@ -34,10 +34,10 @@ main (void)
max_size = 256;
- mem = malloc (max_size + 2 * max_size + 2 * space_around);
- rand_mem = malloc (max_size);
- lo_around = malloc (space_around);
- hi_around = malloc (space_around);
+ mem = xmalloc (max_size + 2 * max_size + 2 * space_around);
+ rand_mem = xmalloc (max_size);
+ lo_around = xmalloc (space_around);
+ hi_around = xmalloc (space_around);
memp = mem + space_around;
/* Fill RAND_MEM with random bytes, each non-zero. */
@@ -105,3 +105,5 @@ main (void)
return 0;
}
+
+#include <support/test-driver.c>
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Ping Re: Move string/testcopy.c to test-driver.c and xmalloc (bug 19667)
2018-02-01 20:36 Move string/testcopy.c to test-driver.c and xmalloc (bug 19667) Joseph Myers
@ 2018-02-06 18:03 ` Joseph Myers
2018-02-06 19:37 ` Adhemerval Zanella
1 sibling, 0 replies; 3+ messages in thread
From: Joseph Myers @ 2018-02-06 18:03 UTC (permalink / raw)
To: libc-alpha
Ping. This patch
<https://sourceware.org/ml/libc-alpha/2018-02/msg00033.html> is pending
review.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Move string/testcopy.c to test-driver.c and xmalloc (bug 19667)
2018-02-01 20:36 Move string/testcopy.c to test-driver.c and xmalloc (bug 19667) Joseph Myers
2018-02-06 18:03 ` Ping " Joseph Myers
@ 2018-02-06 19:37 ` Adhemerval Zanella
1 sibling, 0 replies; 3+ messages in thread
From: Adhemerval Zanella @ 2018-02-06 19:37 UTC (permalink / raw)
To: libc-alpha
On 01/02/2018 18:36, Joseph Myers wrote:
> Bug 19667 reports unchecked malloc calls in the test
> string/testcopy.c. This patch makes that test use xmalloc and the
> support/test-driver.c test framework.
>
> Tested for x86_64.
>
> 2018-02-01 Joseph Myers <joseph@codesourcery.com>
>
> [BZ #19667]
> * string/testcopy.c: Include <support/support.h>. Do not include
> <malloc.h>. Use <support/test-driver.c>.
> (main): Rename to do_test. Make static. Use xmalloc instead of
> malloc.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
>
> diff --git a/string/testcopy.c b/string/testcopy.c
> index 61ede1c..f14917b 100644
> --- a/string/testcopy.c
> +++ b/string/testcopy.c
> @@ -19,10 +19,10 @@
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> -#include <malloc.h>
> +#include <support/support.h>
>
> -int
> -main (void)
> +static int
> +do_test (void)
> {
> char *mem, *memp;
> char *rand_mem;
> @@ -34,10 +34,10 @@ main (void)
>
> max_size = 256;
>
> - mem = malloc (max_size + 2 * max_size + 2 * space_around);
> - rand_mem = malloc (max_size);
> - lo_around = malloc (space_around);
> - hi_around = malloc (space_around);
> + mem = xmalloc (max_size + 2 * max_size + 2 * space_around);
> + rand_mem = xmalloc (max_size);
> + lo_around = xmalloc (space_around);
> + hi_around = xmalloc (space_around);
> memp = mem + space_around;
>
> /* Fill RAND_MEM with random bytes, each non-zero. */
> @@ -105,3 +105,5 @@ main (void)
>
> return 0;
> }
> +
> +#include <support/test-driver.c>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-06 18:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-01 20:36 Move string/testcopy.c to test-driver.c and xmalloc (bug 19667) Joseph Myers
2018-02-06 18:03 ` Ping " Joseph Myers
2018-02-06 19:37 ` Adhemerval Zanella
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 read-only IMAP folder(s) and NNTP newsgroup(s).