From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 2C8693858C66 for ; Fri, 28 Apr 2023 12:35:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2C8693858C66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682685326; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qIvFx/lwDgz1VYDAnTthnIWSFYJEcmm8bFUw7WILqSM=; b=Ec4DYb3hjnTGpe9xEeQGOrPf60cB0gbTRcSNxYmCwkK84rTrwX+1v3V84jKZvTmZ8gyPFK koCHiOjzi2dkZWybE8AvNp4loXoY/XoecpNWtIwl0dGs6fxLKdBO22d5hnsGi+dQrC1SV9 lj/FgOVLVmNLCy/2VVmvLNBwx+Mipl8= 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-437-1RAMHJeaPZ-UE55JXpktlw-1; Fri, 28 Apr 2023 08:35:23 -0400 X-MC-Unique: 1RAMHJeaPZ-UE55JXpktlw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F07E81078508; Fri, 28 Apr 2023 12:35:22 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 564BEC15BA0; Fri, 28 Apr 2023 12:35:22 +0000 (UTC) From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20B=C3=A9rat?= To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com Subject: [PATCH v4 02/15] locale/programs/locarchive.c: fix warn unused result Date: Fri, 28 Apr 2023 14:21:29 +0200 Message-Id: <20230428122142.928135-3-fberat@redhat.com> In-Reply-To: <20230418121130.844302-5-fberat@redhat.com> References: <20230428122142.928135-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.0 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_H2,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 List-Id: Changes since v2: - Freeing normalized_codeset before returning. Changes since v3: - Rebased on master --8<-- Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in glibc. --- locale/programs/locarchive.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c index 8d7d51af6c..71fd9f34fa 100644 --- a/locale/programs/locarchive.c +++ b/locale/programs/locarchive.c @@ -1154,10 +1154,14 @@ add_locale_to_archive (struct locarhandle *ah, const char *name, if (mask & XPG_NORM_CODESET) /* This name contains a codeset in unnormalized form. We will store it in the archive with a normalized name. */ - asprintf (&normalized_name, "%s%s%s.%s%s%s", - language, territory == NULL ? "" : "_", territory ?: "", - normalized_codeset, - modifier == NULL ? "" : "@", modifier ?: ""); + if (asprintf (&normalized_name, "%s%s%s.%s%s%s", + language, territory == NULL ? "" : "_", territory ?: "", + normalized_codeset, + modifier == NULL ? "" : "@", modifier ?: "") < 0) + { + free ((char *) normalized_codeset); + return -1; + } /* This call does the main work. */ locrec_offset = add_locale (ah, normalized_name ?: name, data, replace); @@ -1188,10 +1192,14 @@ add_locale_to_archive (struct locarhandle *ah, const char *name, normalized_codeset = _nl_normalize_codeset (codeset, strlen (codeset)); mask |= XPG_NORM_CODESET; - asprintf (&normalized_codeset_name, "%s%s%s.%s%s%s", - language, territory == NULL ? "" : "_", territory ?: "", - normalized_codeset, - modifier == NULL ? "" : "@", modifier ?: ""); + if (asprintf (&normalized_codeset_name, "%s%s%s.%s%s%s", + language, territory == NULL ? "" : "_", territory ?: "", + normalized_codeset, + modifier == NULL ? "" : "@", modifier ?: "") < 0) + { + free ((char *) normalized_codeset); + return -1; + } add_alias (ah, normalized_codeset_name, replace, normalized_name ?: name, &locrec_offset); -- 2.39.2