diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2015-11-05 13:44:05 +0100 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2015-11-05 13:44:05 +0100 |
commit | 77ba8233f70719ddd53373f98c53c5cfd5ff13c7 (patch) | |
tree | 74821e17f137cb86af98833e8f72b4fc99dc5516 /src/journal/catalog.c | |
parent | 8d2ecdb2cf1bc5b1125e69deaa852c6791ab5a41 (diff) |
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().
Diffstat (limited to 'src/journal/catalog.c')
-rw-r--r-- | src/journal/catalog.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/journal/catalog.c b/src/journal/catalog.c index 7f43a49bcf..ef515fc2d7 100644 --- a/src/journal/catalog.c +++ b/src/journal/catalog.c @@ -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) { |