chiark / gitweb /
Use stdint.h macros instead of casts to print uint64_t values
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 5 Jun 2013 22:44:16 +0000 (18:44 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 10 Jun 2013 14:10:07 +0000 (10:10 -0400)
Casts are visually heavy, and can obscure unwanted truncations.

src/core/execute.c
src/journal/journal-authenticate.c
src/journal/journal-file.c
src/journal/journal-gatewayd.c
src/journal/journal-qrcode.c
src/journal/journal-verify.c
src/journal/journald-kmsg.c
src/journal/sd-journal.c
src/journal/test-journal-verify.c
src/libudev/libudev-hwdb.c
src/login/logind-session.c

index 3959ef96232580e6aaf63d41bae98e3c78e43d4f..9148d06df4697ea0fba78cc608d7d4e8dc8ba304 100644 (file)
@@ -1837,7 +1837,7 @@ static void strv_fprintf(FILE *f, char **l) {
 }
 
 void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
 }
 
 void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
-        char ** e;
+        char **e;
         unsigned i;
 
         assert(c);
         unsigned i;
 
         assert(c);
index 64bf96874e6490485f58a65b146d60e3f4e86425..bd7100a8d5c86aeaebaf3a52c3373d70743679b2 100644 (file)
@@ -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));
 
         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 */
 
         /* 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)
 
         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)
 
         for (;;) {
                 if (epoch > goal)
@@ -195,7 +195,7 @@ int journal_file_fsprg_seek(JournalFile *f, uint64_t goal) {
                         return -ENOMEM;
         }
 
                         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);
 
         msk = alloca(FSPRG_mskinbytes(FSPRG_RECOMMENDED_SECPAR));
         FSPRG_GenMK(msk, NULL, f->fsprg_seed, f->fsprg_seed_size, FSPRG_RECOMMENDED_SECPAR);
index 38499a68812f0b740230e60c8997bcefa6166954..3cb8f79947489948c083b6563072818bdf259385 100644 (file)
@@ -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;
 
         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,
 
         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;
 
                         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
                 }
         }
 #endif
@@ -1206,7 +1206,7 @@ static int journal_file_link_entry(JournalFile *f, Object *o, uint64_t offset) {
         if (r < 0)
                 return r;
 
         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;
 
         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:
                         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:
                         break;
 
                 case OBJECT_FIELD_HASH_TABLE:
@@ -2246,9 +2246,9 @@ void journal_file_dump(JournalFile *f) {
                         break;
 
                 case OBJECT_TAG:
                         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:
                         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"
                "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"
                "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"
                "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),
                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) ? " ???" : "",
                (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)),
                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)),
                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))
 
         if (JOURNAL_HEADER_CONTAINS(f->header, n_data))
-                printf("Data Objects: %llu\n"
+                printf("Data Objects: %"PRIu64"\n"
                        "Data Hash Table Fill: %.1f%%\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))
                        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",
                        "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))
                        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))
         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));
 
         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,
         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);
 
         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) {
 
         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))),
                                   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) {
                         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))),
                                   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;
                 }
 
                         return true;
                 }
 
index 86338c66f33e1493062f82aefb3c2981d4b5391d..10224a1ac12dbe405e9d27ff44e37dd589acf203 100644 (file)
@@ -834,17 +834,17 @@ static int request_handler_machine(
                      "\"hostname\" : \"%s\","
                      "\"os_pretty_name\" : \"%s\","
                      "\"virtualization\" : \"%s\","
                      "\"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",
                      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);
 
         if (r < 0)
                 return respond_oom(connection);
index 10a14e4deff10bfde14ad30003dff3b9e2a4e7b1..1db66e89c64397c8c36c9f5f0f8ca683e7399370 100644 (file)
@@ -76,9 +76,9 @@ int print_qr_code(
                 fprintf(f, "%02x", ((uint8_t*) seed)[i]);
         }
 
                 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)
                 SD_ID128_FORMAT_VAL(machine));
 
         if (hn)
index ed28b457372813e689a09ad0cc9ed4244d6420c3..01c89bc8a427f07a5969ab1b6fd3627de2b446d2 100644 (file)
@@ -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);
 
         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);
 
         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)) {
         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;
         }
 
                 return -EBADMSG;
         }
 
@@ -304,7 +304,7 @@ static int entry_points_to_data(
                 }
 
         if (!found) {
                 }
 
         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;
         }
 
                 return -EBADMSG;
         }
 
@@ -347,7 +347,7 @@ static int entry_points_to_data(
                                         x = z;
                         }
 
                                         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;
                 }
 
                         return -EBADMSG;
                 }
 
@@ -388,12 +388,12 @@ static int verify_data(
                 uint64_t next, m, j;
 
                 if (a == 0) {
                 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)) {
                         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;
                 }
 
                         return -EBADMSG;
                 }
 
@@ -403,7 +403,7 @@ static int verify_data(
 
                 next = le64toh(o->entry_array.next_entry_array_offset);
                 if (next != 0 && next <= a) {
 
                 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;
                 }
 
                         return -EBADMSG;
                 }
 
@@ -412,7 +412,7 @@ static int verify_data(
 
                         q = le64toh(o->entry_array.items[j]);
                         if (q <= last) {
 
                         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;
                                 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)) {
                         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;
                         }
 
                                 return -EBADMSG;
                         }
 
@@ -474,14 +474,14 @@ static int verify_hash_table(
 
                         next = le64toh(o->data.next_hash_offset);
                         if (next != 0 && next <= p) {
 
                         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) {
                                 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;
                         }
 
                                 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)) {
                 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;
                         }
 
                                 return -EBADMSG;
                         }
 
@@ -558,8 +557,7 @@ static int verify_entry(
                         return r;
 
                 if (le64toh(u->data.hash) != h) {
                         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;
                 }
 
                         return -EBADMSG;
                 }
 
@@ -567,8 +565,7 @@ static int verify_entry(
                 if (r < 0)
                         return r;
                 if (r == 0) {
                 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;
                 }
         }
                         return -EBADMSG;
                 }
         }
@@ -603,14 +600,12 @@ static int verify_entry_array(
                         draw_progress(0x8000 + (0x3FFF * i / n), last_usec);
 
                 if (a == 0) {
                         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)) {
                         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;
                 }
 
                         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) {
 
                 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;
                 }
 
                         return -EBADMSG;
                 }
 
@@ -631,15 +625,15 @@ static int verify_entry_array(
 
                         p = le64toh(o->entry_array.items[j]);
                         if (p <= last) {
 
                         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)) {
                                 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;
                         }
 
                                 return -EBADMSG;
                         }
 
@@ -753,7 +747,7 @@ int journal_file_verify(
 
                 r = journal_file_move_to_object(f, -1, p, &o);
                 if (r < 0) {
 
                 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;
                 }
 
                         goto fail;
                 }
 
@@ -770,12 +764,12 @@ int journal_file_verify(
 
                 r = journal_file_object_verify(f, o);
                 if (r < 0) {
 
                 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)) {
                         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;
                 }
                         r = -EBADMSG;
                         goto fail;
                 }
@@ -796,7 +790,7 @@ int journal_file_verify(
 
                 case OBJECT_ENTRY:
                         if (JOURNAL_HEADER_SEALED(f->header) && n_tags <= 0) {
 
                 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;
                         }
                                 r = -EBADMSG;
                                 goto fail;
                         }
@@ -806,21 +800,21 @@ int journal_file_verify(
                                 goto fail;
 
                         if (le64toh(o->entry.realtime) < last_tag_realtime) {
                                 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)) {
                                 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)) {
                                 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;
                         }
                                 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)) {
                         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;
                         }
                                 r = -EBADMSG;
                                 goto fail;
                         }
@@ -855,7 +849,7 @@ int journal_file_verify(
 
                 case OBJECT_DATA_HASH_TABLE:
                         if (n_data_hash_tables > 1) {
 
                 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;
                         }
                                 r = -EBADMSG;
                                 goto fail;
                         }
@@ -872,7 +866,7 @@ int journal_file_verify(
 
                 case OBJECT_FIELD_HASH_TABLE:
                         if (n_field_hash_tables > 1) {
 
                 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;
                         }
                                 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) {
 
                         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;
                                 }
                                         r = -EBADMSG;
                                         goto fail;
                                 }
@@ -907,19 +901,19 @@ int journal_file_verify(
 
                 case OBJECT_TAG:
                         if (!JOURNAL_HEADER_SEALED(f->header)) {
 
                 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) {
                                 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) {
                                 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;
                         }
                                 r = -EBADMSG;
                                 goto fail;
                         }
@@ -928,11 +922,11 @@ int journal_file_verify(
                         if (f->seal) {
                                 uint64_t q, rt;
 
                         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) {
 
                                 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;
                                 }
                                         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) {
                                         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;
                                 }
                                         r = -EBADMSG;
                                         goto fail;
                                 }
@@ -1138,11 +1132,11 @@ fail:
         if (show_progress)
                 flush_progress();
 
         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,
                   f->path,
-                  (unsigned long long) p,
+                  p,
                   (unsigned long long) f->last_stat.st_size,
                   (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);
 
         if (data_fd >= 0) {
                 mmap_cache_close_fd(f->mmap, data_fd);
index 2f536320f8d90d41a8eff6740a55da8051ed83a7..5fd87b815439ba029812a120334f08c0ee665923 100644 (file)
@@ -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)
 
                 /* 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
 
                 /* Make sure we never read this one again. Note that
                  * we always store the next message serial we expect
index 8b9a589cd36425d4e45f438c9e8e55035af9f10e..8986763e4d4fde8da3dc57df55c489698c977ba6 100644 (file)
@@ -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,
         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;
                 return -ENOMEM;
 
         return 0;
index ad2e2d4c3b2e8d107727cdd33df9e93544fde00c..6b7414a4b1bff8ba0a10e6f580492a1010a694bb 100644 (file)
@@ -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);
 
                 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)
 
                         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);
                 }
 
                         bit_toggle("test.journal", p);
                 }
index 42ab6d9a6b356748d21d3ecfd433a71966ed6450..a56ad753e45479f673f9c4a01b799362bc306edb 100644 (file)
@@ -300,11 +300,11 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
         }
 
         log_debug("=== trie on-disk ===\n");
         }
 
         log_debug("=== trie on-disk ===\n");
-        log_debug("tool version:          %llu", (unsigned long long)le64toh(hwdb->head->tool_version));
-        log_debug("file size:        %8llu bytes\n", (unsigned long long)hwdb->st.st_size);
-        log_debug("header size       %8llu bytes\n", (unsigned long long)le64toh(hwdb->head->header_size));
-        log_debug("strings           %8llu bytes\n", (unsigned long long)le64toh(hwdb->head->strings_len));
-        log_debug("nodes             %8llu bytes\n", (unsigned long long)le64toh(hwdb->head->nodes_len));
+        log_debug("tool version:          %"PRIu64, le64toh(hwdb->head->tool_version));
+        log_debug("file size:        %8llu bytes\n", (unsigned long long) hwdb->st.st_size);
+        log_debug("header size       %8"PRIu64" bytes\n", le64toh(hwdb->head->header_size));
+        log_debug("strings           %8"PRIu64" bytes\n", le64toh(hwdb->head->strings_len));
+        log_debug("nodes             %8"PRIu64" bytes\n", le64toh(hwdb->head->nodes_len));
         return hwdb;
 }
 
         return hwdb;
 }
 
index 662273b07f6a22d69dbdd1fdb5dd4dbeb7fae4a3..4fd3985811aa49645f9935995607ac33e167daaa 100644 (file)
@@ -108,9 +108,9 @@ void session_free(Session *s) {
 }
 
 int session_save(Session *s) {
 }
 
 int session_save(Session *s) {
-        FILE *f;
+        _cleanup_fclose_ FILE *f = NULL;
+        _cleanup_free_ char *temp_path = NULL;
         int r = 0;
         int r = 0;
-        char *temp_path;
 
         assert(s);
 
 
         assert(s);
 
@@ -145,69 +145,43 @@ int session_save(Session *s) {
                 s->kill_processes);
 
         if (s->type >= 0)
                 s->kill_processes);
 
         if (s->type >= 0)
-                fprintf(f,
-                        "TYPE=%s\n",
-                        session_type_to_string(s->type));
+                fprintf(f, "TYPE=%s\n", session_type_to_string(s->type));
 
         if (s->class >= 0)
 
         if (s->class >= 0)
-                fprintf(f,
-                        "CLASS=%s\n",
-                        session_class_to_string(s->class));
+                fprintf(f, "CLASS=%s\n", session_class_to_string(s->class));
 
         if (s->cgroup_path)
 
         if (s->cgroup_path)
-                fprintf(f,
-                        "CGROUP=%s\n",
-                        s->cgroup_path);
+                fprintf(f, "CGROUP=%s\n", s->cgroup_path);
 
         if (s->fifo_path)
 
         if (s->fifo_path)
-                fprintf(f,
-                        "FIFO=%s\n",
-                        s->fifo_path);
+                fprintf(f, "FIFO=%s\n", s->fifo_path);
 
         if (s->seat)
 
         if (s->seat)
-                fprintf(f,
-                        "SEAT=%s\n",
-                        s->seat->id);
+                fprintf(f, "SEAT=%s\n", s->seat->id);
 
         if (s->tty)
 
         if (s->tty)
-                fprintf(f,
-                        "TTY=%s\n",
-                        s->tty);
+                fprintf(f, "TTY=%s\n", s->tty);
 
         if (s->display)
 
         if (s->display)
-                fprintf(f,
-                        "DISPLAY=%s\n",
-                        s->display);
+                fprintf(f, "DISPLAY=%s\n", s->display);
 
         if (s->remote_host)
 
         if (s->remote_host)
-                fprintf(f,
-                        "REMOTE_HOST=%s\n",
-                        s->remote_host);
+                fprintf(f, "REMOTE_HOST=%s\n", s->remote_host);
 
         if (s->remote_user)
 
         if (s->remote_user)
-                fprintf(f,
-                        "REMOTE_USER=%s\n",
-                        s->remote_user);
+                fprintf(f, "REMOTE_USER=%s\n", s->remote_user);
 
         if (s->service)
 
         if (s->service)
-                fprintf(f,
-                        "SERVICE=%s\n",
-                        s->service);
+                fprintf(f, "SERVICE=%s\n", s->service);
 
         if (s->seat && seat_can_multi_session(s->seat))
 
         if (s->seat && seat_can_multi_session(s->seat))
-                fprintf(f,
-                        "VTNR=%i\n",
-                        s->vtnr);
+                fprintf(f, "VTNR=%i\n", s->vtnr);
 
         if (s->leader > 0)
 
         if (s->leader > 0)
-                fprintf(f,
-                        "LEADER=%lu\n",
-                        (unsigned long) s->leader);
+                fprintf(f, "LEADER=%lu\n", (unsigned long) s->leader);
 
         if (s->audit_id > 0)
 
         if (s->audit_id > 0)
-                fprintf(f,
-                        "AUDIT=%llu\n",
-                        (unsigned long long) s->audit_id);
+                fprintf(f, "AUDIT=%"PRIu32"\n", s->audit_id);
 
         fflush(f);
 
 
         fflush(f);
 
@@ -217,9 +191,6 @@ int session_save(Session *s) {
                 unlink(temp_path);
         }
 
                 unlink(temp_path);
         }
 
-        fclose(f);
-        free(temp_path);
-
 finish:
         if (r < 0)
                 log_error("Failed to save session data for %s: %s", s->id, strerror(-r));
 finish:
         if (r < 0)
                 log_error("Failed to save session data for %s: %s", s->id, strerror(-r));