journal: use int64_t instead of long for catalog file size

This replaces the use of ftell() with ftello() for 64-bit size on all
archs.

Also drops a pointless check for NULL before calling strbuf_cleanup().
This commit is contained in:
Michal Schmidt
2015-11-05 13:44:05 +01:00
parent 8d2ecdb2cf
commit 77ba8233f7
+15 -13
View File
@@ -319,8 +319,8 @@ int catalog_import_file(Hashmap *h, struct strbuf *sb, const char *path) {
return 0;
}
static long write_catalog(const char *database, struct strbuf *sb,
CatalogItem *items, size_t n) {
static int64_t write_catalog(const char *database, struct strbuf *sb,
CatalogItem *items, size_t n) {
CatalogHeader header;
_cleanup_fclose_ FILE *w = NULL;
int r;
@@ -379,7 +379,7 @@ static long write_catalog(const char *database, struct strbuf *sb,
goto error;
}
return ftell(w);
return ftello(w);
error:
(void) unlink(p);
@@ -395,7 +395,8 @@ int catalog_update(const char* database, const char* root, const char* const* di
CatalogItem *i;
Iterator j;
unsigned n;
long r;
int r;
int64_t sz;
h = hashmap_new(&catalog_hash_ops);
sb = strbuf_new();
@@ -445,18 +446,19 @@ int catalog_update(const char* database, const char* root, const char* const* di
assert(n == hashmap_size(h));
qsort_safe(items, n, sizeof(CatalogItem), catalog_compare_func);
r = write_catalog(database, sb, items, n);
if (r < 0)
log_error_errno(r, "Failed to write %s: %m", database);
else
log_debug("%s: wrote %u items, with %zu bytes of strings, %ld total size.",
database, n, sb->len, r);
sz = write_catalog(database, sb, items, n);
if (sz < 0)
r = log_error_errno(sz, "Failed to write %s: %m", database);
else {
r = 0;
log_debug("%s: wrote %u items, with %zu bytes of strings, %"PRIi64" total size.",
database, n, sb->len, sz);
}
finish:
if (sb)
strbuf_cleanup(sb);
strbuf_cleanup(sb);
return r < 0 ? r : 0;
return r;
}
static int open_mmap(const char *database, int *_fd, struct stat *_st, void **_p) {