mirror of
https://github.com/curl/curl.git
synced 2026-08-06 04:46:13 +03:00
clang-tidy: add to CI, add cmake support, fix fallouts
build: - autotools: fix to build generated sources for the `tidy` target. - autotools: allow passing custom clang-tidy options via `CURL_CLANG_TIDYFLAGS` env. - cmake: add `CURL_CLANG_TIDY` option to configure for `clang-tidy`. Also add: - `CLANG_TIDY` variable to customize the `clang-tidy` tool. - `CURL_CLANG_TIDYFLAGS` to pass custom options to `clang-tidy`. - apply `--enable-werror` and `-DCURL_WERROR=ON` to `clang-tidy`. CI/GHA: - add clang-tidy job for Linux, using autotools and clang-tidy v18. This one needs to disable `clang-analyzer-valist.Uninitialized` to avoid false positives: https://github.com/llvm/llvm-project/issues/40656 Duration: 5.5 minutes - add clang-tidy job for macOS, using cmake and clang-tidy v19. This one also covers tests and examples, and doesn't hit the false positives seen with llvm v18 and earlier. Duration: 4.5 minutes - Linux/macOS: skip installing test dependencies when not building or running tests. fix fallouts reported by `clang-tidy`: - lib: - cf-h2-proxy: unused assignment in non-debug builds. - cf-socket: silence warning. FIXME: https://github.com/curl/curl/pull/15825#issuecomment-2561867769 - ftp: NULL passed to `strncmp()`. - http2: NULL-ptr deref. - mprintf: silence warning. - src/tool_writeout: NULL passed to `fputs()`. - examples: - invalid file pointers. - missing `fclose()`. - tests: - http/clients/hx-download: memory leaks on error. - http/clients/hx-download: memory leak on repeat `-r` option. - server: double `fclose()`. https://www.man7.org/linux/man-pages/man3/fclose.3.html - server: invalid file pointer/handle. - server/getpart: unused assignments. - server/mqttd: leak on failed `realloc()`. - server/tftpd: NULL passed to `strcmp()`. Closes #15825
This commit is contained in:
parent
421e592db2
commit
fabfa8e402
27 changed files with 134 additions and 68 deletions
|
|
@ -100,6 +100,9 @@ int main(int argc, char **argv)
|
|||
|
||||
/* get the file size of the local file */
|
||||
fp = fopen(file, "rb");
|
||||
if(!fp)
|
||||
return 2;
|
||||
|
||||
fstat(fileno(fp), &file_info);
|
||||
|
||||
/* In Windows, this inits the Winsock stuff */
|
||||
|
|
|
|||
|
|
@ -51,8 +51,10 @@ int main(void)
|
|||
return 1; /* cannot continue */
|
||||
|
||||
/* to get the file size */
|
||||
if(fstat(fileno(fd), &file_info) != 0)
|
||||
if(fstat(fileno(fd), &file_info) != 0) {
|
||||
fclose(fd);
|
||||
return 1; /* cannot continue */
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
|
|
|
|||
|
|
@ -49,9 +49,15 @@ int main(void)
|
|||
|
||||
/* local filename to store the file as */
|
||||
ftpfile = fopen(FTPBODY, "wb"); /* b is binary, needed on Windows */
|
||||
if(!ftpfile)
|
||||
return 1;
|
||||
|
||||
/* local filename to store the FTP server's response lines in */
|
||||
respfile = fopen(FTPHEADERS, "wb"); /* b is binary, needed on Windows */
|
||||
if(!respfile) {
|
||||
fclose(ftpfile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
|
|
|
|||
|
|
@ -91,6 +91,8 @@ int main(void)
|
|||
|
||||
/* get a FILE * of the same file */
|
||||
hd_src = fopen(LOCAL_FILE, "rb");
|
||||
if(!hd_src)
|
||||
return 2;
|
||||
|
||||
/* In Windows, this inits the Winsock stuff */
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ int main(int argc, char **argv)
|
|||
fdopen() from the previous descriptor, but hey this is just
|
||||
an example! */
|
||||
hd_src = fopen(file, "rb");
|
||||
if(!hd_src)
|
||||
return 2;
|
||||
|
||||
/* In Windows, this inits the Winsock stuff */
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ int main(void)
|
|||
#endif
|
||||
|
||||
headerfile = fopen(pHeaderFile, "wb");
|
||||
if(!headerfile)
|
||||
return 1;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
|
|
@ -146,5 +148,7 @@ int main(void)
|
|||
|
||||
curl_global_cleanup();
|
||||
|
||||
fclose(headerfile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue