azure-sdk-for-c
azure-sdk-for-c copied to clipboard
We need a linter for C code
These things should not be possible:
az_curl_done(CURL ** pp);
...
CURL * p_curl;
az_curl_done(p_curl); // <-- does compile
or
do_something(uint8_t const * x);
...
az_span span = (az_span){ .begin = ..., .size = ... };
do_something(span); // happy debugging!
@sergey-shandar suggested to assign this to you @barcharcraz, so that maybe you can rescommend us something we should use.
I can't get the second example to compile.
void do_something(uint8_t const *test)
{
(void)test;
}
typedef struct az_span
{
int size;
uint8_t *data;
} az_span;
int main()
{
az_span span = (az_span){.size = 8, .data = 0};
do_something(span);
}
Ah I see what's going on now.
CURL is:
typedef void CURL;
so the first example is:
az_curl_done(void** pp);
void* p_curl;
az_curl_done(p_curl); <- implicit conversion here
for curl in particular it looks like there's a macro CURL_STRICTER
that, when defined, gives a better typedef here, and would prevent this problem. Shame there's no easy way to find out about it by reading the user-facing docs.
Any concern with using clang-tidy?
@joshfree I'm ok with anything if it solves such problems and not introducing more problems :-)
I think @ahsonkhan did something about adding Lint... Can you confirm Ahson? Can we close this then?
I ran the linter across our repo before GA, yes, but we should leave this issue open until that has been added to CI for automated checks.
Hi @antkmsft, we deeply appreciate your input into this project. Regrettably, this issue has remained inactive for over 2 years, leading us to the decision to close it. We've implemented this policy to maintain the relevance of our issue queue and facilitate easier navigation for new contributors. If you still believe this topic requires attention, please feel free to create a new issue, referencing this one. Thank you for your understanding and ongoing support.