sparc: Break up monolithic iommu table/lock into finer graularity pools and lock
[deliverable/linux.git] / lib / vsprintf.c
index 3ab8c9cf3980dc0228d3c5a879da86cb88d67361..3a1e0843f9a2b31e599a5ef9d33ebd0e81c5a208 100644 (file)
@@ -777,11 +777,19 @@ char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
        if (spec.field_width > 0)
                len = min_t(int, spec.field_width, 64);
 
-       for (i = 0; i < len && buf < end - 1; i++) {
-               buf = hex_byte_pack(buf, addr[i]);
+       for (i = 0; i < len; ++i) {
+               if (buf < end)
+                       *buf = hex_asc_hi(addr[i]);
+               ++buf;
+               if (buf < end)
+                       *buf = hex_asc_lo(addr[i]);
+               ++buf;
 
-               if (buf < end && separator && i != len - 1)
-                       *buf++ = separator;
+               if (separator && i != len - 1) {
+                       if (buf < end)
+                               *buf = separator;
+                       ++buf;
+               }
        }
 
        return buf;
@@ -1227,8 +1235,12 @@ char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
 
        len = spec.field_width < 0 ? 1 : spec.field_width;
 
-       /* Ignore the error. We print as many characters as we can */
-       string_escape_mem(addr, len, &buf, end - buf, flags, NULL);
+       /*
+        * string_escape_mem() writes as many characters as it can to
+        * the given buffer, and returns the total size of the output
+        * had the buffer been big enough.
+        */
+       buf += string_escape_mem(addr, len, buf, buf < end ? end - buf : 0, flags, NULL);
 
        return buf;
 }
This page took 0.023637 seconds and 5 git commands to generate.