]> granicus.if.org Git - strace/commitdiff
tests: fix print_quoted_hex output of bytes with high bit set
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 8 Jul 2017 14:57:44 +0000 (14:57 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 8 Jul 2017 14:57:44 +0000 (14:57 +0000)
* tests/tests.h (print_quoted_memory, print_quoted_hex): Change the type
of first argument from "const char *" to "const void *".
* tests/print_quoted_string.c: Likewise.
(print_quoted_hex): Print bytes as unsigned char objects to avoid
unwanted sign extension.
* tests/netlink_protocol.c (send_query): Remove the cast of print_quoted_hex
first argument which is now redundant.

tests/netlink_protocol.c
tests/print_quoted_string.c
tests/tests.h

index a3e09cb9a632f5b3cec69aaa098ee4f25ce7f01c..ee5bf0fe5afd4d1697cd1336abc1e10c92ad394c 100644 (file)
@@ -156,7 +156,7 @@ send_query(const int fd)
        printf("sendto(%d, [{{len=%u, type=NLMSG_NOOP, flags=NLM_F_REQUEST|0x%x"
               ", seq=0, pid=0}, \"\\x61\\x62\\x63\\x64\"}, ",
               fd, reqs->req1.nlh.nlmsg_len, NLM_F_DUMP);
-       print_quoted_hex((void *) &reqs->req2.nlh,
+       print_quoted_hex(&reqs->req2.nlh,
                         sizeof(reqs->req2) - sizeof(req->nlh));
        printf("], %u, MSG_DONTWAIT, NULL, 0) = %s\n",
               (unsigned) (sizeof(*reqs) - sizeof(req->nlh)), errstr);
index 9103eed62a3380b3c39455987286904f94509610..dcfcfa0e8e332aedcead460f7edd5e3147b3c107 100644 (file)
@@ -16,7 +16,7 @@ print_quoted_string(const char *instr)
 }
 
 void
-print_quoted_memory(const char *instr, const size_t len)
+print_quoted_memory(const void *const instr, const size_t len)
 {
        const unsigned char *str = (const unsigned char *) instr;
        size_t i;
@@ -77,8 +77,9 @@ print_quoted_memory(const char *instr, const size_t len)
 }
 
 void
-print_quoted_hex(const char *str, const size_t len)
+print_quoted_hex(const void *const instr, const size_t len)
 {
+       const unsigned char *str = instr;
        size_t i;
 
        printf("\"");
index bc7dc9880cd50d8a233c54c6214097d566a8237d..633461b3cd39b7e190aced8757144e91accf58f8 100644 (file)
@@ -135,10 +135,10 @@ unsigned long inode_of_sockfd(int);
 void print_quoted_string(const char *);
 
 /* Print memory in a quoted form. */
-void print_quoted_memory(const char *, size_t);
+void print_quoted_memory(const void *, size_t);
 
 /* Print memory in a hexquoted form. */
-void print_quoted_hex(const char *, size_t);
+void print_quoted_hex(const void *, size_t);
 
 /* Print time_t and nanoseconds in symbolic format. */
 void print_time_t_nsec(time_t, unsigned long long, int);