From 5c8f0ba56837a0b848cbbbc5a8673589d099ded3 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 10 May 2016 19:50:00 -0600 Subject: [PATCH] verify: unroll string copy Let's just turn the strcpy+replace into a hand rolled version. Signed-off-by: Jens Axboe --- verify-state.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/verify-state.h b/verify-state.h index ccde031a..901aa0a4 100644 --- a/verify-state.h +++ b/verify-state.h @@ -89,18 +89,19 @@ static inline void verify_state_gen_name(char *out, size_t size, /* * Escape '/', just turn them into '.' */ - strcpy(ename, name); ptr = ename; - while ((ptr = strchr(ptr, '/')) != NULL) { - *ptr = '.'; - ptr++; + do { + *ptr = *name; if (*ptr == '\0') break; - } + else if (*ptr == '/') + *ptr = '.'; + ptr++; + name++; + } while (1); snprintf(out, size, "%s-%s-%d-verify.state", prefix, ename, num); out[size - 1] = '\0'; - } #endif -- 2.25.1