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: 496686 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 338CA140271 for ; Thu, 16 Jul 2015 23:03:43 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=r1t+goOH; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; q=dns; s=default; b=aFOVthZAiyp7DCMTZX5TAS/9lc1cWpbRXr79S/Rbkx5 Z+zzJ5wwLf5T/yCUDNsMJV6szD6S8QXrXMX0ackwgxg+HMXy87WEPKDEJc/40R59 qH+bbJF+v4UUsa0WoX02cCsM+D/pizlvyev2J1OHJGSAKkVKjzxh5BEeLXfFZMZU = 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:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=default; bh=ZaQmsVSMiYbpdUjUT+B0cvqxhGM=; b=r1t+goOHH7MW+PZzs uFEffpnlUhiuOoa7B2k8SmM1J3gc/+pzI+5hv4cp0ijNLAM9KMJdc5EOH5cQtEjv h0mjwi0dsII+LDn+QGFO5jKnMLt2U9cf8LLhd0BQR5ASdKv0keKgrCaQ9pb5H/41 mx5jNxUR4DdU886DJ83La/87uc= Received: (qmail 73441 invoked by alias); 16 Jul 2015 13:03:38 -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 73425 invoked by uid 89); 16 Jul 2015 13:03:37 -0000 Authentication-Results: sourceware.org; auth=none 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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=MTOqku+clitOMcVw665zmUaew5BuzNSr7Je7fiBUDNU=; b=gOAHX0Lx58RYezkhjuevM2aAGMu9eg74G8mleIzBgviMYn3YkEyRVktRybmeuEE0FA YKDcM9ucextZ9ouxqN7VYnQeUnu+mlMo/293tHqcIXvhbeQVtjfGnZOSDJk+ojM5LT9X 8b15ZaVgQGt4LeHK5nSxOE5f/Ry2esSDzUak5Jez8peH2JSOyw87yEnlJf+zbF086ffl Uq+cbz97DasQz1FzE2hHiIHdr6tjIdBtHSYGkoibLaKrAHOfHbCOQtq30Nh6dPD6VFWC Mzh6oRR1qHvaou0s2hNRQuToPIEttJWk4Puhd3I1cUD10Jv9EYG1zqUKGFfiiCINNHFI Otmg== X-Gm-Message-State: ALoCoQkCtz+A3YgcPuLV00aGoboyAvg2AZAVxQ82WoNlnMw9/ZC2fYEqJgFzFDuvOHou42bCY4OV 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: 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; }