[PATCH] Consolidate link map sorting

Florian Weimer fweimer@redhat.com
Fri Nov 24 12:47:00 GMT 2017


On 11/09/2017 10:45 AM, Andreas Schwab wrote:
> +/* Sort array MAPS according to dependencies of the contained objects.
> +   Array USED, if non-NULL, is permutated along MAPS.  If USE_RELDEPS also
> +   take relocation dependencies into account.  */
> +void
> +_dl_sort_maps (struct link_map **maps, unsigned int nmaps, char *used,
> +	       bool use_reldeps)
> +{
> +  /* A list of one element need not be sorted.  */
> +  if (nmaps <= 1)
> +    return;

We bail out early if we skipped the initial element of the link map 
array.  Previously, we would have sorted the one-element list, which is 
a no-op as well (the “while (k > i)” loop isn't entered), so this should 
be fine.

I didn't find any other differences after comparing the implementations 
line by line, so this is okay.  This is a great cleanup.

Thanks,
Florian



More information about the Libc-alpha mailing list