From patchwork Wed Oct 1 21:13:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Serebryany X-Patchwork-Id: 395681 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 55ACD14016A for ; Thu, 2 Oct 2014 07:13:42 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; q=dns; s=default; b=C4qb 44iNtIS4OpxP6NYTrSDCMKIO04ZstSGAB/GkeFOlXGXjKaxyMIDT3+CbczX+7x/j njZOJt/911SKeMx9TLCzp6qkOrQmm7Zw1aIbaA4DlHkGqGwm3vzUWUSAMhmnOqA0 +jKwR3+ZQ5a7F8V4mnjBrVJeBvEBXmXh2n95x84= 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:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; s=default; bh=lrwX7+/Mtv bOUcnojzkTDo/HjpI=; b=J34Qu38XNvJQxGFEhVvL/3Kz9RnJELsIVdF19bfUF+ XVDsa43/E7AKyAsz/f5tf4EsvPekMQjxlxmuG/m2QZJOTqy6ehaKWvsiXjY82X7c Avmr4ybXvGFG3zfIqptoxsfHUsKjDki6AyVFE8QMJY8cxsJbdQ+yJ1SvaeBuHJQJ w= Received: (qmail 12787 invoked by alias); 1 Oct 2014 21:13:36 -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 12763 invoked by uid 89); 1 Oct 2014 21:13:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vc0-f170.google.com X-Received: by 10.220.1.5 with SMTP id 5mr4318960vcd.74.1412198009109; Wed, 01 Oct 2014 14:13:29 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20141001204919.D5B132C3AAD@topped-with-meat.com> References: <20141001204919.D5B132C3AAD@topped-with-meat.com> From: Konstantin Serebryany Date: Wed, 1 Oct 2014 14:13:08 -0700 Message-ID: Subject: Re: [PATCH] remove nested functions from elf/dl-deps.c To: Roland McGrath Cc: GNU C Library Fixed all, retested. Please have another look. On Wed, Oct 1, 2014 at 1:49 PM, Roland McGrath wrote: >> +static inline >> +void preload (struct link_map *map, struct list *known, unsigned int *nlist) > > The return type goes on the first line. The function name always starts > its line. > > It's general policy not to use the 'inline' keyword for static functions in > a .c file. Unless there is a strong known reason, just let the compiler > decide about inlining. (This is a relatively recent policy, so you might > find counterexamples in the code.) > > When a function has some parameters that are the "context" and some that > are the specific parameters for the specific call, the style I prefer (and > have used throughout the codebase) is to put all the "context" ones first. > >> +{ >> + known[*nlist].done = 0; >> + known[*nlist].map = map; >> + known[*nlist].next = &known[*nlist + 1]; >> + >> + ++(*nlist); > > Drop superfluous parens. > > > Thanks, > Roland diff --git a/elf/dl-deps.c b/elf/dl-deps.c index c3b0cfc..f66b266 100644 --- a/elf/dl-deps.c +++ b/elf/dl-deps.c @@ -138,6 +138,19 @@ cannot load auxiliary `%s' because of empty dynamic string token " \ \ __result; }) +static void +preload (struct list *known, unsigned int *nlist, struct link_map *map) +{ + known[*nlist].done = 0; + known[*nlist].map = map; + known[*nlist].next = &known[*nlist + 1]; + + ++*nlist; + /* We use `l_reserved' as a mark bit to detect objects we have + already put in the search list and avoid adding duplicate + elements later in the list. */ + map->l_reserved = 1; +} void internal_function @@ -155,28 +168,15 @@ _dl_map_object_deps (struct link_map *map, const char *errstring; const char *objname; - void preload (struct link_map *map) - { - known[nlist].done = 0; - known[nlist].map = map; - known[nlist].next = &known[nlist + 1]; - - ++nlist; - /* We use `l_reserved' as a mark bit to detect objects we have - already put in the search list and avoid adding duplicate - elements later in the list. */ - map->l_reserved = 1; - } - /* No loaded object so far. */ nlist = 0; /* First load MAP itself. */ - preload (map); + preload (known, &nlist, map); /* Add the preloaded items after MAP but before any of its dependencies. */ for (i = 0; i < npreloads; ++i) - preload (preloads[i]); + preload (known, &nlist, preloads[i]); /* Terminate the lists. */ known[nlist - 1].next = NULL;