From: Yu Watanabe Date: Tue, 31 May 2022 21:25:52 +0000 (+0900) Subject: boot: make several functions inline X-Git-Tag: v252-rc1~875^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=42e785d09636b7e0465e0866f6adc32d31f043c4;p=thirdparty%2Fsystemd.git boot: make several functions inline Follow-ups for #23512. --- diff --git a/src/boot/efi/efi-string.c b/src/boot/efi/efi-string.c index b93d0ed46a5..22367ed7385 100644 --- a/src/boot/efi/efi-string.c +++ b/src/boot/efi/efi-string.c @@ -37,14 +37,6 @@ DEFINE_STRNLEN(char, strnlen8); DEFINE_STRNLEN(char16_t, strnlen16); -size_t strlen8(const char *s) { - return strnlen8(s, SIZE_MAX); -} - -size_t strlen16(const char16_t *s) { - return strnlen16(s, SIZE_MAX); -} - #define TOLOWER(c) \ ({ \ typeof(c) _c = (c); \ @@ -87,26 +79,9 @@ DEFINE_STRTOLOWER(char16_t, strtolower16); DEFINE_STRNCASECMP(char, strncmp8, false); DEFINE_STRNCASECMP(char16_t, strncmp16, false); - -int strcmp8(const char *s1, const char *s2) { - return strncmp8(s1, s2, SIZE_MAX); -} - -int strcmp16(const char16_t *s1, const char16_t *s2) { - return strncmp16(s1, s2, SIZE_MAX); -} - DEFINE_STRNCASECMP(char, strncasecmp8, true); DEFINE_STRNCASECMP(char16_t, strncasecmp16, true); -int strcasecmp8(const char *s1, const char *s2) { - return strncasecmp8(s1, s2, SIZE_MAX); -} - -int strcasecmp16(const char16_t *s1, const char16_t *s2) { - return strncasecmp16(s1, s2, SIZE_MAX); -} - #define DEFINE_STRCPY(type, name) \ type *name(type * restrict dest, const type * restrict src) { \ assert(dest); \ @@ -165,14 +140,6 @@ DEFINE_STRCHR(char16_t, strchr16); DEFINE_STRNDUP(char, xstrndup8, strnlen8); DEFINE_STRNDUP(char16_t, xstrndup16, strnlen16); -char *xstrdup8(const char *s) { - return xstrndup8(s, SIZE_MAX); -} - -char16_t *xstrdup16(const char16_t *s) { - return xstrndup16(s, SIZE_MAX); -} - int efi_memcmp(const void *p1, const void *p2, size_t n) { if (!p1 || !p2) return CMP(p1, p2); diff --git a/src/boot/efi/efi-string.h b/src/boot/efi/efi-string.h index 1d3188f1fa6..b4870975bcb 100644 --- a/src/boot/efi/efi-string.h +++ b/src/boot/efi/efi-string.h @@ -10,8 +10,13 @@ size_t strnlen8(const char *s, size_t n); size_t strnlen16(const char16_t *s, size_t n); -size_t strlen8(const char *s); -size_t strlen16(const char16_t *s); +static inline size_t strlen8(const char *s) { + return strnlen8(s, SIZE_MAX); +} + +static inline size_t strlen16(const char16_t *s) { + return strnlen16(s, SIZE_MAX); +} static inline size_t strsize8(const char *s) { return s ? (strlen8(s) + 1) * sizeof(*s) : 0; @@ -26,15 +31,24 @@ void strtolower16(char16_t *s); int strncmp8(const char *s1, const char *s2, size_t n); int strncmp16(const char16_t *s1, const char16_t *s2, size_t n); - -int strcmp8(const char *s1, const char *s2); -int strcmp16(const char16_t *s1, const char16_t *s2); - int strncasecmp8(const char *s1, const char *s2, size_t n); int strncasecmp16(const char16_t *s1, const char16_t *s2, size_t n); -int strcasecmp8(const char *s1, const char *s2); -int strcasecmp16(const char16_t *s1, const char16_t *s2); +static inline int strcmp8(const char *s1, const char *s2) { + return strncmp8(s1, s2, SIZE_MAX); +} + +static inline int strcmp16(const char16_t *s1, const char16_t *s2) { + return strncmp16(s1, s2, SIZE_MAX); +} + +static inline int strcasecmp8(const char *s1, const char *s2) { + return strncasecmp8(s1, s2, SIZE_MAX); +} + +static inline int strcasecmp16(const char16_t *s1, const char16_t *s2) { + return strncasecmp16(s1, s2, SIZE_MAX); +} static inline bool strneq8(const char *s1, const char *s2, size_t n) { return strncmp8(s1, s2, n) == 0; @@ -77,8 +91,13 @@ char16_t *strchr16(const char16_t *s, char16_t c); char *xstrndup8(const char *s, size_t n); char16_t *xstrndup16(const char16_t *s, size_t n); -char *xstrdup8(const char *s); -char16_t *xstrdup16(const char16_t *s); +static inline char *xstrdup8(const char *s) { + return xstrndup8(s, SIZE_MAX); +} + +static inline char16_t *xstrdup16(const char16_t *s) { + return xstrndup16(s, SIZE_MAX); +} #ifdef SD_BOOT /* The compiler normally has knowledge about standard functions such as memcmp, but this is not the case when