X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fuuid.c;h=b5ac8944f27ebf730e0e7b56606a4ee5c511c03d;hb=ac1c1538e338f7f04deaff68604d36bba6ab4237;hp=4846841bb5cc7718b5221f443a0888580007efd8;hpb=c99e3a4d169ada9299c73e20662d17debdc32e1f;p=collectd.git diff --git a/src/uuid.c b/src/uuid.c index 4846841b..b5ac8944 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) +/* 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; }