From patchwork Tue Jan 12 20:37:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 10353 Received: (qmail 112870 invoked by alias); 12 Jan 2016 20:37:59 -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 112817 invoked by uid 89); 12 Jan 2016 20:37:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qg0-f42.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:content-type; bh=OQBhydr8SCUaRJUIjm7EBfKvRapVomszVV1mA+SEG5k=; b=hPNtyxrso2f7TqqCgsQezGmmGuJGlVXmpH5YA3Pa8epKzAwKkZUGv2bCITP0zuJUmm 0TQT3eSfrrX6hQI4OEcJ5u0aqSiZg/R47+PPsH2b5219KI1NLsY2kVvr7bn9FZMmFn1a 7ThxSZMmeAu7yQiaypXJC8L9NuOtAZVQJJx6ud/AyrSEAYvclG890BVdPWBKjL/wE33o fi3MRZw2X91hFYbWBAbjifOG4MIqYs8ng7gDN+WalAnwsa9EsiTBidGvNmY3VoprQuGh temmE/XXY7UlfJ8JTWr/GRDNXAW0Wj8Xq2V3uJe46saeRMyUA4cmW3Vgg/mg2tSBfjOc 8beA== X-Gm-Message-State: ALoCoQn6zgM73URQOM9bjSbd+05iL3p8O21GlcotrCZvs6svMxVo+osuVcaqAZsD0nw3JT+gRTHi5AxftoQSODDVdchhkmIAhg== X-Received: by 10.140.131.17 with SMTP id 17mr148425239qhd.12.1452631071555; Tue, 12 Jan 2016 12:37:51 -0800 (PST) Message-ID: <5695641C.8090607@gmail.com> Date: Tue, 12 Jan 2016 13:37:48 -0700 From: Martin Sebor User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: GNU C Library Subject: [PATCH] fix #19443 - build failures with -DDEBUG A number of glibc source files contain debugging code guarded by the "#if DEBUG" preprocessor conditional. The DEBUG macro isn't documented but as Carlos notes in his comment on the bug, it can be useful to enable various debugging aspects of glibc, for example in the resolver library. The attached patch makes it possible to build glibc with the macro defined. In one instance (time/mktime.c) the macro is being used in a way that's incompatible with the other uses. In that case I renamed to avoid this problem. In case that raises questions, in resolv/res_send.c, I chose to replace the undeclared abort with __builtin_abort to avoid (mostly) unnecessarily including . I checked for uses of other GCC builtins and found a bunch, though not any of __builtin_abort. Either approach works for me. Tested by building and using the library on powerpc64le and x86_64 with the macro defined. Martin 2016-01-12 Martin Sebor [BZ #19443] * crypt/crypt_util.c [DEBUG] (_ufc_prbits): Correct format string. [DEBUG] (_ufc_set_bits): Declare used. * iconv/gconv_dl.c [DEBUG]: Add a missing include directive. [DEBUG] (print_all): Declare used. * resolv/res_send.c [DEBUG] (__libc_res_nsend): Explicitly convert operands of the ternary ?: expression to target type. * stdlib/rshift.c [DEBUG] (mpn_rshift): Call __builtin_abort() instead of the undeclared abort. * time/mktime.c [DEBUG] (DEBUG): Rename to DEBUG_MKTIME. diff --git a/crypt/crypt_util.c b/crypt/crypt_util.c index 4b6490e..1f42f59 100644 --- a/crypt/crypt_util.c +++ b/crypt/crypt_util.c @@ -271,12 +271,12 @@ _ufc_prbits (ufc_long *a, int n) t=8*i+j; tmp|=(a[t/24] & BITMASK[t % 24])?bytemask[j]:0; } - (void)printf("%02x ",tmp); + (void)printf("%02lx ", tmp); } printf(" "); } -static void +static void __attribute__ ((unused)) _ufc_set_bits (ufc_long v, ufc_long *b) { ufc_long i; diff --git a/iconv/gconv_dl.c b/iconv/gconv_dl.c index 86559d3..4e9dfea 100644 --- a/iconv/gconv_dl.c +++ b/iconv/gconv_dl.c @@ -219,6 +219,9 @@ libc_freeres_fn (free_mem) #ifdef DEBUG + +#include + static void do_print (const void *nodep, VISIT value, int level) { @@ -231,7 +234,7 @@ do_print (const void *nodep, VISIT value, int level) obj->name, obj->counter); } -static void +static void __attribute__ ((used)) print_all (void) { __twalk (loaded, do_print); diff --git a/resolv/res_send.c b/resolv/res_send.c index 3550740..776dcb5 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -499,8 +499,8 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, (stdout, ";; Querying server (# %d) address = %s\n", ns + 1, inet_ntop(nsap->sa_family, (nsap->sa_family == AF_INET6 - ? &((struct sockaddr_in6 *) nsap)->sin6_addr - : &((struct sockaddr_in *) nsap)->sin_addr), + ? (char *)&((struct sockaddr_in6 *) nsap)->sin6_addr + : (char *)&((struct sockaddr_in *) nsap)->sin_addr), tmpbuf, sizeof (tmpbuf)))); if (__glibc_unlikely (v_circuit)) { diff --git a/stdlib/rshift.c b/stdlib/rshift.c index 4cf345c..71f8736 100644 --- a/stdlib/rshift.c +++ b/stdlib/rshift.c @@ -42,7 +42,7 @@ mpn_rshift (register mp_ptr wp, #ifdef DEBUG if (usize == 0 || cnt == 0) - abort (); + __builtin_abort (); #endif sh_1 = cnt; diff --git a/time/mktime.c b/time/mktime.c index 7d06314..bc7ed56 100644 --- a/time/mktime.c +++ b/time/mktime.c @@ -19,7 +19,7 @@ /* Define this to have a standalone program to test this implementation of mktime. */ -/* #define DEBUG 1 */ +/* #define DEBUG_MKTIME 1 */ #ifndef _LIBC # include @@ -38,13 +38,13 @@ #include /* For the real memcpy prototype. */ -#if defined DEBUG && DEBUG +#if defined DEBUG_MKTIME && DEBUG_MKTIME # include # include /* Make it work even if the system's libc has its own mktime routine. */ # undef mktime # define mktime my_mktime -#endif /* DEBUG */ +#endif /* DEBUG_MKTIME */ /* Some of the code in this file assumes that signed integer overflow silently wraps around. This assumption can't easily be programmed @@ -600,7 +600,7 @@ libc_hidden_def (mktime) libc_hidden_weak (timelocal) #endif -#if defined DEBUG && DEBUG +#if defined DEBUG_MKTIME && DEBUG_MKTIME static int not_equal_tm (const struct tm *a, const struct tm *b) @@ -732,10 +732,10 @@ main (int argc, char **argv) return status; } -#endif /* DEBUG */ +#endif /* DEBUG_MKTIME */ /* Local Variables: -compile-command: "gcc -DDEBUG -I. -Wall -W -O2 -g mktime.c -o mktime" +compile-command: "gcc -DDEBUG_MKTIME -I. -Wall -W -O2 -g mktime.c -o mktime" End: */