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
10 changed files with 16 additions and 13 deletions
+1 -1
View File
@@ -103,7 +103,7 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
_fallthrough_; _fallthrough_;
case ENTRY_BOOT_ID: { case ENTRY_BOOT_ID: {
sd_id128_t 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); r = sd_journal_get_monotonic_usec(u->journal, NULL, &boot_id);
if (r < 0) if (r < 0)
+1 -1
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) { 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]; char x[FORMAT_TIMESTAMP_MAX], y[FORMAT_TIMESTAMP_MAX], z[FORMAT_TIMESTAMP_MAX];
struct stat st; struct stat st;
char bytes[FORMAT_BYTES_MAX]; char bytes[FORMAT_BYTES_MAX];
+1 -1
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) { _public_ int sd_journal_get_cursor(sd_journal *j, char **cursor) {
Object *o; Object *o;
int r; int r;
char bid[33], sid[33]; char bid[SD_ID128_STRING_MAX], sid[SD_ID128_STRING_MAX];
assert_return(j, -EINVAL); assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD); assert_return(!journal_pid_changed(j), -ECHILD);
+1 -1
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); r = sd_bus_message_new_method_return(m, &reply);
else if (streq_ptr(m->member, "GetMachineId")) { else if (streq_ptr(m->member, "GetMachineId")) {
sd_id128_t id; sd_id128_t id;
char sid[33]; char sid[SD_ID128_STRING_MAX];
r = sd_id128_get_machine(&id); r = sd_id128_get_machine(&id);
if (r < 0) if (r < 0)
+1 -1
View File
@@ -11,7 +11,7 @@
#include "io-util.h" #include "io-util.h"
#include "stdio-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; unsigned n, k = 0;
assert(s); assert(s);
+3 -1
View File
@@ -8,7 +8,9 @@
#include "hash-funcs.h" #include "hash-funcs.h"
#include "macro.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_; bool id128_is_valid(const char *s) _pure_;
+2 -2
View File
@@ -2229,9 +2229,9 @@ static int setup_hostname(void) {
static int setup_journal(const char *directory) { static int setup_journal(const char *directory) {
_cleanup_free_ char *d = NULL; _cleanup_free_ char *d = NULL;
char id[SD_ID128_STRING_MAX];
const char *dirname, *p, *q; const char *dirname, *p, *q;
sd_id128_t this_id; sd_id128_t this_id;
char id[33];
bool try; bool try;
int r; int r;
@@ -2866,7 +2866,7 @@ static int inner_child(
FDSet *fds) { FDSet *fds) {
_cleanup_free_ char *home = NULL; _cleanup_free_ char *home = NULL;
char as_uuid[37]; char as_uuid[ID128_UUID_STRING_MAX];
size_t n_env = 1; size_t n_env = 1;
const char *envp[] = { const char *envp[] = {
"PATH=" DEFAULT_PATH_COMPAT, "PATH=" DEFAULT_PATH_COMPAT,
+4 -3
View File
@@ -17,6 +17,7 @@
#include "format-util.h" #include "format-util.h"
#include "hashmap.h" #include "hashmap.h"
#include "hostname-util.h" #include "hostname-util.h"
#include "id128-util.h"
#include "io-util.h" #include "io-util.h"
#include "journal-internal.h" #include "journal-internal.h"
#include "json.h" #include "json.h"
@@ -26,8 +27,8 @@
#include "namespace-util.h" #include "namespace-util.h"
#include "output-mode.h" #include "output-mode.h"
#include "parse-util.h" #include "parse-util.h"
#include "process-util.h"
#include "pretty-print.h" #include "pretty-print.h"
#include "process-util.h"
#include "sparse-endian.h" #include "sparse-endian.h"
#include "stdio-util.h" #include "stdio-util.h"
#include "string-table.h" #include "string-table.h"
@@ -654,7 +655,7 @@ static int output_export(
const size_t highlight[2]) { const size_t highlight[2]) {
sd_id128_t boot_id; sd_id128_t boot_id;
char sid[33]; char sid[SD_ID128_STRING_MAX];
int r; int r;
usec_t realtime, monotonic; usec_t realtime, monotonic;
_cleanup_free_ char *cursor = NULL; _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) { 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_pair_ int pair[2] = { -1, -1 };
_cleanup_close_ int pidnsfd = -1, mntnsfd = -1, rootfd = -1; _cleanup_close_ int pidnsfd = -1, mntnsfd = -1, rootfd = -1;
char buf[ID128_UUID_STRING_MAX];
pid_t pid, child; pid_t pid, child;
char buf[37];
ssize_t k; ssize_t k;
int r; int r;
+1 -1
View File
@@ -21,7 +21,7 @@
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
sd_id128_t id, id2; 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_free_ char *b = NULL;
_cleanup_close_ int fd = -1; _cleanup_close_ int fd = -1;
int r; int r;
+1 -1
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) { static int determine_devices(void) {
_cleanup_free_ void *m = NULL; _cleanup_free_ void *m = NULL;
sd_id128_t root_uuid, verity_uuid; sd_id128_t root_uuid, verity_uuid;
char ids[37]; char ids[ID128_UUID_STRING_MAX];
size_t l; size_t l;
int r; int r;