From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id 63ACF3857C4A for ; Thu, 16 Jul 2020 08:28:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 63ACF3857C4A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sebastian.huber@embedded-brains.de Received: from sslproxy03.your-server.de ([88.198.220.132]) by dedi548.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1jvzG7-0007J2-2r for newlib@sourceware.org; Thu, 16 Jul 2020 10:28:51 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy03.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jvzG6-000TfP-VJ for newlib@sourceware.org; Thu, 16 Jul 2020 10:28:50 +0200 Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id D6EA72A1610 for ; Thu, 16 Jul 2020 10:29:21 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 1Gb2miSUIEpo for ; Thu, 16 Jul 2020 10:29:21 +0200 (CEST) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 8B19A2A165B for ; Thu, 16 Jul 2020 10:29:21 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id r2poosVU0rhd for ; Thu, 16 Jul 2020 10:29:21 +0200 (CEST) Received: from linux-diu0.suse (unknown [192.168.96.142]) by mail.embedded-brains.de (Postfix) with ESMTP id 673C82A1610 for ; Thu, 16 Jul 2020 10:29:21 +0200 (CEST) From: Sebastian Huber To: newlib@sourceware.org Subject: [PATCH] ctype.h: Fix unused variable warnings Date: Thu, 16 Jul 2020 10:28:49 +0200 Message-Id: <20200716082849.20381-1-sebastian.huber@embedded-brains.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.102.3/25874/Wed Jul 15 16:18:08 2020) X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jul 2020 08:28:53 -0000 From: Aschref Ben Thabet If __HAVE_LOCALE_INFO__ is not defined, then the locale in the locale-specific ctype functions is ignored. In the previous implementation this resulted in compiler warnings. For example: int main() { locale_t locale; locale =3D duplocale(uselocale((locale_t)0)); isspace_l('x', locale); return 0; } gcc -Wall main.c main.c: In function 'main': main.c:6:11: warning: variable 'locale' set but not used [-Wunused-but-se= t-variable] 6 | locale_t locale; | ^~~~~~ --- newlib/libc/include/ctype.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/newlib/libc/include/ctype.h b/newlib/libc/include/ctype.h index a0009af17..8b1013ac0 100644 --- a/newlib/libc/include/ctype.h +++ b/newlib/libc/include/ctype.h @@ -66,6 +66,9 @@ extern int toascii_l (int __c, locale_t __l); #define _X 0100 #define _B 0200 =20 +/* For C++ backward-compatibility only. */ +extern __IMPORT const char _ctype_[]; + #ifdef __HAVE_LOCALE_INFO__ const char *__locale_ctype_ptr (void); #else @@ -108,7 +111,12 @@ const char *__locale_ctype_ptr (void); #ifdef __HAVE_LOCALE_INFO__ const char *__locale_ctype_ptr_l (locale_t); #else -#define __locale_ctype_ptr_l(l) _ctype_ +static __inline char * +__locale_ctype_ptr_l(locale_t _l) +{ + (void)_l; + return __locale_ctype_ptr(); +} #endif #define __ctype_lookup_l(__c,__l) ((__locale_ctype_ptr_l(__l)+sizeof(""[= __c]))[(int)(__c)]) =20 @@ -170,9 +178,6 @@ const char *__locale_ctype_ptr_l (locale_t); =20 #endif /* !__cplusplus */ =20 -/* For C++ backward-compatibility only. */ -extern __IMPORT const char _ctype_[]; - _END_STD_C =20 #endif /* _CTYPE_H_ */ --=20 2.26.2