From 318e1be240574e316094e5ea73d32e9f9a1f7c04 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 18 Sep 2015 07:27:35 -0400 Subject: [PATCH] Fix warnings introduced by prior commit --- include/stringop.h | 5 +++++ sway/commands.c | 1 + sway/container.c | 2 ++ sway/log.c | 4 +--- sway/main.c | 1 + sway/stringop.c | 8 ++++++++ sway/workspace.c | 1 + 7 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/stringop.h b/include/stringop.h index dde50f135..f9f3130c7 100644 --- a/include/stringop.h +++ b/include/stringop.h @@ -2,6 +2,11 @@ #define _SWAY_STRINGOP_H #include "list.h" +#if !HAVE_DECL_SETENV +// Not sure why we need to provide this +extern int setenv(const char *, const char *, int); +#endif + // array of whitespace characters to use for delims extern const char *whitespace; diff --git a/sway/commands.c b/sway/commands.c index 71eb9d70c..68bdff2ca 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/sway/container.c b/sway/container.c index ef0e6c555..85b169a19 100644 --- a/sway/container.c +++ b/sway/container.c @@ -1,7 +1,9 @@ #include #include #include +#include #include "config.h" +#include "stringop.h" #include "container.h" #include "workspace.h" #include "focus.h" diff --git a/sway/log.c b/sway/log.c index cf5c2092f..a6582172b 100644 --- a/sway/log.c +++ b/sway/log.c @@ -80,9 +80,7 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) { va_end(args); fprintf(stderr, ": "); - char error[256]; - strerror_r(errno, error, sizeof(error)); - fprintf(stderr, "%s", error); + fprintf(stderr, "%s", strerror(errno)); if (colored && isatty(STDERR_FILENO)) { fprintf(stderr, "\x1B[0m"); diff --git a/sway/main.c b/sway/main.c index 97243f990..669211840 100644 --- a/sway/main.c +++ b/sway/main.c @@ -7,6 +7,7 @@ #include #include #include "layout.h" +#include "stringop.h" #include "config.h" #include "log.h" #include "readline.h" diff --git a/sway/stringop.c b/sway/stringop.c index 191e40c86..7a2c83171 100644 --- a/sway/stringop.c +++ b/sway/stringop.c @@ -311,3 +311,11 @@ char *join_list(list_t *list, char *separator) { return res; } + +char *strdup(const char *str) { + char *dup = malloc(strlen(str) + 1); + if (dup) { + strcpy(dup, str); + } + return dup; +} diff --git a/sway/workspace.c b/sway/workspace.c index 658f79bc7..c169c1cb8 100644 --- a/sway/workspace.c +++ b/sway/workspace.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "workspace.h" #include "layout.h" #include "list.h"