diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-11-07 12:19:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-11-07 12:20:17 +0000 |
commit | a64a253794ac64cb40befee54db53bde17dd0d49 (patch) | |
tree | c1024acc5f6e508814b944d99f112259bb28b1be /libnetdata/inlined.h | |
parent | New upstream version 1.10.0+dfsg (diff) | |
download | netdata-upstream/1.11.0+dfsg.tar.xz netdata-upstream/1.11.0+dfsg.zip |
New upstream version 1.11.0+dfsgupstream/1.11.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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; } |