X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fuuid.c;h=a5fba034faf22f518f496deb5125a10bb8a24f8b;hp=4846841bb5cc7718b5221f443a0888580007efd8;hb=f22b9ecc5e5d204e5dcb6861d6fd8039e1fb0181;hpb=a1b19a64325554b0410daaefed3ce229b34958b7 diff --git a/src/uuid.c b/src/uuid.c index 4846841b..a5fba034 100644 --- a/src/uuid.c +++ b/src/uuid.c @@ -26,10 +26,12 @@ #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 +39,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 +192,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; }