Allow the test suite to pass in a directory whose name contains spaces
[gitweb.git] / server-info.c
index 5a86e297b51261b5f1ae9fa6dad6fa7dc86cd4ba..f6c1a3dfb04bff5310a1b930b03478d88c9c2904 100644 (file)
@@ -14,19 +14,21 @@ static int update_info_file(char *path, int (*generate)(FILE *))
        char *tmp = mkpathdup("%s_XXXXXX", path);
        int ret = -1;
        int fd = -1;
-       FILE *fp = NULL;
+       FILE *fp = NULL, *to_close;
 
        safe_create_leading_directories(path);
        fd = git_mkstemp_mode(tmp, 0666);
        if (fd < 0)
                goto out;
-       fp = fdopen(fd, "w");
+       to_close = fp = fdopen(fd, "w");
        if (!fp)
                goto out;
+       fd = -1;
        ret = generate(fp);
        if (ret)
                goto out;
-       if (fclose(fp))
+       fp = NULL;
+       if (fclose(to_close))
                goto out;
        if (adjust_shared_perm(tmp) < 0)
                goto out;
@@ -36,7 +38,7 @@ static int update_info_file(char *path, int (*generate)(FILE *))
 
 out:
        if (ret) {
-               error("unable to update %s: %s", path, strerror(errno));
+               error_errno("unable to update %s", path);
                if (fp)
                        fclose(fp);
                else if (fd >= 0)
@@ -229,7 +231,7 @@ static void init_pack_info(const char *infofile, int force)
        }
 
        /* renumber them */
-       qsort(info, num_pack, sizeof(info[0]), compare_info);
+       QSORT(info, num_pack, compare_info);
        for (i = 0; i < num_pack; i++)
                info[i]->new_num = i;
 }