diff options
Diffstat (limited to '')
-rw-r--r-- | libnetdata/inlined.h (renamed from src/inlined.h) | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/inlined.h b/libnetdata/inlined.h index 9ab2dca73..6a5994c12 100644 --- a/src/inlined.h +++ b/libnetdata/inlined.h @@ -1,7 +1,9 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + #ifndef NETDATA_INLINED_H -#define NETDATA_INLINED_H +#define NETDATA_INLINED_H 1 -#include "common.h" +#include "libnetdata.h" #ifdef KERNEL_32BIT typedef uint32_t kernel_uint_t; @@ -245,12 +247,17 @@ static inline char *strncpyz(char *dst, const char *src, size_t n) { } static inline int read_file(const char *filename, char *buffer, size_t size) { + if(unlikely(!size)) return 3; + int fd = open(filename, O_RDONLY, 0666); - if(unlikely(fd == -1)) + if(unlikely(fd == -1)) { + buffer[0] = '\0'; return 1; + } ssize_t r = read(fd, buffer, size); if(unlikely(r == -1)) { + buffer[0] = '\0'; close(fd); return 2; } |