Merge pull request #14297 from poettering/id128-size

cleaning up id128 formatting buffer sizing
This commit is contained in:
Yu Watanabe 2019-12-11 13:26:51 +09:00 committed by GitHub
commit 8fb3bda83c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 16 additions and 13 deletions

View file

@ -103,7 +103,7 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
_fallthrough_;
case ENTRY_BOOT_ID: {
sd_id128_t boot_id;
char sid[33];
char sid[SD_ID128_STRING_MAX];
r = sd_journal_get_monotonic_usec(u->journal, NULL, &boot_id);
if (r < 0)

View file

@ -3056,7 +3056,7 @@ static const char* format_timestamp_safe(char *buf, size_t l, usec_t t) {
}
void journal_file_print_header(JournalFile *f) {
char a[33], b[33], c[33], d[33];
char a[SD_ID128_STRING_MAX], b[SD_ID128_STRING_MAX], c[SD_ID128_STRING_MAX], d[SD_ID128_STRING_MAX];
char x[FORMAT_TIMESTAMP_MAX], y[FORMAT_TIMESTAMP_MAX], z[FORMAT_TIMESTAMP_MAX];
struct stat st;
char bytes[FORMAT_BYTES_MAX];

View file

@ -908,7 +908,7 @@ _public_ int sd_journal_previous_skip(sd_journal *j, uint64_t skip) {
_public_ int sd_journal_get_cursor(sd_journal *j, char **cursor) {
Object *o;
int r;
char bid[33], sid[33];
char bid[SD_ID128_STRING_MAX], sid[SD_ID128_STRING_MAX];
assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD);

View file

@ -2672,7 +2672,7 @@ static int process_builtin(sd_bus *bus, sd_bus_message *m) {
r = sd_bus_message_new_method_return(m, &reply);
else if (streq_ptr(m->member, "GetMachineId")) {
sd_id128_t id;
char sid[33];
char sid[SD_ID128_STRING_MAX];
r = sd_id128_get_machine(&id);
if (r < 0)

View file

@ -11,7 +11,7 @@
#include "io-util.h"
#include "stdio-util.h"
char *id128_to_uuid_string(sd_id128_t id, char s[37]) {
char *id128_to_uuid_string(sd_id128_t id, char s[static ID128_UUID_STRING_MAX]) {
unsigned n, k = 0;
assert(s);

View file

@ -8,7 +8,9 @@
#include "hash-funcs.h"
#include "macro.h"
char *id128_to_uuid_string(sd_id128_t id, char s[37]);
#define ID128_UUID_STRING_MAX 37
char *id128_to_uuid_string(sd_id128_t id, char s[static ID128_UUID_STRING_MAX]);
bool id128_is_valid(const char *s) _pure_;

View file

@ -2229,9 +2229,9 @@ static int setup_hostname(void) {
static int setup_journal(const char *directory) {
_cleanup_free_ char *d = NULL;
char id[SD_ID128_STRING_MAX];
const char *dirname, *p, *q;
sd_id128_t this_id;
char id[33];
bool try;
int r;
@ -2866,7 +2866,7 @@ static int inner_child(
FDSet *fds) {
_cleanup_free_ char *home = NULL;
char as_uuid[37];
char as_uuid[ID128_UUID_STRING_MAX];
size_t n_env = 1;
const char *envp[] = {
"PATH=" DEFAULT_PATH_COMPAT,

View file

@ -17,6 +17,7 @@
#include "format-util.h"
#include "hashmap.h"
#include "hostname-util.h"
#include "id128-util.h"
#include "io-util.h"
#include "journal-internal.h"
#include "json.h"
@ -26,8 +27,8 @@
#include "namespace-util.h"
#include "output-mode.h"
#include "parse-util.h"
#include "process-util.h"
#include "pretty-print.h"
#include "process-util.h"
#include "sparse-endian.h"
#include "stdio-util.h"
#include "string-table.h"
@ -654,7 +655,7 @@ static int output_export(
const size_t highlight[2]) {
sd_id128_t boot_id;
char sid[33];
char sid[SD_ID128_STRING_MAX];
int r;
usec_t realtime, monotonic;
_cleanup_free_ char *cursor = NULL;
@ -1353,8 +1354,8 @@ int add_matches_for_user_unit(sd_journal *j, const char *unit, uid_t uid) {
static int get_boot_id_for_machine(const char *machine, sd_id128_t *boot_id) {
_cleanup_close_pair_ int pair[2] = { -1, -1 };
_cleanup_close_ int pidnsfd = -1, mntnsfd = -1, rootfd = -1;
char buf[ID128_UUID_STRING_MAX];
pid_t pid, child;
char buf[37];
ssize_t k;
int r;

View file

@ -21,7 +21,7 @@
int main(int argc, char *argv[]) {
sd_id128_t id, id2;
char t[33], q[37];
char t[SD_ID128_STRING_MAX], q[ID128_UUID_STRING_MAX];
_cleanup_free_ char *b = NULL;
_cleanup_close_ int fd = -1;
int r;

View file

@ -166,7 +166,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
static int determine_devices(void) {
_cleanup_free_ void *m = NULL;
sd_id128_t root_uuid, verity_uuid;
char ids[37];
char ids[ID128_UUID_STRING_MAX];
size_t l;
int r;