]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-resp.c
Fix warnings when building for 32-bit and defining _TIME_BITS=64
[tcpdump] / print-resp.c
index 00a6e257d41746656825c9fe2c8ddde0b8d61cdf..7388a73fbd573dcb5c4779c9f720d871482a19d4 100644 (file)
@@ -209,14 +209,12 @@ static int resp_get_length(netdissect_options *, const u_char *, int, const u_ch
 void
 resp_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
-    int ret_len = 0, length_cur = length;
+    int ret_len = 0;
 
     ndo->ndo_protocol = "resp";
-    if(!bp || length <= 0)
-        return;
 
     ND_PRINT(": RESP");
-    while (length_cur > 0) {
+    while (length > 0) {
         /*
          * This block supports redis pipelining.
          * For example, multiple operations can be pipelined within the same string:
@@ -226,10 +224,10 @@ resp_print(netdissect_options *ndo, const u_char *bp, u_int length)
          * In order to handle this case, we must try and parse 'bp' until
          * 'length' bytes have been processed or we reach a trunc condition.
          */
-        ret_len = resp_parse(ndo, bp, length_cur);
+        ret_len = resp_parse(ndo, bp, length);
         TEST_RET_LEN_NORETURN(ret_len);
         bp += ret_len;
-        length_cur -= ret_len;
+        length -= ret_len;
     }
 
     return;
@@ -308,7 +306,7 @@ resp_print_string_error_integer(netdissect_options *ndo, const u_char *bp, int l
      * preceding the \r\n.  That includes the opcode, so don't print
      * that.
      */
-    len = ND_BYTES_BETWEEN(bp_ptr, bp);
+    len = ND_BYTES_BETWEEN(bp, bp_ptr);
     RESP_PRINT_SEGMENT(ndo, bp, len);
     ret_len = 1 /*<opcode>*/ + len /*<string>*/ + 2 /*<CRLF>*/;
 
@@ -433,7 +431,7 @@ resp_print_inline(netdissect_options *ndo, const u_char *bp, int length) {
      * Found it; bp_ptr points to the \r or \n, so bp_ptr - bp is the
      * Length of the line text that precedes it.  Print it.
      */
-    len = ND_BYTES_BETWEEN(bp_ptr, bp);
+    len = ND_BYTES_BETWEEN(bp, bp_ptr);
     RESP_PRINT_SEGMENT(ndo, bp, len);
 
     /*