journal-file: structured initialization is your friend

This commit is contained in:
Lennart Poettering 2018-10-25 21:35:32 +02:00
parent a33687b792
commit 971b52c485

View file

@ -3224,30 +3224,30 @@ int journal_file_open(
if (fname && (flags & O_CREAT) && !endswith(fname, ".journal")) if (fname && (flags & O_CREAT) && !endswith(fname, ".journal"))
return -EINVAL; return -EINVAL;
f = new0(JournalFile, 1); f = new(JournalFile, 1);
if (!f) if (!f)
return -ENOMEM; return -ENOMEM;
f->fd = fd; *f = (JournalFile) {
f->mode = mode; .fd = fd,
.mode = mode,
.flags = flags,
.prot = prot_from_flags(flags),
.writable = (flags & O_ACCMODE) != O_RDONLY,
f->flags = flags;
f->prot = prot_from_flags(flags);
f->writable = (flags & O_ACCMODE) != O_RDONLY;
#if HAVE_LZ4 #if HAVE_LZ4
f->compress_lz4 = compress; .compress_lz4 = compress,
#elif HAVE_XZ #elif HAVE_XZ
f->compress_xz = compress; .compress_xz = compress,
#endif #endif
.compress_threshold_bytes = compress_threshold_bytes == (uint64_t) -1 ?
if (compress_threshold_bytes == (uint64_t) -1) DEFAULT_COMPRESS_THRESHOLD :
f->compress_threshold_bytes = DEFAULT_COMPRESS_THRESHOLD; MAX(MIN_COMPRESS_THRESHOLD, compress_threshold_bytes),
else
f->compress_threshold_bytes = MAX(MIN_COMPRESS_THRESHOLD, compress_threshold_bytes);
#if HAVE_GCRYPT #if HAVE_GCRYPT
f->seal = seal; .seal = seal,
#endif #endif
};
log_debug("Journal effective settings seal=%s compress=%s compress_threshold_bytes=%s", log_debug("Journal effective settings seal=%s compress=%s compress_threshold_bytes=%s",
yes_no(f->seal), yes_no(JOURNAL_FILE_COMPRESS(f)), yes_no(f->seal), yes_no(JOURNAL_FILE_COMPRESS(f)),