Remove dead code
[freeradius.git] / scripts / jlibtool.c
index cdad9b5..8abbaed 100644 (file)
@@ -414,6 +414,14 @@ static void *lt_malloc(size_t size)
        return out;
 }
 
+static void lt_const_free(const void *ptr)
+{
+       void *tmp;
+       
+       memcpy(&tmp, &ptr, sizeof(tmp));
+       free(tmp);
+}
+
 static void init_count_chars(count_chars *cc)
 {
        cc->vals = (const char**) lt_malloc(PATH_MAX*sizeof(char*));
@@ -1068,37 +1076,17 @@ static char *gen_install_name(const char *name, enum lib_type genlib)
 static const char *check_object_exists(command_t *cmd, const char *arg, int arglen)
 {
        char *newarg, *ext;
-       int pass, rv;
+       struct stat sb;
 
        newarg = (char *)lt_malloc(arglen + 10);
        memcpy(newarg, arg, arglen);
        newarg[arglen] = 0;
        ext = newarg + arglen;
 
-       pass = 0;
-
-       do {
-               struct stat sb;
-
-               switch (pass) {
-               case 0:
-                       strcpy(ext, OBJECT_EXT);
-                       break;
-/*
-               case 1:
-                       strcpy(ext, NO_PIC_EXT);
-                       break;
-*/
-               default:
-                       break;
-               }
-
-               DEBUG("Checking (obj): %s\n", newarg);
-               rv = stat(newarg, &sb);
-       }
-       while (rv != 0 && ++pass < 1);
-
-       if (rv == 0) {
+       strcpy(ext, OBJECT_EXT);
+       
+       DEBUG("Checking (obj): %s\n", newarg);
+       if (stat(newarg, &sb) == 0) {
                return newarg;
        }
        
@@ -1307,7 +1295,7 @@ static void add_rpath_file(count_chars *cc, const char *arg)
        path = load_install_path(arg);
        if (path) {
                add_rpath(cc, path);
-       free(path);
+               lt_const_free(path);
        }
 }
 
@@ -1318,7 +1306,7 @@ static void add_rpath_noinstall(count_chars *cc, const char *arg, int pathlen)
        path = load_noinstall_path(arg, pathlen);
        if (path) {
                add_rpath(cc, path);
-               free(path);
+               lt_const_free(path);
        }
 }
 #endif
@@ -1525,7 +1513,7 @@ static int parse_input_file_name(const char *arg, command_t *cmd)
                struct stat sb;
                
                if (!stat(arg, &sb)) {
-                       DEBUG("Adding object: %s\n", newarg);
+                       DEBUG("Adding object: %s\n", arg);
                        
                        push_count_chars(cmd->obj_files, arg);
                        
@@ -1713,25 +1701,25 @@ static int parse_output_file_name(const char *arg, command_t *cmd)
                cmd->module_name.install = gen_install_name(arg, TYPE_MODULE_LIB);
 
                if (!cmd->options.dry_run) {
-               char *newname;
-               char *newext;
-               newname = lt_malloc(strlen(cmd->static_name.normal) + 1);
+                       char *newname;
+                       char *newext;
+                       newname = lt_malloc(strlen(cmd->static_name.normal) + 1);
 
-               strcpy(newname, cmd->static_name.normal);
-               newext = strrchr(newname, '/');
-               if (!newext) {
-                       /* Check first to see if the dir already exists! */
-                       safe_mkdir(cmd, ".libs");
-               } else {
-                       *newext = '\0';
-                       safe_mkdir(cmd, newname);
-               }
-               free(newname);
+                       strcpy(newname, cmd->static_name.normal);
+                       newext = strrchr(newname, '/');
+                       if (!newext) {
+                               /* Check first to see if the dir already exists! */
+                               safe_mkdir(cmd, ".libs");
+                       } else {
+                               *newext = '\0';
+                               safe_mkdir(cmd, newname);
+                       }
+                       free(newname);
                }
 
 #ifdef TRUNCATE_DLL_NAME
                if (shared) {
-                 arg = truncate_dll_name(arg);
+                       arg = truncate_dll_name(arg);
                }
 #endif
 
@@ -1749,20 +1737,20 @@ static int parse_output_file_name(const char *arg, command_t *cmd)
                cmd->static_name.install = gen_install_name(arg, TYPE_STATIC_LIB);
 
                if (!cmd->options.dry_run) {
-               char *newname;
-               char *newext;
-               newname = lt_malloc(strlen(cmd->static_name.normal) + 1);
+                       char *newname;
+                       char *newext;
+                       newname = lt_malloc(strlen(cmd->static_name.normal) + 1);
 
-               strcpy(newname, cmd->static_name.normal);
-               newext = strrchr(newname, '/');
-               if (!newext) {
-                       /* Check first to see if the dir already exists! */
-                       safe_mkdir(cmd, ".libs");
-               } else {
-                       *newext = '\0';
-                       safe_mkdir(cmd, newname);
-               }
-               free(newname);
+                       strcpy(newname, cmd->static_name.normal);
+                       newext = strrchr(newname, '/');
+                       if (!newext) {
+                               /* Check first to see if the dir already exists! */
+                               safe_mkdir(cmd, ".libs");
+                       } else {
+                               *newext = '\0';
+                               safe_mkdir(cmd, newname);
+                       }
+                       free(newname);
                }
 
                cmd->output_name = arg;
@@ -1909,7 +1897,7 @@ static void generate_def_file(command_t *cmd)
                        ext = strrchr(implib_file, '.');
 
                        if (ext) {
-                               *ext = 0;
+                               *ext = '\0';
                        }
                        
                        strcat(implib_file, ".");