diff options
author | Andrew Jones <ajones@ventanamicro.com> | 2023-07-25 16:41:27 +0800 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2023-08-08 21:41:57 +0530 |
commit | dfaf20af7649c82b0c53103e3bd9f3e6c3751c9d (patch) | |
tree | b0a3f7737ac128462e82835ce4c8aa057c14fba3 /tools/testing/selftests/kvm/include | |
parent | 630b4cee9c378e2dbb56ed84f71fc2fac50b716e (diff) |
KVM: arm64: selftests: Replace str_with_index with strdup_printf
The original author of aarch64/get-reg-list.c (me) was wearing
tunnel vision goggles when implementing str_with_index(). There's
no reason to have such a special case string function. Instead,
take inspiration from glib and implement strdup_printf. The
implementation builds on vasprintf() which requires _GNU_SOURCE,
but we require _GNU_SOURCE in most files already.
Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Haibo Xu <haibo1.xu@intel.com>
Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'tools/testing/selftests/kvm/include')
-rw-r--r-- | tools/testing/selftests/kvm/include/test_util.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h index a6e9f215ce70..7e0182f837b5 100644 --- a/tools/testing/selftests/kvm/include/test_util.h +++ b/tools/testing/selftests/kvm/include/test_util.h @@ -186,4 +186,6 @@ static inline uint32_t atoi_non_negative(const char *name, const char *num_str) return num; } +char *strdup_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2), nonnull(1))); + #endif /* SELFTEST_KVM_TEST_UTIL_H */ |