OSDN Git Service

mkostemp: fix implementation
[uclinux-h8/uClibc.git] / utils / ldconfig.c
index f6aec5c..e6b7881 100644 (file)
@@ -57,8 +57,6 @@ struct exec {
 /* Code indicating core file.  */
 #define CMAGIC 0421
 
-char *___strtok = NULL;
-
 char *prog = NULL;
 int debug = 0;                 /* debug mode */
 int verbose = 0;               /* verbose mode */
@@ -96,6 +94,7 @@ struct needed_tab needed_tab[] = {
 extern char *chroot_realpath(const char *chroot, const char *path,
                             char resolved_path[]);
 
+#if defined __UCLIBC_STATIC_LDCONFIG__ || !defined __UCLIBC_HAS_BSD_ERR__
 /* These two are used internally -- you shouldn't need to use them */
 static void verror_msg(const char *s, va_list p)
 {
@@ -114,7 +113,7 @@ static void warnx(const char *s, ...)
        fprintf(stderr, "\n");
 }
 
-static void attribute_noreturn err(int errnum, const char *s, ...)
+static attribute_noreturn void err(int errnum, const char *s, ...)
 {
        va_list p;
 
@@ -127,14 +126,14 @@ static void attribute_noreturn err(int errnum, const char *s, ...)
 
 static void vperror_msg(const char *s, va_list p)
 {
-       int err = errno;
+       int e = errno;
 
        if (s == 0)
                s = "";
        verror_msg(s, p);
        if (*s)
                s = ": ";
-       fprintf(stderr, "%s%s\n", s, strerror(err));
+       fprintf(stderr, "%s%s\n", s, strerror(e));
 }
 
 static void warn(const char *s, ...)
@@ -145,6 +144,9 @@ static void warn(const char *s, ...)
        vperror_msg(s, p);
        va_end(p);
 }
+#else
+# include <err.h>
+#endif
 
 static void *xmalloc(size_t size)
 {
@@ -173,8 +175,8 @@ static char *xstrdup(const char *str)
 #define readsonameXX readsoname64
 #define __ELF_NATIVE_CLASS 64
 #include "readsoname2.c"
-char *readsoname(char *name, FILE *infile, int expected_type,
-                int *type, int elfclass)
+static char *readsoname(char *name, FILE *infile, int expected_type,
+                       int *type, int elfclass)
 {
        char *res;
 
@@ -206,8 +208,8 @@ char *readsoname(char *name, FILE *infile, int expected_type,
  * If the expected, actual/deduced types missmatch we display a warning
  * and use the actual/deduced type.
  */
-char *is_shlib(const char *dir, const char *name, int *type,
-              int *islink, int expected_type)
+static char *is_shlib(const char *dir, const char *name, int *type,
+                     int *islink, int expected_type)
 {
        char *good = NULL;
        char *cp, *cp2;
@@ -256,10 +258,10 @@ char *is_shlib(const char *dir, const char *name, int *type,
                                 && N_MAGIC_SWAP(exec) != QMAGIC) {
                                        elf_hdr = (ElfW(Ehdr) *) & exec;
                                        if (elf_hdr->e_ident[0] != 0x7f ||
-                                           strncmp((char *)elf_hdr->e_ident + 1, "ELF", 3) != 0)
+                                           strncmp((const char *)elf_hdr->e_ident + 1, "ELF", 3) != 0)
                                        {
                                                /* silently ignore linker scripts */
-                                               if (strncmp((char *)&exec, "/* GNU ld", 9) != 0)
+                                               if (strncmp((const char *)&exec, "/* GNU ld", 9) != 0)
                                                        warnx("%s is not a shared library, skipping", buff);
                                        } else {
                                                /* always call readsoname to update type */
@@ -281,7 +283,7 @@ char *is_shlib(const char *dir, const char *name, int *type,
                                                        /* if the soname does not match the filename,
                                                           issue a warning, but only in debug mode. */
                                                        int len = strlen(good);
-                                                       if (debug && (strncmp(good, name, len) != 0
+                                                       if (debug && (strncmp((const char *)good, name, len) != 0
                                                            || (name[len] != '\0' && name[len] != '.')))
                                                                warnx("%s has inconsistent soname (%s)", buff, good);
                                                }
@@ -323,7 +325,7 @@ char *is_shlib(const char *dir, const char *name, int *type,
 }
 
 /* update the symlink to new library */
-void link_shlib(const char *dir, const char *file, const char *so)
+static void link_shlib(const char *dir, const char *file, const char *so)
 {
        int change = 1;
        char libname[BUFFER_SIZE];
@@ -380,7 +382,7 @@ void link_shlib(const char *dir, const char *file, const char *so)
 }
 
 /* figure out which library is greater */
-int libcmp(char *p1, char *p2)
+static int libcmp(char *p1, char *p2)
 {
        while (*p1) {
                if (isdigit(*p1) && isdigit(*p2)) {
@@ -412,7 +414,7 @@ struct lib {
 };
 
 /* update all shared library links in a directory */
-void scan_dir(const char *rawname)
+static void scan_dir(const char *rawname)
 {
        DIR *dir;
        const char *name;
@@ -554,22 +556,22 @@ void cache_write(void)
 }
 #else
 /* return the list of system-specific directories */
-char *get_extpath(void)
+static char *get_extpath(void)
 {
        char *res = NULL, *cp;
        FILE *file;
-       struct stat stat;
+       struct stat st;
        char realconffile[BUFFER_SIZE];
 
        if (!chroot_realpath(chroot_dir, conffile, realconffile))
                return NULL;
 
        if ((file = fopen(realconffile, "r")) != NULL) {
-               fstat(fileno(file), &stat);
-               res = xmalloc(stat.st_size + 1);
-               fread(res, 1, stat.st_size, file);
+               fstat(fileno(file), &st);
+               res = xmalloc(st.st_size + 1);
+               (void)fread(res, 1, st.st_size, file);
                fclose(file);
-               res[stat.st_size] = '\0';
+               res[st.st_size] = '\0';
 
                /* convert comments fo spaces */
                for (cp = res; *cp; /*nada */ ) {
@@ -783,7 +785,7 @@ void cache_print(void)
 }
 #endif
 
-static void attribute_noreturn usage(void)
+static attribute_noreturn void usage(void)
 {
        fprintf(stderr,
 #ifdef __LDSO_CACHE_SUPPORT__