verify: unroll string copy
authorJens Axboe <axboe@fb.com>
Wed, 11 May 2016 01:50:00 +0000 (19:50 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 11 May 2016 01:50:00 +0000 (19:50 -0600)
Let's just turn the strcpy+replace into a hand rolled version.

Signed-off-by: Jens Axboe <axboe@fb.com>
verify-state.h

index ccde031..901aa0a 100644 (file)
@@ -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