chiark / gitweb /
systemd-journald: fix endianess bug
[elogind.git] / src / journal / journal-file.c
index 6ba3d8dca37797cd159835edb4a542f8de87c2d2..275caea50e10a7625007f0164ef3be4e6cbad192 100644 (file)
@@ -37,7 +37,7 @@
 
 #define DEFAULT_WINDOW_SIZE (128ULL*1024ULL*1024ULL)
 
-#define COMPRESSION_SIZE_THRESHOLD (64ULL)
+#define COMPRESSION_SIZE_THRESHOLD (512ULL)
 
 /* This is the minimum journal file size */
 #define JOURNAL_FILE_SIZE_MIN (64ULL*1024ULL)
@@ -238,7 +238,7 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
         if (fstat(f->fd, &f->last_stat) < 0)
                 return -errno;
 
-        f->header->arena_size = new_size - htole64(f->header->arena_offset);
+        f->header->arena_size = htole64(new_size - le64toh(f->header->arena_offset));
 
         return 0;
 }
@@ -640,8 +640,7 @@ int journal_file_find_data_object_with_hash(
 
                 if (o->object.flags & OBJECT_COMPRESSED) {
 #ifdef HAVE_XZ
-                        uint64_t l;
-                        size_t rsize;
+                        uint64_t l, rsize;
 
                         l = le64toh(o->object.size);
                         if (l <= offsetof(Object, data.payload))
@@ -652,7 +651,7 @@ int journal_file_find_data_object_with_hash(
                         if (!uncompress_blob(o->data.payload, l, &f->compress_buffer, &f->compress_buffer_size, &rsize))
                                 return -EBADMSG;
 
-                        if ((uint64_t) rsize == size &&
+                        if (rsize == size &&
                             memcmp(f->compress_buffer, data, size) == 0) {
 
                                 if (ret)
@@ -2104,7 +2103,7 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
 void journal_default_metrics(JournalMetrics *m, int fd) {
         uint64_t fs_size = 0;
         struct statvfs ss;
-        char a[64], b[64], c[64], d[64];
+        char a[FORMAT_BYTES_MAX], b[FORMAT_BYTES_MAX], c[FORMAT_BYTES_MAX], d[FORMAT_BYTES_MAX];
 
         assert(m);
         assert(fd >= 0);