diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-06-05 18:44:16 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-06-10 10:10:07 -0400 |
commit | 507f22bd0172bff5e5d98145b1419bd472a2c57f (patch) | |
tree | b8873279314be8faed250aa8d8c76cb0f9434112 /src/journal | |
parent | b32ff512191bf873266ee8067f6f6c8a30c96a5e (diff) |
Use stdint.h macros instead of casts to print uint64_t values
Casts are visually heavy, and can obscure unwanted truncations.
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/journal-authenticate.c | 10 | ||||
-rw-r--r-- | src/journal/journal-file.c | 90 | ||||
-rw-r--r-- | src/journal/journal-gatewayd.c | 12 | ||||
-rw-r--r-- | src/journal/journal-qrcode.c | 6 | ||||
-rw-r--r-- | src/journal/journal-verify.c | 94 | ||||
-rw-r--r-- | src/journal/journald-kmsg.c | 3 | ||||
-rw-r--r-- | src/journal/sd-journal.c | 10 | ||||
-rw-r--r-- | src/journal/test-journal-verify.c | 4 |
8 files changed, 112 insertions, 117 deletions
diff --git a/src/journal/journal-authenticate.c b/src/journal/journal-authenticate.c index 64bf96874e..bd7100a8d5 100644 --- a/src/journal/journal-authenticate.c +++ b/src/journal/journal-authenticate.c @@ -60,9 +60,9 @@ int journal_file_append_tag(JournalFile *f) { o->tag.seqnum = htole64(journal_file_tag_seqnum(f)); o->tag.epoch = htole64(FSPRG_GetEpoch(f->fsprg_state)); - log_debug("Writing tag %llu for epoch %llu\n", - (unsigned long long) le64toh(o->tag.seqnum), - (unsigned long long) FSPRG_GetEpoch(f->fsprg_state)); + log_debug("Writing tag %"PRIu64" for epoch %"PRIu64"\n", + le64toh(o->tag.seqnum), + FSPRG_GetEpoch(f->fsprg_state)); /* Add the tag object itself, so that we can protect its * header. This will exclude the actual hash value in it */ @@ -152,7 +152,7 @@ int journal_file_fsprg_evolve(JournalFile *f, uint64_t realtime) { epoch = FSPRG_GetEpoch(f->fsprg_state); if (epoch < goal) - log_debug("Evolving FSPRG key from epoch %llu to %llu.", (unsigned long long) epoch, (unsigned long long) goal); + log_debug("Evolving FSPRG key from epoch %"PRIu64" to %"PRIu64".", epoch, goal); for (;;) { if (epoch > goal) @@ -195,7 +195,7 @@ int journal_file_fsprg_seek(JournalFile *f, uint64_t goal) { return -ENOMEM; } - log_debug("Seeking FSPRG key to %llu.", (unsigned long long) goal); + log_debug("Seeking FSPRG key to %"PRIu64".", goal); msk = alloca(FSPRG_mskinbytes(FSPRG_RECOMMENDED_SECPAR)); FSPRG_GenMK(msk, NULL, f->fsprg_seed, f->fsprg_seed_size, FSPRG_RECOMMENDED_SECPAR); diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 38499a6881..3cb8f79947 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -549,7 +549,7 @@ static int journal_file_setup_data_hash_table(JournalFile *f) { if (s < DEFAULT_DATA_HASH_TABLE_SIZE) s = DEFAULT_DATA_HASH_TABLE_SIZE; - log_debug("Reserving %llu entries in hash table.", (unsigned long long) (s / sizeof(HashItem))); + log_debug("Reserving %"PRIu64" entries in hash table.", s / sizeof(HashItem)); r = journal_file_append_object(f, OBJECT_DATA_HASH_TABLE, @@ -985,7 +985,7 @@ static int journal_file_append_data( o->object.size = htole64(offsetof(Object, data.payload) + rsize); o->object.flags |= OBJECT_COMPRESSED; - log_debug("Compressed data object %lu -> %lu", (unsigned long) size, (unsigned long) rsize); + log_debug("Compressed data object %"PRIu64" -> %"PRIu64, size, rsize); } } #endif @@ -1206,7 +1206,7 @@ static int journal_file_link_entry(JournalFile *f, Object *o, uint64_t offset) { if (r < 0) return r; - /* log_debug("=> %s seqnr=%lu n_entries=%lu", f->path, (unsigned long) o->entry.seqnum, (unsigned long) f->header->n_entries); */ + /* log_debug("=> %s seqnr=%"PRIu64" n_entries=%"PRIu64, f->path, o->entry.seqnum, f->header->n_entries); */ if (f->header->head_entry_realtime == 0) f->header->head_entry_realtime = o->entry.realtime; @@ -2227,10 +2227,10 @@ void journal_file_dump(JournalFile *f) { break; case OBJECT_ENTRY: - printf("Type: OBJECT_ENTRY seqnum=%llu monotonic=%llu realtime=%llu\n", - (unsigned long long) le64toh(o->entry.seqnum), - (unsigned long long) le64toh(o->entry.monotonic), - (unsigned long long) le64toh(o->entry.realtime)); + printf("Type: OBJECT_ENTRY seqnum=%"PRIu64" monotonic=%"PRIu64" realtime=%"PRIu64"\n", + le64toh(o->entry.seqnum), + le64toh(o->entry.monotonic), + le64toh(o->entry.realtime)); break; case OBJECT_FIELD_HASH_TABLE: @@ -2246,9 +2246,9 @@ void journal_file_dump(JournalFile *f) { break; case OBJECT_TAG: - printf("Type: OBJECT_TAG seqnum=%llu epoch=%llu\n", - (unsigned long long) le64toh(o->tag.seqnum), - (unsigned long long) le64toh(o->tag.epoch)); + printf("Type: OBJECT_TAG seqnum=%"PRIu64" epoch=%"PRIu64"\n", + le64toh(o->tag.seqnum), + le64toh(o->tag.epoch)); break; default: @@ -2286,17 +2286,17 @@ void journal_file_print_header(JournalFile *f) { "State: %s\n" "Compatible Flags:%s%s\n" "Incompatible Flags:%s%s\n" - "Header size: %llu\n" - "Arena size: %llu\n" - "Data Hash Table Size: %llu\n" - "Field Hash Table Size: %llu\n" + "Header size: %"PRIu64"\n" + "Arena size: %"PRIu64"\n" + "Data Hash Table Size: %"PRIu64"\n" + "Field Hash Table Size: %"PRIu64"\n" "Rotate Suggested: %s\n" - "Head Sequential Number: %llu\n" - "Tail Sequential Number: %llu\n" + "Head Sequential Number: %"PRIu64"\n" + "Tail Sequential Number: %"PRIu64"\n" "Head Realtime Timestamp: %s\n" "Tail Realtime Timestamp: %s\n" - "Objects: %llu\n" - "Entry Objects: %llu\n", + "Objects: %"PRIu64"\n" + "Entry Objects: %"PRIu64"\n", f->path, sd_id128_to_string(f->header->file_id, a), sd_id128_to_string(f->header->machine_id, b), @@ -2309,36 +2309,36 @@ void journal_file_print_header(JournalFile *f) { (le32toh(f->header->compatible_flags) & ~HEADER_COMPATIBLE_SEALED) ? " ???" : "", JOURNAL_HEADER_COMPRESSED(f->header) ? " COMPRESSED" : "", (le32toh(f->header->incompatible_flags) & ~HEADER_INCOMPATIBLE_COMPRESSED) ? " ???" : "", - (unsigned long long) le64toh(f->header->header_size), - (unsigned long long) le64toh(f->header->arena_size), - (unsigned long long) le64toh(f->header->data_hash_table_size) / sizeof(HashItem), - (unsigned long long) le64toh(f->header->field_hash_table_size) / sizeof(HashItem), + le64toh(f->header->header_size), + le64toh(f->header->arena_size), + le64toh(f->header->data_hash_table_size) / sizeof(HashItem), + le64toh(f->header->field_hash_table_size) / sizeof(HashItem), yes_no(journal_file_rotate_suggested(f, 0)), - (unsigned long long) le64toh(f->header->head_entry_seqnum), - (unsigned long long) le64toh(f->header->tail_entry_seqnum), + le64toh(f->header->head_entry_seqnum), + le64toh(f->header->tail_entry_seqnum), format_timestamp(x, sizeof(x), le64toh(f->header->head_entry_realtime)), format_timestamp(y, sizeof(y), le64toh(f->header->tail_entry_realtime)), - (unsigned long long) le64toh(f->header->n_objects), - (unsigned long long) le64toh(f->header->n_entries)); + le64toh(f->header->n_objects), + le64toh(f->header->n_entries)); if (JOURNAL_HEADER_CONTAINS(f->header, n_data)) - printf("Data Objects: %llu\n" + printf("Data Objects: %"PRIu64"\n" "Data Hash Table Fill: %.1f%%\n", - (unsigned long long) le64toh(f->header->n_data), + le64toh(f->header->n_data), 100.0 * (double) le64toh(f->header->n_data) / ((double) (le64toh(f->header->data_hash_table_size) / sizeof(HashItem)))); if (JOURNAL_HEADER_CONTAINS(f->header, n_fields)) - printf("Field Objects: %llu\n" + printf("Field Objects: %"PRIu64"\n" "Field Hash Table Fill: %.1f%%\n", - (unsigned long long) le64toh(f->header->n_fields), + le64toh(f->header->n_fields), 100.0 * (double) le64toh(f->header->n_fields) / ((double) (le64toh(f->header->field_hash_table_size) / sizeof(HashItem)))); if (JOURNAL_HEADER_CONTAINS(f->header, n_tags)) - printf("Tag Objects: %llu\n", - (unsigned long long) le64toh(f->header->n_tags)); + printf("Tag Objects: %"PRIu64"\n", + le64toh(f->header->n_tags)); if (JOURNAL_HEADER_CONTAINS(f->header, n_entry_arrays)) - printf("Entry Array Objects: %llu\n", - (unsigned long long) le64toh(f->header->n_entry_arrays)); + printf("Entry Array Objects: %"PRIu64"\n", + le64toh(f->header->n_entry_arrays)); if (fstat(f->fd, &st) >= 0) printf("Disk usage: %s\n", format_bytes(bytes, sizeof(bytes), (off_t) st.st_blocks * 512ULL)); @@ -2564,9 +2564,9 @@ int journal_file_rotate(JournalFile **f, bool compress, bool seal) { p[l-8] = '@'; sd_id128_to_string(old_file->header->seqnum_id, p + l - 8 + 1); snprintf(p + l - 8 + 1 + 32, 1 + 16 + 1 + 16 + 8 + 1, - "-%016llx-%016llx.journal", - (unsigned long long) le64toh((*f)->header->head_entry_seqnum), - (unsigned long long) le64toh((*f)->header->head_entry_realtime)); + "-%016"PRIx64"-%016"PRIx64".journal", + le64toh((*f)->header->head_entry_seqnum), + le64toh((*f)->header->head_entry_realtime)); r = rename(old_file->path, p); free(p); @@ -2873,23 +2873,23 @@ bool journal_file_rotate_suggested(JournalFile *f, usec_t max_file_usec) { if (JOURNAL_HEADER_CONTAINS(f->header, n_data)) if (le64toh(f->header->n_data) * 4ULL > (le64toh(f->header->data_hash_table_size) / sizeof(HashItem)) * 3ULL) { - log_debug("Data hash table of %s has a fill level at %.1f (%llu of %llu items, %llu file size, %llu bytes per hash table item), suggesting rotation.", + log_debug("Data hash table of %s has a fill level at %.1f (%"PRIu64" of %"PRIu64" items, %llu file size, %"PRIu64" bytes per hash table item), suggesting rotation.", f->path, 100.0 * (double) le64toh(f->header->n_data) / ((double) (le64toh(f->header->data_hash_table_size) / sizeof(HashItem))), - (unsigned long long) le64toh(f->header->n_data), - (unsigned long long) (le64toh(f->header->data_hash_table_size) / sizeof(HashItem)), - (unsigned long long) (f->last_stat.st_size), - (unsigned long long) (f->last_stat.st_size / le64toh(f->header->n_data))); + le64toh(f->header->n_data), + le64toh(f->header->data_hash_table_size) / sizeof(HashItem), + (unsigned long long) f->last_stat.st_size, + f->last_stat.st_size / le64toh(f->header->n_data)); return true; } if (JOURNAL_HEADER_CONTAINS(f->header, n_fields)) if (le64toh(f->header->n_fields) * 4ULL > (le64toh(f->header->field_hash_table_size) / sizeof(HashItem)) * 3ULL) { - log_debug("Field hash table of %s has a fill level at %.1f (%llu of %llu items), suggesting rotation.", + log_debug("Field hash table of %s has a fill level at %.1f (%"PRIu64" of %"PRIu64" items), suggesting rotation.", f->path, 100.0 * (double) le64toh(f->header->n_fields) / ((double) (le64toh(f->header->field_hash_table_size) / sizeof(HashItem))), - (unsigned long long) le64toh(f->header->n_fields), - (unsigned long long) (le64toh(f->header->field_hash_table_size) / sizeof(HashItem))); + le64toh(f->header->n_fields), + le64toh(f->header->field_hash_table_size) / sizeof(HashItem)); return true; } diff --git a/src/journal/journal-gatewayd.c b/src/journal/journal-gatewayd.c index 86338c66f3..10224a1ac1 100644 --- a/src/journal/journal-gatewayd.c +++ b/src/journal/journal-gatewayd.c @@ -834,17 +834,17 @@ static int request_handler_machine( "\"hostname\" : \"%s\"," "\"os_pretty_name\" : \"%s\"," "\"virtualization\" : \"%s\"," - "\"usage\" : \"%llu\"," - "\"cutoff_from_realtime\" : \"%llu\"," - "\"cutoff_to_realtime\" : \"%llu\" }\n", + "\"usage\" : \"%"PRIu64"\"," + "\"cutoff_from_realtime\" : \"%"PRIu64"\"," + "\"cutoff_to_realtime\" : \"%"PRIu64"\" }\n", SD_ID128_FORMAT_VAL(mid), SD_ID128_FORMAT_VAL(bid), hostname_cleanup(hostname, false), os_name ? os_name : "Linux", v ? v : "bare", - (unsigned long long) usage, - (unsigned long long) cutoff_from, - (unsigned long long) cutoff_to); + usage, + cutoff_from, + cutoff_to); if (r < 0) return respond_oom(connection); diff --git a/src/journal/journal-qrcode.c b/src/journal/journal-qrcode.c index 10a14e4def..1db66e89c6 100644 --- a/src/journal/journal-qrcode.c +++ b/src/journal/journal-qrcode.c @@ -76,9 +76,9 @@ int print_qr_code( fprintf(f, "%02x", ((uint8_t*) seed)[i]); } - fprintf(f, "/%llx-%llx?machine=" SD_ID128_FORMAT_STR, - (unsigned long long) start, - (unsigned long long) interval, + fprintf(f, "/%"PRIx64"-%"PRIx64"?machine=" SD_ID128_FORMAT_STR, + start, + interval, SD_ID128_FORMAT_VAL(machine)); if (hn) diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c index ed28b45737..01c89bc8a4 100644 --- a/src/journal/journal-verify.c +++ b/src/journal/journal-verify.c @@ -203,7 +203,7 @@ static void draw_progress(uint64_t p, usec_t *last_usec) { for (i = 0; i < k; i++) fputs("\xe2\x96\x91", stdout); - printf(" %3lu%%", 100LU * (unsigned long) p / 65535LU); + printf(" %3"PRIu64"%%", 100U * p / 65535U); fputs("\r\x1B[?25h", stdout); fflush(stdout); @@ -288,7 +288,7 @@ static int entry_points_to_data( assert(entry_fd >= 0); if (!contains_uint64(f->mmap, entry_fd, n_entries, entry_p)) { - log_error("Data object references invalid entry at %llu", (unsigned long long) data_p); + log_error("Data object references invalid entry at %"PRIu64, data_p); return -EBADMSG; } @@ -304,7 +304,7 @@ static int entry_points_to_data( } if (!found) { - log_error("Data object not referenced by linked entry at %llu", (unsigned long long) data_p); + log_error("Data object not referenced by linked entry at %"PRIu64, data_p); return -EBADMSG; } @@ -347,7 +347,7 @@ static int entry_points_to_data( x = z; } - log_error("Entry object doesn't exist in main entry array at %llu", (unsigned long long) entry_p); + log_error("Entry object doesn't exist in main entry array at %"PRIu64, entry_p); return -EBADMSG; } @@ -388,12 +388,12 @@ static int verify_data( uint64_t next, m, j; if (a == 0) { - log_error("Array chain too short at %llu", (unsigned long long) p); + log_error("Array chain too short at %"PRIu64, p); return -EBADMSG; } if (!contains_uint64(f->mmap, entry_array_fd, n_entry_arrays, a)) { - log_error("Invalid array at %llu", (unsigned long long) p); + log_error("Invalid array at %"PRIu64, p); return -EBADMSG; } @@ -403,7 +403,7 @@ static int verify_data( next = le64toh(o->entry_array.next_entry_array_offset); if (next != 0 && next <= a) { - log_error("Array chain has cycle at %llu", (unsigned long long) p); + log_error("Array chain has cycle at %"PRIu64, p); return -EBADMSG; } @@ -412,7 +412,7 @@ static int verify_data( q = le64toh(o->entry_array.items[j]); if (q <= last) { - log_error("Data object's entry array not sorted at %llu", (unsigned long long) p); + log_error("Data object's entry array not sorted at %"PRIu64, p); return -EBADMSG; } last = q; @@ -463,8 +463,8 @@ static int verify_hash_table( uint64_t next; if (!contains_uint64(f->mmap, data_fd, n_data, p)) { - log_error("Invalid data object at hash entry %llu of %llu", - (unsigned long long) i, (unsigned long long) n); + log_error("Invalid data object at hash entry %"PRIu64" of %"PRIu64, + i, n); return -EBADMSG; } @@ -474,14 +474,14 @@ static int verify_hash_table( next = le64toh(o->data.next_hash_offset); if (next != 0 && next <= p) { - log_error("Hash chain has a cycle in hash entry %llu of %llu", - (unsigned long long) i, (unsigned long long) n); + log_error("Hash chain has a cycle in hash entry %"PRIu64" of %"PRIu64, + i, n); return -EBADMSG; } if (le64toh(o->data.hash) % n != i) { - log_error("Hash value mismatch in hash entry %llu of %llu", - (unsigned long long) i, (unsigned long long) n); + log_error("Hash value mismatch in hash entry %"PRIu64" of %"PRIu64, + i, n); return -EBADMSG; } @@ -548,8 +548,7 @@ static int verify_entry( h = le64toh(o->entry.items[i].hash); if (!contains_uint64(f->mmap, data_fd, n_data, q)) { - log_error("Invalid data object at entry %llu", - (unsigned long long) p); + log_error("Invalid data object at entry %"PRIu64, p); return -EBADMSG; } @@ -558,8 +557,7 @@ static int verify_entry( return r; if (le64toh(u->data.hash) != h) { - log_error("Hash mismatch for data object at entry %llu", - (unsigned long long) p); + log_error("Hash mismatch for data object at entry %"PRIu64, p); return -EBADMSG; } @@ -567,8 +565,7 @@ static int verify_entry( if (r < 0) return r; if (r == 0) { - log_error("Data object missing from hash at entry %llu", - (unsigned long long) p); + log_error("Data object missing from hash at entry %"PRIu64, p); return -EBADMSG; } } @@ -603,14 +600,12 @@ static int verify_entry_array( draw_progress(0x8000 + (0x3FFF * i / n), last_usec); if (a == 0) { - log_error("Array chain too short at %llu of %llu", - (unsigned long long) i, (unsigned long long) n); + log_error("Array chain too short at %"PRIu64" of %"PRIu64, i, n); return -EBADMSG; } if (!contains_uint64(f->mmap, entry_array_fd, n_entry_arrays, a)) { - log_error("Invalid array at %llu of %llu", - (unsigned long long) i, (unsigned long long) n); + log_error("Invalid array at %"PRIu64" of %"PRIu64, i, n); return -EBADMSG; } @@ -620,8 +615,7 @@ static int verify_entry_array( next = le64toh(o->entry_array.next_entry_array_offset); if (next != 0 && next <= a) { - log_error("Array chain has cycle at %llu of %llu", - (unsigned long long) i, (unsigned long long) n); + log_error("Array chain has cycle at %"PRIu64" of %"PRIu64, i, n); return -EBADMSG; } @@ -631,15 +625,15 @@ static int verify_entry_array( p = le64toh(o->entry_array.items[j]); if (p <= last) { - log_error("Entry array not sorted at %llu of %llu", - (unsigned long long) i, (unsigned long long) n); + log_error("Entry array not sorted at %"PRIu64" of %"PRIu64, + i, n); return -EBADMSG; } last = p; if (!contains_uint64(f->mmap, entry_fd, n_entries, p)) { - log_error("Invalid array entry at %llu of %llu", - (unsigned long long) i, (unsigned long long) n); + log_error("Invalid array entry at %"PRIu64" of %"PRIu64, + i, n); return -EBADMSG; } @@ -753,7 +747,7 @@ int journal_file_verify( r = journal_file_move_to_object(f, -1, p, &o); if (r < 0) { - log_error("Invalid object at %llu", (unsigned long long) p); + log_error("Invalid object at %"PRIu64, p); goto fail; } @@ -770,12 +764,12 @@ int journal_file_verify( r = journal_file_object_verify(f, o); if (r < 0) { - log_error("Invalid object contents at %llu", (unsigned long long) p); + log_error("Invalid object contents at %"PRIu64, p); goto fail; } if ((o->object.flags & OBJECT_COMPRESSED) && !JOURNAL_HEADER_COMPRESSED(f->header)) { - log_error("Compressed object in file without compression at %llu", (unsigned long long) p); + log_error("Compressed object in file without compression at %"PRIu64, p); r = -EBADMSG; goto fail; } @@ -796,7 +790,7 @@ int journal_file_verify( case OBJECT_ENTRY: if (JOURNAL_HEADER_SEALED(f->header) && n_tags <= 0) { - log_error("First entry before first tag at %llu", (unsigned long long) p); + log_error("First entry before first tag at %"PRIu64, p); r = -EBADMSG; goto fail; } @@ -806,21 +800,21 @@ int journal_file_verify( goto fail; if (le64toh(o->entry.realtime) < last_tag_realtime) { - log_error("Older entry after newer tag at %llu", (unsigned long long) p); + log_error("Older entry after newer tag at %"PRIu64, p); r = -EBADMSG; goto fail; } if (!entry_seqnum_set && le64toh(o->entry.seqnum) != le64toh(f->header->head_entry_seqnum)) { - log_error("Head entry sequence number incorrect at %llu", (unsigned long long) p); + log_error("Head entry sequence number incorrect at %"PRIu64, p); r = -EBADMSG; goto fail; } if (entry_seqnum_set && entry_seqnum >= le64toh(o->entry.seqnum)) { - log_error("Entry sequence number out of synchronization at %llu", (unsigned long long) p); + log_error("Entry sequence number out of synchronization at %"PRIu64, p); r = -EBADMSG; goto fail; } @@ -831,7 +825,7 @@ int journal_file_verify( if (entry_monotonic_set && sd_id128_equal(entry_boot_id, o->entry.boot_id) && entry_monotonic > le64toh(o->entry.monotonic)) { - log_error("Entry timestamp out of synchronization at %llu", (unsigned long long) p); + log_error("Entry timestamp out of synchronization at %"PRIu64, p); r = -EBADMSG; goto fail; } @@ -855,7 +849,7 @@ int journal_file_verify( case OBJECT_DATA_HASH_TABLE: if (n_data_hash_tables > 1) { - log_error("More than one data hash table at %llu", (unsigned long long) p); + log_error("More than one data hash table at %"PRIu64, p); r = -EBADMSG; goto fail; } @@ -872,7 +866,7 @@ int journal_file_verify( case OBJECT_FIELD_HASH_TABLE: if (n_field_hash_tables > 1) { - log_error("More than one field hash table at %llu", (unsigned long long) p); + log_error("More than one field hash table at %"PRIu64, p); r = -EBADMSG; goto fail; } @@ -894,7 +888,7 @@ int journal_file_verify( if (p == le64toh(f->header->entry_array_offset)) { if (found_main_entry_array) { - log_error("More than one main entry array at %llu", (unsigned long long) p); + log_error("More than one main entry array at %"PRIu64, p); r = -EBADMSG; goto fail; } @@ -907,19 +901,19 @@ int journal_file_verify( case OBJECT_TAG: if (!JOURNAL_HEADER_SEALED(f->header)) { - log_error("Tag object in file without sealing at %llu", (unsigned long long) p); + log_error("Tag object in file without sealing at %"PRIu64, p); r = -EBADMSG; goto fail; } if (le64toh(o->tag.seqnum) != n_tags + 1) { - log_error("Tag sequence number out of synchronization at %llu", (unsigned long long) p); + log_error("Tag sequence number out of synchronization at %"PRIu64, p); r = -EBADMSG; goto fail; } if (le64toh(o->tag.epoch) < last_epoch) { - log_error("Epoch sequence out of synchronization at %llu", (unsigned long long) p); + log_error("Epoch sequence out of synchronization at %"PRIu64, p); r = -EBADMSG; goto fail; } @@ -928,11 +922,11 @@ int journal_file_verify( if (f->seal) { uint64_t q, rt; - log_debug("Checking tag %llu..", (unsigned long long) le64toh(o->tag.seqnum)); + log_debug("Checking tag %"PRIu64"...", le64toh(o->tag.seqnum)); rt = f->fss_start_usec + o->tag.epoch * f->fss_interval_usec; if (entry_realtime_set && entry_realtime >= rt + f->fss_interval_usec) { - log_error("Tag/entry realtime timestamp out of synchronization at %llu", (unsigned long long) p); + log_error("Tag/entry realtime timestamp out of synchronization at %"PRIu64, p); r = -EBADMSG; goto fail; } @@ -975,7 +969,7 @@ int journal_file_verify( goto fail; if (memcmp(o->tag.tag, gcry_md_read(f->hmac, 0), TAG_LENGTH) != 0) { - log_error("Tag failed verification at %llu", (unsigned long long) p); + log_error("Tag failed verification at %"PRIu64, p); r = -EBADMSG; goto fail; } @@ -1138,11 +1132,11 @@ fail: if (show_progress) flush_progress(); - log_error("File corruption detected at %s:%llu (of %llu, %llu%%).", + log_error("File corruption detected at %s:%"PRIu64" (of %llu bytes, %"PRIu64"%%).", f->path, - (unsigned long long) p, + p, (unsigned long long) f->last_stat.st_size, - (unsigned long long) (100 * p / f->last_stat.st_size)); + 100 * p / f->last_stat.st_size); if (data_fd >= 0) { mmap_cache_close_fd(f->mmap, data_fd); diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index 2f536320f8..5fd87b8154 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -151,7 +151,8 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) { /* Did we lose any? */ if (serial > *s->kernel_seqnum) - server_driver_message(s, SD_MESSAGE_JOURNAL_MISSED, "Missed %llu kernel messages", (unsigned long long) serial - *s->kernel_seqnum - 1); + server_driver_message(s, SD_MESSAGE_JOURNAL_MISSED, "Missed %"PRIu64" kernel messages", + serial - *s->kernel_seqnum - 1); /* Make sure we never read this one again. Note that * we always store the next message serial we expect diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 8b9a589cd3..8986763e4d 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -979,11 +979,11 @@ _public_ int sd_journal_get_cursor(sd_journal *j, char **cursor) { sd_id128_to_string(o->entry.boot_id, bid); if (asprintf(cursor, - "s=%s;i=%llx;b=%s;m=%llx;t=%llx;x=%llx", - sid, (unsigned long long) le64toh(o->entry.seqnum), - bid, (unsigned long long) le64toh(o->entry.monotonic), - (unsigned long long) le64toh(o->entry.realtime), - (unsigned long long) le64toh(o->entry.xor_hash)) < 0) + "s=%s;i=%"PRIx64";b=%s;m=%"PRIx64";t=%"PRIx64";x=%"PRIx64, + sid, le64toh(o->entry.seqnum), + bid, le64toh(o->entry.monotonic), + le64toh(o->entry.realtime), + le64toh(o->entry.xor_hash)) < 0) return -ENOMEM; return 0; diff --git a/src/journal/test-journal-verify.c b/src/journal/test-journal-verify.c index ad2e2d4c3b..6b7414a4b1 100644 --- a/src/journal/test-journal-verify.c +++ b/src/journal/test-journal-verify.c @@ -130,10 +130,10 @@ int main(int argc, char *argv[]) { for (p = 38448*8+0; p < ((uint64_t) st.st_size * 8); p ++) { bit_toggle("test.journal", p); - log_info("[ %llu+%llu]", (unsigned long long) p / 8, (unsigned long long) p % 8); + log_info("[ %"PRIu64"+%"PRIu64"]", p / 8, p % 8); if (raw_verify("test.journal", verification_key) >= 0) - log_notice(ANSI_HIGHLIGHT_RED_ON ">>>> %llu (bit %llu) can be toggled without detection." ANSI_HIGHLIGHT_OFF, (unsigned long long) p / 8, (unsigned long long) p % 8); + log_notice(ANSI_HIGHLIGHT_RED_ON ">>>> %"PRIu64" (bit %"PRIu64") can be toggled without detection." ANSI_HIGHLIGHT_OFF, p / 8, p % 8); bit_toggle("test.journal", p); } |