From ca3ab55a5c21b4d617861476595c2e887f2014fa Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Wed, 28 Aug 2019 00:27:28 +0300 Subject: [PATCH] Satisfy compiler warning about unchecked getcwd() return TODO: raise an error --- c/os_unix.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/c/os_unix.c b/c/os_unix.c index 80d836c..e7bfe8c 100644 --- a/c/os_unix.c +++ b/c/os_unix.c @@ -28,7 +28,12 @@ void path_to_dirname(char *path) *p = '\0'; } -void get_cwd(char *buf, size_t size) { getcwd(buf, size); } +void get_cwd(char *buf, size_t size) +{ + if (!getcwd(buf, size)) { + memset(buf, 0, size); + } +} int set_cwd(char *buf) {