Greg Ward avatar Greg Ward committed f39c0a8

Swap args to dump_hex() so dest comes first.
This is more consistent with e.g. strcat(), sprintf(), etc.

Comments (0)

Files changed (3)

 }
 
 void
-dump_hex(const char *data, char *buf, int datasize)
+dump_hex(char *dest, const char *data, int datasize)
 {
     const char HEXSTR[16] = {'0', '1', '2', '3', '4', '5', '6', '7',
                              '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
     int i;
 
     for (i = 0; i < datasize; ++i) {
-        buf[i * 2] = HEXSTR[(unsigned char) data[i] >> 4];
-        buf[i * 2 + 1] = HEXSTR[(unsigned char) data[i] & 0x0f];
+        dest[i * 2] = HEXSTR[(unsigned char) data[i] >> 4];
+        dest[i * 2 + 1] = HEXSTR[(unsigned char) data[i] & 0x0f];
     }
 
-    buf[i * 2] = '\0';
+    dest[i * 2] = '\0';
 }
 
 void
 void
 chop_newline(char *buf);
 
-/* Encode datasize bytes of binary data to hex chars in buf.  Caller
- * must allocate at least datasize*2 + 1 chars for buf.
+/* Encode datasize bytes of binary data to hex chars in dest. Caller
+ * must allocate at least datasize * 2 + 1 chars for dest.
  */
 void
-dump_hex(const char *data, char *buf, int datasize);
+dump_hex(char *dest, const char *data, int datasize);
 
 /* Copy up to nchars chars from src to dest, stopping at the first
  * newline and terminating dest with a NUL char.  On return, it is
         p += sprintf(p, "%d", csinfo.rev);
     }
     else {
-        dump_hex(nodeid, p, SHORT_NODEID_LEN);
+        dump_hex(p, nodeid, SHORT_NODEID_LEN);
         p += SHORT_NODEID_LEN * 2;
     }
     return p - dest;
     debug("read last line from %s: '%s'", status_fn, last_line);
 
     char nodeid_s[NODEID_LEN * 2 + 1];
-    dump_hex(result->full_revision, nodeid_s, NODEID_LEN);
+    dump_hex(nodeid_s, result->full_revision, NODEID_LEN);
 
     if (strncmp(nodeid_s, last_line, NODEID_LEN * 2) == 0) {
         result->patch = strdup(last_line + NODEID_LEN * 2 + 1);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.