[Mesa-dev] [PATCH mesa 05/13] util: use standard name for strncat()
Emil Velikov
emil.l.velikov at gmail.com
Wed Nov 21 14:19:50 UTC 2018
On 2018/11/20, Eric Engestrom wrote:
> Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
> ---
> src/gallium/auxiliary/gallivm/lp_bld_printf.c | 6 +++---
> src/util/u_debug.c | 8 ++++----
> src/util/u_string.h | 2 +-
> 3 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
> index 53c4d3cde41e4677abdb..cf58c3b1eaa8d6152c17 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_printf.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
> @@ -126,12 +126,12 @@ lp_build_print_value(struct gallivm_state *gallivm,
>
> params[1] = lp_build_const_string(gallivm, msg);
> if (length == 1) {
> - util_strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
> + strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
> params[2] = value;
> } else {
> for (i = 0; i < length; ++i) {
> LLVMValueRef param;
> - util_strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
> + strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
> param = LLVMBuildExtractElement(builder, value, lp_build_const_int32(gallivm, i), "");
> if (type_kind == LLVMIntegerTypeKind &&
> LLVMGetIntTypeWidth(type_ref) < sizeof(int) * 8) {
> @@ -146,7 +146,7 @@ lp_build_print_value(struct gallivm_state *gallivm,
> }
> }
>
> - util_strncat(format, "\n", sizeof(format) - strlen(format) - 1);
> + strncat(format, "\n", sizeof(format) - strlen(format) - 1);
>
> params[0] = lp_build_const_string(gallivm, format);
> return lp_build_print_args(gallivm, 2 + length, params);
> diff --git a/src/util/u_debug.c b/src/util/u_debug.c
> index f6ed0138c1faf94ed399..787d6c255ebbd382d4c9 100644
> --- a/src/util/u_debug.c
> +++ b/src/util/u_debug.c
> @@ -371,10 +371,10 @@ debug_dump_flags(const struct debug_named_value *names, unsigned long value)
> while (names->name) {
> if ((names->value & value) == names->value) {
> if (!first)
> - util_strncat(output, "|", sizeof(output) - strlen(output) - 1);
> + strncat(output, "|", sizeof(output) - strlen(output) - 1);
> else
> first = 0;
> - util_strncat(output, names->name, sizeof(output) - strlen(output) - 1);
> + strncat(output, names->name, sizeof(output) - strlen(output) - 1);
> output[sizeof(output) - 1] = '\0';
> value &= ~names->value;
> }
> @@ -383,12 +383,12 @@ debug_dump_flags(const struct debug_named_value *names, unsigned long value)
>
> if (value) {
> if (!first)
> - util_strncat(output, "|", sizeof(output) - strlen(output) - 1);
> + strncat(output, "|", sizeof(output) - strlen(output) - 1);
> else
> first = 0;
>
> util_snprintf(rest, sizeof(rest), "0x%08lx", value);
> - util_strncat(output, rest, sizeof(output) - strlen(output) - 1);
> + strncat(output, rest, sizeof(output) - strlen(output) - 1);
> output[sizeof(output) - 1] = '\0';
> }
>
> diff --git a/src/util/u_string.h b/src/util/u_string.h
> index 94080e540d66b9fd8381..82c340663b757fcfb3d8 100644
> --- a/src/util/u_string.h
> +++ b/src/util/u_string.h
> @@ -139,6 +139,7 @@ util_strchr(const char *s, char c)
> return *p ? p : NULL;
> }
>
> +#define strncat util_strncat
> static inline char*
> util_strncat(char *dst, const char *src, size_t n)
> {
AFAICT the MSVC 2017 strncat [1] is identical to the ISO one.
Perhaps we should drop this helper?
HTH
Emil
[1] https://msdn.microsoft.com/en-us/library/tbyd7s1y.aspx
More information about the mesa-dev
mailing list