obfsproxy: don't reinvent offsetof
Change 9d96eb94 introduced a bogon to util.h:
#define OFFSETOF(container_type, element) \ (((char*)&((container_type*)0)->element) - ((char*) ((container_type*)0)))
It is not necessary to reinvent this particular wheel -- stddef.h
, which is part of C89 and is well-supported everywhere, provides offsetof
-- and it's actually wrong: there is a dereference of the null pointer here, and that causes undefined behavior, even when it's inside the operand of &
. (I am not aware of any compiler that presently generates "incorrect" results for this construct, but it did cause the compiler itself to crash in some (probably never-released) versions of GCC: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17396 .)
Please apply attached patch. I also renamed UPCAST to DOWNCAST, consistent with C++ terminology (the type is becoming more specific, that's downward).