Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Oct 2018 17:28:27 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r339166 - stable/11/libexec/rtld-elf
Message-ID:  <201810031728.w93HSR77015692@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Oct  3 17:28:27 2018
New Revision: 339166
URL: https://svnweb.freebsd.org/changeset/base/339166

Log:
  MFC r324951 (by trasz):
  Make find_library() conform to style(9).

Modified:
  stable/11/libexec/rtld-elf/rtld.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/libexec/rtld-elf/rtld.c
==============================================================================
--- stable/11/libexec/rtld-elf/rtld.c	Wed Oct  3 17:27:20 2018	(r339165)
+++ stable/11/libexec/rtld-elf/rtld.c	Wed Oct  3 17:28:27 2018	(r339166)
@@ -1590,92 +1590,93 @@ gnu_hash(const char *s)
 static char *
 find_library(const char *xname, const Obj_Entry *refobj, int *fdp)
 {
-    char *pathname;
-    char *name;
-    bool nodeflib, objgiven;
+	char *pathname;
+	char *name;
+	bool nodeflib, objgiven;
 
-    objgiven = refobj != NULL;
+	objgiven = refobj != NULL;
 
-    if (libmap_disable || !objgiven ||
-      (name = lm_find(refobj->path, xname)) == NULL)
-	name = (char *)xname;
+	if (libmap_disable || !objgiven ||
+	    (name = lm_find(refobj->path, xname)) == NULL)
+		name = (char *)xname;
 
-    if (strchr(name, '/') != NULL) {	/* Hard coded pathname */
-	if (name[0] != '/' && !trust) {
-	    _rtld_error("Absolute pathname required for shared object \"%s\"",
-	      name);
-	    return (NULL);
+	if (strchr(name, '/') != NULL) {	/* Hard coded pathname */
+		if (name[0] != '/' && !trust) {
+			_rtld_error("Absolute pathname required "
+			    "for shared object \"%s\"", name);
+			return (NULL);
+		}
+		return (origin_subst(__DECONST(Obj_Entry *, refobj),
+		    __DECONST(char *, name)));
 	}
-	return (origin_subst(__DECONST(Obj_Entry *, refobj),
-	  __DECONST(char *, name)));
-    }
 
-    dbg(" Searching for \"%s\"", name);
+	dbg(" Searching for \"%s\"", name);
 
-    /*
-     * If refobj->rpath != NULL, then refobj->runpath is NULL.  Fall
-     * back to pre-conforming behaviour if user requested so with
-     * LD_LIBRARY_PATH_RPATH environment variable and ignore -z
-     * nodeflib.
-     */
-    if (objgiven && refobj->rpath != NULL && ld_library_path_rpath) {
-	pathname = search_library_path(name, ld_library_path);
-	if (pathname != NULL)
-	    return (pathname);
-	if (refobj != NULL) {
-	    pathname = search_library_path(name, refobj->rpath);
-	    if (pathname != NULL)
-	      return (pathname);
+	/*
+	 * If refobj->rpath != NULL, then refobj->runpath is NULL.  Fall
+	 * back to pre-conforming behaviour if user requested so with
+	 * LD_LIBRARY_PATH_RPATH environment variable and ignore -z
+	 * nodeflib.
+	 */
+	if (objgiven && refobj->rpath != NULL && ld_library_path_rpath) {
+		pathname = search_library_path(name, ld_library_path);
+		if (pathname != NULL)
+			return (pathname);
+		if (refobj != NULL) {
+			pathname = search_library_path(name, refobj->rpath);
+			if (pathname != NULL)
+				return (pathname);
+		}
+		pathname = search_library_pathfds(name, ld_library_dirs, fdp);
+		if (pathname != NULL)
+			return (pathname);
+		pathname = search_library_path(name, gethints(false));
+		if (pathname != NULL)
+			return (pathname);
+		pathname = search_library_path(name, ld_standard_library_path);
+		if (pathname != NULL)
+			return (pathname);
+	} else {
+		nodeflib = objgiven ? refobj->z_nodeflib : false;
+		if (objgiven) {
+			pathname = search_library_path(name, refobj->rpath);
+			if (pathname != NULL)
+				return (pathname);
+		}
+		if (objgiven && refobj->runpath == NULL && refobj != obj_main) {
+			pathname = search_library_path(name, obj_main->rpath);
+			if (pathname != NULL)
+				return (pathname);
+		}
+		pathname = search_library_path(name, ld_library_path);
+		if (pathname != NULL)
+			return (pathname);
+		if (objgiven) {
+			pathname = search_library_path(name, refobj->runpath);
+			if (pathname != NULL)
+				return (pathname);
+		}
+		pathname = search_library_pathfds(name, ld_library_dirs, fdp);
+		if (pathname != NULL)
+			return (pathname);
+		pathname = search_library_path(name, gethints(nodeflib));
+		if (pathname != NULL)
+			return (pathname);
+		if (objgiven && !nodeflib) {
+			pathname = search_library_path(name,
+			    ld_standard_library_path);
+			if (pathname != NULL)
+				return (pathname);
+		}
 	}
-	pathname = search_library_pathfds(name, ld_library_dirs, fdp);
-	if (pathname != NULL)
-	    return (pathname);
-	pathname = search_library_path(name, gethints(false));
-	if (pathname != NULL)
-	    return (pathname);
-	pathname = search_library_path(name, ld_standard_library_path);
-	if (pathname != NULL)
-	    return (pathname);
-    } else {
-	nodeflib = objgiven ? refobj->z_nodeflib : false;
-	if (objgiven) {
-	    pathname = search_library_path(name, refobj->rpath);
-	    if (pathname != NULL)
-		return (pathname);
-	}
-	if (objgiven && refobj->runpath == NULL && refobj != obj_main) {
-	    pathname = search_library_path(name, obj_main->rpath);
-	    if (pathname != NULL)
-		return (pathname);
-	}
-	pathname = search_library_path(name, ld_library_path);
-	if (pathname != NULL)
-	    return (pathname);
-	if (objgiven) {
-	    pathname = search_library_path(name, refobj->runpath);
-	    if (pathname != NULL)
-		return (pathname);
-	}
-	pathname = search_library_pathfds(name, ld_library_dirs, fdp);
-	if (pathname != NULL)
-	    return (pathname);
-	pathname = search_library_path(name, gethints(nodeflib));
-	if (pathname != NULL)
-	    return (pathname);
-	if (objgiven && !nodeflib) {
-	    pathname = search_library_path(name, ld_standard_library_path);
-	    if (pathname != NULL)
-		return (pathname);
-	}
-    }
 
-    if (objgiven && refobj->path != NULL) {
-	_rtld_error("Shared object \"%s\" not found, required by \"%s\"",
-	  name, basename(refobj->path));
-    } else {
-	_rtld_error("Shared object \"%s\" not found", name);
-    }
-    return NULL;
+	if (objgiven && refobj->path != NULL) {
+		_rtld_error("Shared object \"%s\" not found, "
+		    "required by \"%s\"", name, basename(refobj->path));
+	} else {
+		_rtld_error("Shared object \"%s\" not found", name);
+	}
+	return (NULL);
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201810031728.w93HSR77015692>