Wireshark-bugs: [Wireshark-bugs] [Bug 3467] Memcache Textual Protocol dissector patch
Date: Tue, 19 May 2009 14:14:26 -0700 (PDT)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3467





--- Comment #18 from Stig Bjørlykke <stig@xxxxxxxxxxxxx>  2009-05-19 14:14:26 PDT ---
(In reply to comment #17)
> Yeah, I got to the bottom of the problem here. This was my goofy logic around
> comparing an opcode with OP_GET.

Ah, yes :)


And while looking at this code.  I would really like you to rewrite this block
to a more human readable format, because it's not that easy to see that it's
both a check and some assignments.

>     if (((strncmp(data, "get", indx) == 0) ? ((*opcode = OP_GET) || 1) : 0)  ||
>         (strncmp(data, "set", indx) == 0 && (*opcode = OP_SET) &&
>          (*expect_content_length = TRUE)) ||
>         (strncmp(data, "add", indx) == 0 && (*opcode = OP_ADD) &&
>          (*expect_content_length = TRUE)) ||
>         (strncmp(data, "cas", indx) == 0 && (*opcode = OP_CAS) &&
>          (*expect_content_length = TRUE))) {
>       is_request_or_response = TRUE;
>       *type = MEMCACHE_REQUEST;
>     }

Maybe more like this:

     if (strncmp(data, "get", indx) == 0) {
        *opcode = OP_GET;
        is_request_or_response = TRUE;
        *type = MEMCACHE_REQUEST;
     } else if (strncmp(data, "set", indx) == 0) {
        *opcode = OP_SET;
        *expect_content_length = TRUE;
        is_request_or_response = TRUE;
        *type = MEMCACHE_REQUEST;
     } else if (...) {
     }


-- 
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.