From patchwork Thu Feb 1 20:36:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 868419 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-89887-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="n5Nn+pHK"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zXX3724s0z9sBZ for ; Fri, 2 Feb 2018 07:36:51 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=wIECS4/5duMMB8ZJm9RxbD0egU7lm zdB+yMSR9ZPYeYphT+WfLgDYot07iZxtYXSQJRyBqu2CdWf1XH2bQGwv7Z8BBF/7 6RJIRA9qafD/VDljz5eEH56kJPc9/xhriFPZrX9p8HhYEmUgCj2nkeNwlsYiJkdn Q+T107mh7RtBLs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=5mGhQUG5aGPVAXPnklKQrx8qE+4=; b=n5N n+pHK2+BtD3V5Q1mGmRvfNJxTSIke3CP8KoZ217+niE55pdPP+XlDi3AY6EVuZKE wZbbdRMLQ4cCMoGFO1ox4P6cOOHgxzHYCPRHp3FQR9fH6MYvl3ztI3s3B35wqtTA iB/H+veoNiZVZxtIk7vCAHyQ9U5m7x3EusOSC4sY= Received: (qmail 116328 invoked by alias); 1 Feb 2018 20:36:43 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116303 invoked by uid 89); 1 Feb 2018 20:36:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=Hx-languages-length:1425 X-HELO: relay1.mentorg.com Date: Thu, 1 Feb 2018 20:36:35 +0000 From: Joseph Myers To: Subject: Move string/testcopy.c to test-driver.c and xmalloc (bug 19667) Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) 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 [BZ #19667] * string/testcopy.c: Include . Do not include . Use . (main): Rename to do_test. Make static. Use xmalloc instead of malloc. Reviewed-by: Adhemerval Zanella 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 #include #include -#include +#include -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