diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-07-30 22:25:28 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-07-30 22:25:28 +0000 |
commit | 19e5f24389a9326c16000b001ba2ad4d7840282a (patch) | |
tree | 5544f2140edc596bf9961010df866f11bf3c4af7 | |
parent | d44f267b230c74629de780577c7fe56d73d38edc (diff) |
knf & ansi
-rw-r--r-- | libexec/ld.so/ldconfig/ldconfig.c | 43 | ||||
-rw-r--r-- | libexec/ld.so/ldconfig/shlib.c | 73 |
2 files changed, 38 insertions, 78 deletions
diff --git a/libexec/ld.so/ldconfig/ldconfig.c b/libexec/ld.so/ldconfig/ldconfig.c index 1ca9537def9..0197c4ccacc 100644 --- a/libexec/ld.so/ldconfig/ldconfig.c +++ b/libexec/ld.so/ldconfig/ldconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldconfig.c,v 1.11 2002/05/24 19:00:17 drahn Exp $ */ +/* $OpenBSD: ldconfig.c,v 1.12 2002/07/30 22:25:27 deraadt Exp $ */ /* * Copyright (c) 1993,1995 Paul Kranenburg @@ -86,12 +86,10 @@ static int readhints(void); static void listhints(void); int -main(argc, argv) -int argc; -char *argv[]; +main(int argc, char *argv[]) { - int i, c; - int rval = 0; + int i, c; + int rval = 0; while ((c = getopt(argc, argv, "RUmrsv")) != -1) { switch (c) { @@ -160,6 +158,7 @@ char *argv[]; for (i = 0; i < n_search_dirs; i++) { char *cp = concat(dir_list, *dir_list?":":"", search_dirs[i]); + free(dir_list); dir_list = cp; rval |= dodir(search_dirs[i], 0); @@ -171,9 +170,7 @@ char *argv[]; } int -dodir(dir, silent) -char *dir; -int silent; +dodir(char *dir, int silent) { DIR *dd; struct dirent *dp; @@ -225,9 +222,7 @@ int silent; } static void -enter(dir, file, name, dewey, ndewey) -char *dir, *file, *name; -int dewey[], ndewey; +enter(char *dir, char *file, char *name, int dewey[], int ndewey) { struct shlib_list *shp; @@ -281,9 +276,7 @@ int dewey[], ndewey; #endif int -hinthash(cp, vmajor, vminor) -char *cp; -int vmajor, vminor; +hinthash(char *cp, int vmajor, int vminor) { int k = 0; @@ -299,7 +292,7 @@ int vmajor, vminor; } int -buildhints() +buildhints(void) { struct hints_header hdr; struct hints_bucket *blist; @@ -402,7 +395,7 @@ buildhints() return -1; } if (write(fd, blist, hdr.hh_nbucket * sizeof(struct hints_bucket)) != - hdr.hh_nbucket * sizeof(struct hints_bucket)) { + hdr.hh_nbucket * sizeof(struct hints_bucket)) { warn("%s", _PATH_LD_HINTS); return -1; } @@ -430,16 +423,15 @@ buildhints() } static int -readhints() +readhints(void) { - int fd; + int fd, i; caddr_t addr; long msize; struct hints_header *hdr; struct hints_bucket *blist; char *strtab; struct shlib_list *shp; - int i; if ((fd = open(_PATH_LD_HINTS, O_RDONLY, 0)) == -1) { warn("%s", _PATH_LD_HINTS); @@ -457,7 +449,7 @@ readhints() hdr = (struct hints_header *)addr; if (HH_BADMAG(*hdr)) { warnx("%s: Bad magic: %lo", - _PATH_LD_HINTS, hdr->hh_magic); + _PATH_LD_HINTS, hdr->hh_magic); return -1; } @@ -468,8 +460,8 @@ readhints() if (hdr->hh_ehints > msize) { if (mmap(addr+msize, hdr->hh_ehints - msize, - PROT_READ, MAP_PRIVATE|MAP_FIXED, - fd, msize) != (caddr_t)(addr+msize)) { + PROT_READ, MAP_PRIVATE|MAP_FIXED, + fd, msize) != (caddr_t)(addr+msize)) { warn("%s", _PATH_LD_HINTS); return -1; @@ -509,12 +501,11 @@ readhints() *shlib_tail = shp; shlib_tail = &shp->next; } - return 0; } static void -listhints() +listhints(void) { struct shlib_list *shp; int i; @@ -525,6 +516,4 @@ listhints() for (i = 0, shp = shlib_head; shp; i++, shp = shp->next) printf("\t%d:-l%s.%d.%d => %s\n", i, shp->name, shp->major, shp->minor, shp->path); - - return; } diff --git a/libexec/ld.so/ldconfig/shlib.c b/libexec/ld.so/ldconfig/shlib.c index 6206179f065..20526743a0c 100644 --- a/libexec/ld.so/ldconfig/shlib.c +++ b/libexec/ld.so/ldconfig/shlib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: shlib.c,v 1.6 2002/05/24 04:17:00 deraadt Exp $ */ +/* $OpenBSD: shlib.c,v 1.7 2002/07/30 22:25:27 deraadt Exp $ */ /* $NetBSD: shlib.c,v 1.13 1998/04/04 01:00:29 fvdl Exp $ */ /* @@ -32,11 +32,6 @@ * */ -#ifdef sun -char *strsep(); -int isdigit(); -#endif - #include <sys/param.h> #include <sys/types.h> #include <sys/stat.h> @@ -72,10 +67,8 @@ char *standard_search_dirs[] = { STANDARD_SEARCH_DIRS }; - void -add_search_dir(name) - char *name; +add_search_dir(char *name) { int i, len; @@ -86,18 +79,17 @@ add_search_dir(name) for (i = 0; i < n_search_dirs; i++) if (strlen(search_dirs[i]) == len && - !strncmp(search_dirs[i], name, len)) + !strncmp(search_dirs[i], name, len)) return; n_search_dirs++; search_dirs = (char **) - xrealloc(search_dirs, n_search_dirs * sizeof search_dirs[0]); + xrealloc(search_dirs, n_search_dirs * sizeof search_dirs[0]); search_dirs[n_search_dirs - 1] = xmalloc(++len); (void)strlcpy(search_dirs[n_search_dirs - 1], name, len); } void -remove_search_dir(name) - char *name; +remove_search_dir(char *name) { int i, len; @@ -116,14 +108,13 @@ remove_search_dir(name) (n_search_dirs - i - 1) * sizeof search_dirs[0]); n_search_dirs--; search_dirs = (char **)xrealloc(search_dirs, - n_search_dirs * sizeof search_dirs[0]); + n_search_dirs * sizeof search_dirs[0]); break; } } void -add_search_path(path) -char *path; +add_search_path(char *path) { char *cp, *dup; @@ -138,8 +129,7 @@ char *path; } void -remove_search_path(path) -char *path; +remove_search_path(char *path) { char *cp, *dup; @@ -171,9 +161,7 @@ std_search_path(void) */ int -getdewey(dewey, cp) - int dewey[]; - char *cp; +getdewey(int dewey[], char *cp) { int i, n; @@ -191,7 +179,6 @@ getdewey(dewey, cp) dewey[n++] = strtol(cp, &cp, 10); } - return n; } @@ -202,9 +189,7 @@ getdewey(dewey, cp) * Return 0 if equal. */ int -cmpndewey(d1, n1, d2, n2) -int d1[], d2[]; -int n1, n2; +cmpndewey(int d1[], int n1, int d2[], int n2) { int i; @@ -214,16 +199,12 @@ int n1, n2; if (d1[i] > d2[i]) return 1; } - if (n1 == n2) return 0; - if (i == n1) return -1; - if (i == n2) return 1; - errx(1, "cmpndewey: cant happen"); return 0; } @@ -243,31 +224,24 @@ int n1, n2; #undef minor char * -findshlib(name, majorp, minorp, do_dot_a) -char *name; -int *majorp, *minorp; -int do_dot_a; +findshlib(char *name, int *majorp, int *minorp, int do_dot_a) { - int dewey[MAXDEWEY]; - int ndewey; - int tmp[MAXDEWEY]; - int i; - int len; - char *lname; - int major = *majorp, minor = *minorp; + int major = *majorp, minor = *minorp, ndewey, i, len; + int dewey[MAXDEWEY], tmp[MAXDEWEY]; + char *lname; - len = strlen(name); - lname = (char *)alloca(len + sizeof("lib")); - sprintf(lname, "lib%s", name); - len += 3; + len = strlen(name) + sizeof("lib"); + lname = (char *)alloca(len); + snprintf(lname, len, "lib%s", name); ndewey = 0; for (i = 0; i < n_search_dirs; i++) { - DIR *dd = opendir(search_dirs[i]); - struct dirent *dp; - char *path = NULL; + struct dirent *dp; + char *path = NULL; + DIR *dd; + dd = opendir(search_dirs[i]); if (dd == NULL) continue; @@ -313,12 +287,9 @@ int do_dot_a; } closedir(dd); + /* There's a lib in this dir; take it. */ if (path != NULL) - /* - * There's a lib in this dir; take it. - */ return path; } - return NULL; } |