Copy-Paste
V501 There are identical sub-expressions ‘(uintptr_t) b->handler’ to the left and to the right of the ‘>’ operator. ip_fw_sockopt.c 2893
static int compare_sh(const void *_a, const void *_b) { const struct ipfw_sopt_handler *a, *b; a = (const struct ipfw_sopt_handler *)_a; b = (const struct ipfw_sopt_handler *)_b; .... if ((uintptr_t)a->handler < (uintptr_t)b->handler) return (-1); else if ((uintptr_t)b->handler > (uintptr_t)b->handler) return (1); return (0); }
Here is a vivid example of a bad practice – giving the variables short and uninformative names. Now because of the typo in the letter b, the a part of the condition will never be return 1. Thus, the function returns a zero status not always correctly.
Please click here to see more bugs from this project.