From patchwork Wed Jul 15 14:44:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 51126 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5F11020300 for ; Wed, 15 Jul 2015 14:44:39 +0000 (UTC) Received: by lafd3 with SMTP id d3sf11349718laf.1 for ; Wed, 15 Jul 2015 07:44:38 -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:mailing-list:precedence:list-id :list-unsubscribe:list-subscribe:list-archive:list-post:list-help :sender:delivered-to:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding:x-original-sender :x-original-authentication-results; bh=5G5tY5M5g7zKsEwPGLmNL89cn9dAaRctwCX+9X8nnrI=; b=XckAFCOby5/diyJkKzDaSknv3CmSkIt3y0zrDY5l/AOwJBXd1/aKnYwKE6MNpuYixb DkuvkMqUoBpiXKP4kxtoQ2bRTNoVhdr1PAa44ReEmyeUKdBttEML5AEra1cD9ZMZG8A/ SCcajBpX4wX69z3xc9AD3Tt8nQkk7O9zub5Aw7NiGPv6jeiETmfbPPguzgx877V2w7tN rqV50eMUi8FrOy0d2rb7XV3UfZucjZSoMf78p1Un3ubXlspJWbeCYeL4gK8jxD6SHsYv WExksav4ULtLF/uaXnSM1V5/jDdqlCuaZZ91e+pmaNbjl1uDOAJD8NUzwWi6PI13077m 4Vqw== X-Gm-Message-State: ALoCoQnAkDhFZghvtTwdN7CI/nmUhAOHfSqbwdUx2aXEP+Hafq1qj6NF1KpB3aV8Tcs9hJtJ72Xs X-Received: by 10.112.54.166 with SMTP id k6mr2307690lbp.0.1436971477981; Wed, 15 Jul 2015 07:44:37 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.101 with SMTP id z5ls207258laz.65.gmail; Wed, 15 Jul 2015 07:44:37 -0700 (PDT) X-Received: by 10.152.234.42 with SMTP id ub10mr4439853lac.60.1436971477839; Wed, 15 Jul 2015 07:44:37 -0700 (PDT) Received: from mail-lb0-x22c.google.com (mail-lb0-x22c.google.com. [2a00:1450:4010:c04::22c]) by mx.google.com with ESMTPS id pp10si4179859lbc.132.2015.07.15.07.44.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jul 2015 07:44:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22c as permitted sender) client-ip=2a00:1450:4010:c04::22c; Received: by lbbzr7 with SMTP id zr7so26362219lbb.1 for ; Wed, 15 Jul 2015 07:44:37 -0700 (PDT) X-Received: by 10.112.139.103 with SMTP id qx7mr4481880lbb.73.1436971477736; Wed, 15 Jul 2015 07:44:37 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3140778lbb; Wed, 15 Jul 2015 07:44:36 -0700 (PDT) X-Received: by 10.68.198.101 with SMTP id jb5mr9032766pbc.84.1436971476042; Wed, 15 Jul 2015 07:44:36 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id es1si7991130pad.58.2015.07.15.07.44.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jul 2015 07:44:36 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-60983-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 114943 invoked by alias); 15 Jul 2015 14:44:23 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 114934 invoked by uid 89); 15 Jul 2015 14:44:22 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f178.google.com X-Received: by 10.170.157.87 with SMTP id y84mr4398559ykc.28.1436971458896; Wed, 15 Jul 2015 07:44:18 -0700 (PDT) Message-ID: <55A671BE.6090306@linaro.org> Date: Wed, 15 Jul 2015 11:44:14 -0300 From: Adhemerval Zanella User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: libc-alpha@sourceware.org CC: Carlos O'Donell Subject: Re: [PATCH 2/2] libio: Update tst-fmemopen2.c References: <55802AFD.1040404@linaro.org> <559C2D12.6000508@redhat.com> <559C4341.3040107@linaro.org> <55A66422.5010306@linux.vnet.ibm.com> In-Reply-To: <55A66422.5010306@linux.vnet.ibm.com> X-Original-Sender: adhemerval.zanella@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22c as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 Hi Stefan, Thanks for checking it. On 15-07-2015 10:46, Stefan Liebler wrote: > Hi, > > i get the following failure for this test on s390-32: > FAIL: third ftello returned 28, expected 100 > FAIL: final string is "just hellod`<80>@^]<92>Ua^C^?<9E>u^?<9E>u`", expected "just hellod" > > I think the "expected 100" should be "expected 11". See testcode - there is nbuf instead of nstr as argument to printf: > if (o != nstr) > { > printf ("FAIL: third ftello returned %jd, expected %zu\n", > (intmax_t)o, nbuf); > result = 1; > } > > [...] > > Is this is a bug in the new fmemopen implementation?! > If it isn't, the testcase should initialize buf with zeros. Yes, it is an issue with new implementation since it requires to open the stream to first null byte (thus the strnlen) only for 'a' mode. The follow patch should fix the behaviour you are seeing: Carlos, if you allow I would like to push this modification for 2.22. > > Bye > Stefan > > On 07/07/2015 11:23 PM, Adhemerval Zanella wrote: >> >> >> On 07-07-2015 16:48, Carlos O'Donell wrote: >>> On 06/16/2015 09:56 AM, Adhemerval Zanella wrote: >>>> Reposting to see if I can land it for 2.22. >>>> >>>> -- >>>> >>>> This patch updates tst-fmemopen2 to check for fmemopen with NULL buffer >>>> inputs and also refactor the code a bit. >>>> >>>> The test relies on a POSIX compliant fmemopen implementation. >>>> >>>> Tested on x86_64, i386, aarch64, and arm-linux-gnueabihf. >>>> >>>> * stdio-common/tst-fmemopen2.c (do_test): Add test for NULL and zero >>>> length buffers. >>>> * stdio-common/tst-fmemopen.c (do_test): Refactor to use >>>> test-skeleton.c. >>> >>> OK with nits fixed and after you checkin the fmemopen fixes. >> >> Thanks for the review, I have updated the patch with all your requests and >> I have also added some more comments about the tests intentions. >> > diff --git a/libio/fmemopen.c b/libio/fmemopen.c index e6e6a49..3ab3e8d 100644 --- a/libio/fmemopen.c +++ b/libio/fmemopen.c @@ -150,7 +150,7 @@ __fmemopen (void *buf, size_t len, const char *mode) cookie_io_functions_t iof; fmemopen_cookie_t *c; - c = (fmemopen_cookie_t *) malloc (sizeof (fmemopen_cookie_t)); + c = (fmemopen_cookie_t *) calloc (sizeof (fmemopen_cookie_t), 1); if (c == NULL) return NULL; @@ -165,7 +165,6 @@ __fmemopen (void *buf, size_t len, const char *mode) return NULL; } c->buffer[0] = '\0'; - c->maxpos = 0; } else { @@ -182,7 +181,8 @@ __fmemopen (void *buf, size_t len, const char *mode) if (mode[0] == 'w' && mode[1] == '+') c->buffer[0] = '\0'; - c->maxpos = strnlen (c->buffer, len); + if (mode[0] == 'a') + c->maxpos = strnlen (c->buffer, len); }