]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-snapshot.c
Remove redundant calls to fmt("%s", ...)
[ps-cgit] / ui-snapshot.c
index 7374d9d851ca70fb4d53e3d1fd22426d9c9f48e5..a47884e85556ff75d24364f67f441994d339ca7b 100644 (file)
@@ -8,12 +8,14 @@
  */
 
 #include "cgit.h"
+#include "ui-snapshot.h"
 #include "html.h"
 #include "ui-shared.h"
 
 static int write_archive_type(const char *format, const char *hex, const char *prefix)
 {
        struct argv_array argv = ARGV_ARRAY_INIT;
+       argv_array_push(&argv, "snapshot");
        argv_array_push(&argv, format);
        if (prefix) {
                argv_array_push(&argv, "--prefix");
@@ -72,7 +74,7 @@ const struct cgit_snapshot_format cgit_snapshot_formats[] = {
        { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive, 0x04 },
        { ".tar", "application/x-tar", write_tar_archive, 0x08 },
        { ".tar.xz", "application/x-xz", write_tar_xz_archive, 0x10 },
-       {}
+       { NULL }
 };
 
 static const struct cgit_snapshot_format *get_format(const char *filename)
@@ -81,7 +83,7 @@ static const struct cgit_snapshot_format *get_format(const char *filename)
        int fl, sl;
 
        fl = strlen(filename);
-       for(fmt = cgit_snapshot_formats; fmt->suffix; fmt++) {
+       for (fmt = cgit_snapshot_formats; fmt->suffix; fmt++) {
                sl = strlen(fmt->suffix);
                if (sl >= fl)
                        continue;
@@ -98,11 +100,11 @@ static int make_snapshot(const struct cgit_snapshot_format *format,
        unsigned char sha1[20];
 
        if (get_sha1(hex, sha1)) {
-               cgit_print_error(fmt("Bad object id: %s", hex));
+               cgit_print_error("Bad object id: %s", hex);
                return 1;
        }
        if (!lookup_commit_reference(sha1)) {
-               cgit_print_error(fmt("Not a commit reference: %s", hex));
+               cgit_print_error("Not a commit reference: %s", hex);
                return 1;
        }
        ctx.page.mimetype = xstrdup(format->mimetype);
@@ -152,13 +154,18 @@ static const char *get_ref_from_filename(const char *url, const char *filename,
        return NULL;
 }
 
-void show_error(char *msg)
+__attribute__((format (printf, 1, 2)))
+static void show_error(char *fmt, ...)
 {
+       va_list ap;
+
        ctx.page.mimetype = "text/html";
        cgit_print_http_headers(&ctx);
        cgit_print_docstart(&ctx);
        cgit_print_pageheader(&ctx);
-       cgit_print_error(msg);
+       va_start(ap, fmt);
+       cgit_vprint_error(fmt, ap);
+       va_end(ap);
        cgit_print_docend();
 }
 
@@ -175,8 +182,7 @@ void cgit_print_snapshot(const char *head, const char *hex,
 
        f = get_format(filename);
        if (!f) {
-               show_error(xstrdup(fmt("Unsupported snapshot format: %s",
-                                      filename)));
+               show_error("Unsupported snapshot format: %s", filename);
                return;
        }