From patchwork Thu Oct 3 12:24:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 20783 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f200.google.com (mail-ye0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8A7BF25CAB for ; Thu, 3 Oct 2013 12:24:46 +0000 (UTC) Received: by mail-ye0-f200.google.com with SMTP id r5sf3737433yen.7 for ; Thu, 03 Oct 2013 05:24:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=Jx3kLBIX7ID7KVXqFYFjbYaN1rDAtiuak4woPZaJ01M=; b=BRh7oOhmHzFZe2+V6t3kgMw7KZYILYyCdrd88eVcd/aVbUiGyMoWadPzMptdguTlwT fn/UmtA1M7Pdchpoyp6FBwuAcdRjr/zWFErQXIkGqTeMcBEYIPLFGpw6bfnMW4m3lv1m GnHN8KkIMFxCQ6WyCLNKHiU+atRITqYX3h7yZoMWQOxWoglKbXaul/HqhmUKlymJQ/vp d5flAdSIUkdTMm+qxY4AxE40PhzXlxGpCVsd9RKmNjDBTDYC5v70K03RZZb6pMqkfkZs pqZpKmUDy7o6szR6klIYA/wHUE5psIWPYY+ZafK02rlubMlLAsQCf09z9AevYB+D6tg4 8cJw== X-Received: by 10.236.88.129 with SMTP id a1mr6727499yhf.40.1380803086241; Thu, 03 Oct 2013 05:24:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.59.194 with SMTP id b2ls867245qer.88.gmail; Thu, 03 Oct 2013 05:24:46 -0700 (PDT) X-Received: by 10.52.26.69 with SMTP id j5mr6049545vdg.21.1380803086076; Thu, 03 Oct 2013 05:24:46 -0700 (PDT) Received: from mail-vb0-f43.google.com (mail-vb0-f43.google.com [209.85.212.43]) by mx.google.com with ESMTPS id f20si1659500vcs.67.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 05:24:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.43 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.43; Received: by mail-vb0-f43.google.com with SMTP id h11so1542091vbh.30 for ; Thu, 03 Oct 2013 05:24:46 -0700 (PDT) X-Gm-Message-State: ALoCoQnjJn3+7bir72c0WLFzPcRSm4TnEmubyqlPWA73Hg/WrWe0uNzqBSLKTj20unxE4z3RxFo4 X-Received: by 10.52.98.131 with SMTP id ei3mr6043075vdb.4.1380803085987; Thu, 03 Oct 2013 05:24:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp173986vcz; Thu, 3 Oct 2013 05:24:45 -0700 (PDT) X-Received: by 10.15.35.196 with SMTP id g44mr12418975eev.18.1380803084988; Thu, 03 Oct 2013 05:24:44 -0700 (PDT) Received: from mail-ea0-f171.google.com (mail-ea0-f171.google.com [209.85.215.171]) by mx.google.com with ESMTPS id w44si5673393eef.345.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 05:24:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.171 is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=209.85.215.171; Received: by mail-ea0-f171.google.com with SMTP id n15so1054569ead.30 for ; Thu, 03 Oct 2013 05:24:44 -0700 (PDT) X-Received: by 10.14.224.198 with SMTP id x46mr3139914eep.53.1380803083849; Thu, 03 Oct 2013 05:24:43 -0700 (PDT) Received: from localhost.localdomain (cpc6-seac21-2-0-cust453.7-2.cable.virginmedia.com. [82.1.113.198]) by mx.google.com with ESMTPSA id h45sm15211623eeg.5.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 03 Oct 2013 05:24:43 -0700 (PDT) Message-ID: <524D6209.8080005@linaro.org> Date: Thu, 03 Oct 2013 13:24:41 +0100 From: Will Newton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: libc-alpha@sourceware.org CC: patches@linaro.org Subject: [PATCH] malloc/tst-posix_memalign.c: Tidy up code. X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.43 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add some comments and call free on all potentially allocated pointers. ChangeLog: 2013-10-03 Will Newton * malloc/tst-posix_memalign.c: Add comments. (do_test): Add comments and call free on all potentially allocated pointers. Add space after cast. --- malloc/tst-posix_memalign.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/malloc/tst-posix_memalign.c b/malloc/tst-posix_memalign.c index 9d9d1bf..276757b 100644 --- a/malloc/tst-posix_memalign.c +++ b/malloc/tst-posix_memalign.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2013 Free Software Foundation, Inc. +/* Test for posix_memalign. + Copyright (C) 2013 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -40,6 +41,8 @@ do_test (void) p = NULL; + /* An attempt to allocate a huge value should return ENOMEM and + p should remain NULL. */ ret = posix_memalign (&p, sizeof (void *), -1); if (ret != ENOMEM) @@ -48,15 +51,22 @@ do_test (void) if (ret == ENOMEM && p != NULL) merror ("returned an error but pointer was modified"); + free (p); + p = NULL; + /* Test to expose integer overflow in malloc internals from BZ #15857. */ ret = posix_memalign (&p, pagesize, -pagesize); if (ret != ENOMEM) merror ("posix_memalign (&p, pagesize, -pagesize) succeeded."); + free (p); + p = NULL; + /* A zero-sized allocation should succeed with glibc, returning zero + and setting p to a non-NULL value. */ ret = posix_memalign (&p, sizeof (void *), 0); if (ret != 0 || p == NULL) @@ -84,9 +94,9 @@ do_test (void) if (ret == 0 && p == NULL) merror ("returned success but pointer is NULL"); - ptrval = (unsigned long)p; + ptrval = (unsigned long) p; - if (ret == 0 && (ptrval & 0xff)) + if (ret == 0 && (ptrval & 0xff) != 0) merror ("pointer is not aligned to 0x100"); free (p);