From patchwork Thu Jul 16 13:03:26 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: 51180 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1A3EF22A28 for ; Thu, 16 Jul 2015 13:03:51 +0000 (UTC) Received: by lafd3 with SMTP id d3sf18616893laf.1 for ; Thu, 16 Jul 2015 06:03:49 -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 :subject:references:in-reply-to:content-type :content-transfer-encoding:x-original-sender :x-original-authentication-results; bh=MTOqku+clitOMcVw665zmUaew5BuzNSr7Je7fiBUDNU=; b=FW4qSjiEhY/fwxYWOJ9oVUTNguG4DOJdS+K6GjJfgbDbDN7lVs4NqDP8pOs6I5TKyA m37WiUc6Dk2kxCa+zvTYRHAR+IUEzVTZjkln7zdNcl4m9LCYMejniwgRJN6fLjuDEWMk kEPhII+iXHulLnoWcKQXxFIzwAa/gDcKN8OmvNOjEm1gvl1OMkb0cs05D/qF9lItHqGg aAP2Rvzp6l5EsBZV8SkmobPIRv67iJK65Lb1pWe9ft7EpOTI4cg+urfdIqGQsizsceKK fVQ/wlJpdBTyZ1Rx4X7Q1RuNUgr4x3T8U5SWP3U21sm1RbYossQafF3XPBEpt7P7nVfq T+zA== X-Gm-Message-State: ALoCoQnTi/mAZ3MW91JmLeBI3BZwit6ED/Z3nDJNXT16wpm+jUbJAI9Q3rm4iou8WVab8r0OB2tz X-Received: by 10.112.181.37 with SMTP id dt5mr4925057lbc.10.1437051829810; Thu, 16 Jul 2015 06:03:49 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.4 with SMTP id x4ls355750lag.100.gmail; Thu, 16 Jul 2015 06:03:49 -0700 (PDT) X-Received: by 10.112.105.104 with SMTP id gl8mr9310127lbb.81.1437051829530; Thu, 16 Jul 2015 06:03:49 -0700 (PDT) Received: from mail-la0-x233.google.com (mail-la0-x233.google.com. [2a00:1450:4010:c03::233]) by mx.google.com with ESMTPS id lv6si6891180lac.87.2015.07.16.06.03.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 06:03:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::233 as permitted sender) client-ip=2a00:1450:4010:c03::233; Received: by lagw2 with SMTP id w2so43021092lag.3 for ; Thu, 16 Jul 2015 06:03:49 -0700 (PDT) X-Received: by 10.152.1.66 with SMTP id 2mr9514623lak.56.1437051829176; Thu, 16 Jul 2015 06:03:49 -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 hn6csp244520lbb; Thu, 16 Jul 2015 06:03:47 -0700 (PDT) X-Received: by 10.66.227.131 with SMTP id sa3mr18454754pac.24.1437051827070; Thu, 16 Jul 2015 06:03:47 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id cd9si12935093pac.153.2015.07.16.06.03.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 06:03:47 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-61015-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 73441 invoked by alias); 16 Jul 2015 13:03:38 -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 73425 invoked by uid 89); 16 Jul 2015 13:03:37 -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-f180.google.com X-Received: by 10.13.205.196 with SMTP id p187mr9774315ywd.119.1437051810396; Thu, 16 Jul 2015 06:03:30 -0700 (PDT) Message-ID: <55A7AB9E.2050308@linaro.org> Date: Thu, 16 Jul 2015 10:03:26 -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 Subject: Re: [PATCH] libio: Fix fmemopen 'w' mode with provided buffer References: <55A799A3.6040202@linaro.org> In-Reply-To: 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:c03::233 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 On 16-07-2015 08:58, Stefan Liebler wrote: > As already mentioned in https://www.sourceware.org/ml/libc-alpha/2015-07/msg00455.html, the testcase is now passing on s390-32. > > Can you change this printf in case of a failure, too: Ok, change below: * libio/fmemopen.c (__fmemopen): Fix 'w' openmode with provided buffer. * stdio-common/tst-fmemopen2.c (do_test_with_buffer): Fix typo and fail output information. 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); } diff --git a/stdio-common/tst-fmemopen2.c b/stdio-common/tst-fmemopen2.c index 16dd3ad..a2c05c1 100644 --- a/stdio-common/tst-fmemopen2.c +++ b/stdio-common/tst-fmemopen2.c @@ -34,7 +34,7 @@ do_test_with_buffer (void) FILE *fp = fmemopen (buf, nbuf, "w"); if (fp == NULL) { - printf ("FAIL: fmemopen failedi (%s)\n", __FUNCTION__); + printf ("FAIL: fmemopen failed (%s)\n", __FUNCTION__); return 1; } @@ -69,7 +69,7 @@ do_test_with_buffer (void) if (o != nstr) { printf ("FAIL: third ftello returned %jd, expected %zu\n", - (intmax_t)o, nbuf); + (intmax_t)o, nstr); result = 1; }