[systemd-devel] [PATCH] util: Make in_charset a static inline in util.h

Lennart Poettering lennart at poettering.net
Wed Mar 12 09:05:56 PDT 2014


On Tue, 11.03.14 18:51, Josh Triplett (josh at joshtriplett.org) wrote:

Applied both.

THanks!

> With in_charset now reduced to a one-liner (plus asserts), make it a
> static inline.
> ---
> 
> This applies on top of the previous patch simplifying in_charset.
> 
>  src/shared/util.c | 6 ------
>  src/shared/util.h | 6 +++++-
>  2 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/src/shared/util.c b/src/shared/util.c
> index 82326df..9f79409 100644
> --- a/src/shared/util.c
> +++ b/src/shared/util.c
> @@ -920,12 +920,6 @@ char *delete_chars(char *s, const char *bad) {
>          return s;
>  }
>  
> -bool in_charset(const char *s, const char* charset) {
> -        assert(s);
> -        assert(charset);
> -        return s[strspn(s, charset)] == '\0';
> -}
> -
>  char *file_in_same_dir(const char *path, const char *filename) {
>          char *e, *r;
>          size_t k;
> diff --git a/src/shared/util.h b/src/shared/util.h
> index c2bc977..0c8eb4b 100644
> --- a/src/shared/util.h
> +++ b/src/shared/util.h
> @@ -529,7 +529,11 @@ char *strjoin(const char *x, ...) _sentinel_;
>  
>  bool is_main_thread(void);
>  
> -bool in_charset(const char *s, const char* charset) _pure_;
> +static inline bool _pure_ in_charset(const char *s, const char* charset) {
> +        assert(s);
> +        assert(charset);
> +        return s[strspn(s, charset)] == '\0';
> +}
>  
>  int block_get_whole_disk(dev_t d, dev_t *ret);
>  


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list