libcoap
libcoap copied to clipboard
Recheck source code in coap_dtls_new_context()
The implementation of the function “coap_dtls_new_context” does not contain a goto statement. The jump label “fail” can not be reached. How do you think about to adjust (or delete) a bit of source code here?
Unfortunately, it does contain a goto fail
statement. I would like to get rid of that side-effect of the macro G_CHECK
, i.e., make the jump obvious.
@obgm Wouldn't removing the goto fail
statement from G_CHECK
lead to lots of duplicate code as you'd have to put in if ... goto fail
each time. Wouldn't it it be better to rename the macro to make it obvious what it does?
How about "G_RET_ZERO_OR_FAIL"?
It is a macro, so this is duplicate source code anyway. But I agree that renaming would be better than nothing. @mrdeep1 do you have an opinion on this?
The issue with a long macro name is that there is likelihood of exceeding the line length of 80 characters. [Anything longer than G_CHECK will require lines to be split in most cases in the current code]
Many of the GnuTLS examples make the use of just CHECK (which normally triggers and assert()), I decided to prefix with G_ to indicate this was a CHECK for GnuTLS.
That said, I am all for better readability of the code making it self documenting where possible. To that end, I would prefer something like G_CHECK_FAIL.
Sounds good.
Ok is everyone fine with changing G_CHECK to G_CHECK_FAIL? If so I'll submit a pr, ensuring lines are split when needed.
@oliness If you are happy to do the work, that is fine by me.
@oliness Are you going to be able to do this work?