From patchwork Thu Jul 30 02:55:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 501906 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 447F0140788 for ; Thu, 30 Jul 2015 12:55:30 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=SudPVgDN; 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:from:to:subject:date:message-id; q=dns; s= default; b=JUKlhBCNQ4mjvWADFzaAuMZY+W8f7s99PJaDqQrd63o/mFwjDVksz ikESq8RVUvzt6ahzqy/fTyWTTQnSku/tdbztB2b3Y5BwBj5ai7qXyYZU9c3awWRs /ChU+hHlJAGW9sLMt2FoJPaI2Agf5MDUeOCAnJc60sa+0USJLn8gvo= 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:from:to:subject:date:message-id; s=default; bh=UZcvlZHTPF9A0rrEABVJdc8T+zs=; b=SudPVgDNXRFTfyTQg6yFGW+QjSld tOUiqWZZC/LMgwIYPHAe8ZIFBKM+c2AwPYJUd4ia0VqXYiy1oHKbDiJwxGYlldEl hZWcKMuXKWyUbqhGJmVEebaUMRiimLFg2ef5g5WxrFlJAT7k5QycDmIkCXyo8qye tEfM2WIqjckfaZs= Received: (qmail 87210 invoked by alias); 30 Jul 2015 02:55:25 -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 87153 invoked by uid 89); 30 Jul 2015 02:55:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: smtp.gentoo.org From: Mike Frysinger To: libc-alpha@sourceware.org Subject: [PATCH] nptl: fix set-but-unused warning w/_STACK_GROWS_UP Date: Wed, 29 Jul 2015 22:55:16 -0400 Message-Id: <1438224916-27724-1-git-send-email-vapier@gentoo.org> On arches that set _STACK_GROWS_UP, the stacktop variable is declared and set, but never actually used. Refactor the code a bit so that the variable is only declared/set under _STACK_GROWS_DOWN settings. 2015-07-30 Mike Frysinger * nptl/allocatestack.c (allocate_stack): Move stacktop decl down to bottom and under _STACK_GROWS_DOWN. Move the stacktop assignment in there too. --- nptl/allocatestack.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index c56a4df..753da61 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -353,7 +353,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, struct pthread *pd; size_t size; size_t pagesize_m1 = __getpagesize () - 1; - void *stacktop; assert (powerof2 (pagesize_m1 + 1)); assert (TCB_ALIGNMENT >= STACK_ALIGN); @@ -717,19 +716,23 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, /* We place the thread descriptor at the end of the stack. */ *pdp = pd; -#if TLS_TCB_AT_TP +#if _STACK_GROWS_DOWN + void *stacktop; + +# if TLS_TCB_AT_TP /* The stack begins before the TCB and the static TLS block. */ stacktop = ((char *) (pd + 1) - __static_tls_size); -#elif TLS_DTV_AT_TP +# elif TLS_DTV_AT_TP stacktop = (char *) (pd - 1); -#endif +# endif -#ifdef NEED_SEPARATE_REGISTER_STACK +# ifdef NEED_SEPARATE_REGISTER_STACK *stack = pd->stackblock; *stacksize = stacktop - *stack; -#elif _STACK_GROWS_DOWN +# else *stack = stacktop; -#elif _STACK_GROWS_UP +# endif +#else *stack = pd->stackblock; assert (*stack > 0); #endif