From patchwork Wed Jun 28 08:42:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1800908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=uXcuA79Q; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QrZxD07Mgz20bH for ; Wed, 28 Jun 2023 18:48:32 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BE768386C5A6 for ; Wed, 28 Jun 2023 08:48:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE768386C5A6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687942109; bh=LvWKG1Jy6nOP8wuCcnaw9iaNegrCcFrky3gHGXa0CwU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=uXcuA79QVw8WAqzaWEg2oka8jocSbce8v9O8ZmCKLBY5C+5K5x5dWSuTkf897cWXo XflK+grW5o7DXbo4sL2EzKbfbj775GuYgqzFzN8Y5VSxqaaw40BJOL224ANSnWgbR2 MN2+qR/NKMuGuUq9QISbZdrle9FtnKdlscGcnFt4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 33537385841C for ; Wed, 28 Jun 2023 08:43:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33537385841C Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-584-3yANqd79PPeLFn_FQamdxw-1; Wed, 28 Jun 2023 04:43:07 -0400 X-MC-Unique: 3yANqd79PPeLFn_FQamdxw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6840A802A55; Wed, 28 Jun 2023 08:43:07 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C1084492B02; Wed, 28 Jun 2023 08:43:06 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com Subject: [PATCH v3 15/16] sysdeps/ieee754/ldbl-128ibm-compat: Fix warn unused result Date: Wed, 28 Jun 2023 10:42:45 +0200 Message-ID: <20230628084246.778302-16-fberat@redhat.com> In-Reply-To: <20230628084246.778302-1-fberat@redhat.com> References: <20230628084246.778302-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Return value from *scanf and *asprintf routines are now properly checked in test-scanf-ldbl-compat-template.c and test-printf-ldbl-compat.c. Reviewed-by: Siddhesh Poyarekar --- .../test-printf-ldbl-compat.c | 10 +++++---- .../test-scanf-ldbl-compat-template.c | 21 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c index 3c759e1427..be37af7c31 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c @@ -30,12 +30,13 @@ do_test_call_varg (FILE *stream, const char *format, ...) char *buffer = NULL; char string[128]; va_list args; + int ret; printf ("%15s", "vasprintf: "); va_start (args, format); - vasprintf (&buffer, format, args); + ret = vasprintf (&buffer, format, args); va_end (args); - if (buffer == NULL) + if (ret == -1 || buffer == NULL) printf ("Error using vasprintf\n"); else { @@ -82,10 +83,11 @@ do_test_call_rarg (FILE *stream, const char *format, long double ld, double d) { char *buffer = NULL; char string[128]; + int ret; printf ("%15s", "asprintf: "); - asprintf (&buffer, format, ld, d); - if (buffer == NULL) + ret = asprintf (&buffer, format, ld, d); + if (ret == -1 || buffer == NULL) printf ("Error using asprintf\n"); else { diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c index e8da3a67f0..776c12dd16 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c @@ -37,10 +37,10 @@ ldptr = va_arg (args, long double *); \ fptr = va_arg (args, float *); \ va_end (args); \ - if (*ldptr == -1 && *fptr == -2) \ + if (*ldptr == -1 && *fptr == -2 && ret == 2) \ printf ("OK"); \ else \ - printf ("ERROR (%Lf %f)", *ldptr, *fptr); \ + printf ("ERROR (%Lf %f %d)", *ldptr, *fptr, ret); \ printf ("\n"); #define CLEAR_VALUE \ @@ -48,10 +48,10 @@ f = 0; #define CHECK_VALUE \ - if (ld == -1 && f == -2) \ + if (ld == -1 && f == -2 && ret == 2) \ printf ("OK"); \ else \ - printf ("ERROR (%Lf %f)", ld, f); \ + printf ("ERROR (%Lf %f %d)", ld, f, ret); \ printf ("\n"); static void @@ -62,40 +62,41 @@ do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...) float *fptr; long double *ldptr; va_list args; + int ret; CLEAR_VALUE printf ("fscanf: "); - FSCANF (stream, format, &ld, &f); + ret = FSCANF (stream, format, &ld, &f); CHECK_VALUE CLEAR_VALUE printf ("scanf: "); - SCANF (format, &ld, &f); + ret = SCANF (format, &ld, &f); CHECK_VALUE CLEAR_VALUE printf ("sscanf: "); - SSCANF (string, format, &ld, &f); + ret = SSCANF (string, format, &ld, &f); CHECK_VALUE CLEAR_VARGS printf ("vfscanf: "); va_start (args, format); - VFSCANF (stream, format, args); + ret = VFSCANF (stream, format, args); va_end (args); CHECK_VARGS CLEAR_VARGS printf ("vscanf: "); va_start (args, format); - VSCANF (format, args); + ret = VSCANF (format, args); va_end (args); CHECK_VARGS CLEAR_VARGS printf ("vsscanf: "); va_start (args, format); - VSSCANF (string, format, args); + ret = VSSCANF (string, format, args); va_end (args); CHECK_VARGS }