X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fuuid.c;h=4bd43340f61a0100b10233bd61bf5d889706a2bd;hp=4846841bb5cc7718b5221f443a0888580007efd8;hb=d748379ea585d52338913a6ba589842ae05ab78a;hpb=7c2336dde35a7b42853b6ca167d4164619e52333 diff --git a/src/uuid.c b/src/uuid.c index 4846841b..4bd43340 100644 --- a/src/uuid.c +++ b/src/uuid.c @@ -26,10 +26,11 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" -#if HAVE_SYS_SYSCTL_H +#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME) || defined(__OpenBSD__) +/* Implies have BSD variant */ #include #endif @@ -37,18 +38,15 @@ #define UUID_PRINTABLE_COMPACT_LENGTH (UUID_RAW_LENGTH * 2) #define UUID_PRINTABLE_NORMAL_LENGTH (UUID_PRINTABLE_COMPACT_LENGTH + 4) -static char *uuidfile = NULL; +static char *uuidfile; static const char *config_keys[] = {"UUIDFile"}; static int looks_like_a_uuid(const char *uuid) { - int len; - if (!uuid) return 0; - len = strlen(uuid); - + size_t len = strlen(uuid); if (len < UUID_PRINTABLE_COMPACT_LENGTH) return 0; @@ -193,7 +191,7 @@ static int uuid_init(void) { char *uuid = uuid_get_local(); if (uuid) { - sstrncpy(hostname_g, uuid, DATA_MAX_NAME_LEN); + hostname_set(uuid); sfree(uuid); return 0; }