id128: introduce ID128_UUID_STRING_MAX for sizing UUID buffers

This commit is contained in:
Lennart Poettering 2019-12-10 11:33:28 +01:00
parent dd1b315d22
commit b5ea030d65
6 changed files with 10 additions and 7 deletions

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

@ -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"
@ -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;