]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: udf: For better readibility use one snprintf call instead multiple in loop
authorPali Rohár <pali.rohar@gmail.com>
Mon, 1 May 2017 07:28:22 +0000 (09:28 +0200)
committerPali Rohár <pali.rohar@gmail.com>
Mon, 1 May 2017 07:28:22 +0000 (09:28 +0200)
libblkid/src/superblocks/udf.c

index fc258cd1ea716e16c0186b6f5998cda55b0e813b..efbf7983dd529cdf63127486fbecb3d392edd673 100644 (file)
@@ -109,12 +109,13 @@ static inline int gen_uuid_from_volset_id(unsigned char uuid[17], struct dstring
        }
 
        if (binpos < 8) {
-               for (i = 0; i < 8; ++i)
-                       snprintf((char *) uuid + 2 * i, 3, "%02x", buf[i]);
+               snprintf((char *) uuid, 17, "%02x%02x%02x%02x%02x%02x%02x%02x",
+                       buf[0], buf[1], buf[2], buf[3],
+                       buf[4], buf[5], buf[6], buf[7]);
        } else if (binpos < 16) {
                memcpy(uuid, buf, 8);
-               for (i = 0; i < 4; ++i)
-                       snprintf((char *) uuid + 8 + 2 * i, 3, "%02x", buf[8+i]);
+               snprintf((char *) uuid + 8, 9, "%02x%02x%02x%02x",
+                       buf[8], buf[9], buf[10], buf[11]);
        } else {
                memcpy(uuid, buf, 16);
                uuid[16] = 0;