From: Christian Brauner Date: Wed, 22 Aug 2018 13:45:33 +0000 (+0200) Subject: string_utils: add remove_trailing_slashes() X-Git-Tag: lxc-3.1.0~133^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dca12ddf8d40f0f56c417ad3f0056b8637c0d209;p=thirdparty%2Flxc.git string_utils: add remove_trailing_slashes() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/initutils.c b/src/lxc/initutils.c index 9e5397aa6..c582b2d00 100644 --- a/src/lxc/initutils.c +++ b/src/lxc/initutils.c @@ -217,13 +217,6 @@ out: return values[i]; } -extern void remove_trailing_slashes(char *p) -{ - int l = strlen(p); - while (--l >= 0 && (p[l] == '/' || p[l] == '\n')) - p[l] = '\0'; -} - /* * Sets the process title to the specified title. Note that this may fail if * the kernel doesn't support PR_SET_MM_MAP (kernels <3.18). diff --git a/src/lxc/initutils.h b/src/lxc/initutils.h index 6753956ce..4af8c3e6c 100644 --- a/src/lxc/initutils.h +++ b/src/lxc/initutils.h @@ -24,6 +24,8 @@ #ifndef __LXC_INITUTILS_H #define __LXC_INITUTILS_H +#include "config.h" + #include #include #include @@ -31,12 +33,12 @@ #include #include #include -#include #include #include #include +#include -#include "config.h" +#include "string_utils.h" #define DEFAULT_VG "lxc" #define DEFAULT_THIN_POOL "lxc" @@ -70,7 +72,6 @@ struct prctl_mm_map { extern const char *lxc_global_config_value(const char *option_name); -extern void remove_trailing_slashes(char *p); extern int setproctitle(char *title); #endif /* __LXC_INITUTILS_H */ diff --git a/src/lxc/string_utils.c b/src/lxc/string_utils.c index 633255c5c..74cea3c70 100644 --- a/src/lxc/string_utils.c +++ b/src/lxc/string_utils.c @@ -978,3 +978,10 @@ int lxc_is_line_empty(const char *line) return 0; return 1; } + +void remove_trailing_slashes(char *p) +{ + int l = strlen(p); + while (--l >= 0 && (p[l] == '/' || p[l] == '\n')) + p[l] = '\0'; +} diff --git a/src/lxc/string_utils.h b/src/lxc/string_utils.h index 211c6c866..d289d18e0 100644 --- a/src/lxc/string_utils.h +++ b/src/lxc/string_utils.h @@ -111,5 +111,6 @@ extern int lxc_char_right_gc(const char *buffer, size_t len); extern char *lxc_trim_whitespace_in_place(char *buffer); extern int lxc_is_line_empty(const char *line); +extern void remove_trailing_slashes(char *p); #endif /* __LXC_STRING_UTILS_H */