]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/um/os-Linux/mem.c
[PATCH] uml: change sigjmp_buf to jmp_buf
[linux-2.6-omap-h63xx.git] / arch / um / os-Linux / mem.c
index 6ab372da96579e4a49e372b920ff302d703484f2..71bb90a7606d0ebf8dab332fd874aa0e0f6d707b 100644 (file)
@@ -53,33 +53,36 @@ static void __init find_tempdir(void)
  */
 int make_tempfile(const char *template, char **out_tempname, int do_unlink)
 {
-       char tempname[MAXPATHLEN];
+       char *tempname;
        int fd;
 
+       tempname = malloc(MAXPATHLEN);
+
        find_tempdir();
-       if (*template != '/')
+       if (template[0] != '/')
                strcpy(tempname, tempdir);
        else
-               *tempname = 0;
+               tempname[0] = '\0';
        strcat(tempname, template);
        fd = mkstemp(tempname);
        if(fd < 0){
                fprintf(stderr, "open - cannot create %s: %s\n", tempname,
                        strerror(errno));
-               return -1;
+               goto out;
        }
        if(do_unlink && (unlink(tempname) < 0)){
                perror("unlink");
-               return -1;
+               goto out;
        }
        if(out_tempname){
-               *out_tempname = strdup(tempname);
-               if(*out_tempname == NULL){
-                       perror("strdup");
-                       return -1;
-               }
+               *out_tempname = tempname;
+       } else {
+               free(tempname);
        }
        return(fd);
+out:
+       free(tempname);
+       return -1;
 }
 
 #define TEMPNAME_TEMPLATE "vm_file-XXXXXX"