diff options
author | Viktor Szakats <commit@vsz.me> | 2025-02-27 11:32:43 +0100 |
---|---|---|
committer | Viktor Szakats <commit@vsz.me> | 2025-02-28 13:11:41 +0100 |
commit | 08c7c937dc0dbd1f92f73360e5d8b2bb2ee6afa8 (patch) | |
tree | cb080c4ae67182d142f2d55b690d9b9f4e0d053e /docs/examples/htmltitle.cpp | |
parent | 2e585f564004e473b0163092fb687e051cec14ec (diff) |
tidy-up: prefer `return` over `exit()`, fix fallouts
To avoid breaking the control flow and align to majority of code
already using `return`.
`exit()` has the side-effect of suppressing leak detection in cases.
Fix fallouts detected after switching to `return`.
- configure:
- fix `getaddrinfo` run test to call `freeaddrinfo()` to pacify ASAN,
and call `WSACleanup()` to deinit winsock2.
- fix `getifaddrs` run test to call `freeifaddrs()` to pacify ASAN.
- tests/server:
- setup `atexit(win32_cleanup)` via `win32_init()`.
- return 2 instead of 1 on winsock2 init failures.
- sws: goto cleanup instead of `exit()` in `http_connect()`.
Follow-up to 02dfe7193704817184b522888ffa926e6b73f648 #7235
- tests/client/http:
- cleanup memory to pacify ASAN in `h2-upgrade-extreme`,
`tls-session-reuse`.
- examples:
- block_ip: fix memory leak reported by CI.
- http2-upload: avoid handle leaks.
Untouched `exit()` calls, made from callbacks:
- docs/examples: ephiperfifo.c, ghiper.c, hiperfifo.c
- tests/libtest: lib582.c, lib655.c, lib670.c
- tests/server: tftpd.c
Closes #16507
Diffstat (limited to 'docs/examples/htmltitle.cpp')
-rw-r--r-- | docs/examples/htmltitle.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/examples/htmltitle.cpp b/docs/examples/htmltitle.cpp index f8a463a78..52dbdf153 100644 --- a/docs/examples/htmltitle.cpp +++ b/docs/examples/htmltitle.cpp @@ -94,7 +94,7 @@ static bool init(CURL *&conn, const char *url) if(conn == NULL) { fprintf(stderr, "Failed to create CURL connection\n"); - exit(EXIT_FAILURE); + return false; } code = curl_easy_setopt(conn, CURLOPT_ERRORBUFFER, errorBuffer); @@ -270,7 +270,7 @@ int main(int argc, char *argv[]) if(argc != 2) { fprintf(stderr, "Usage: %s <url>\n", argv[0]); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } curl_global_init(CURL_GLOBAL_DEFAULT); @@ -279,7 +279,7 @@ int main(int argc, char *argv[]) if(!init(conn, argv[1])) { fprintf(stderr, "Connection initialization failed\n"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } // Retrieve content for the URL @@ -289,7 +289,7 @@ int main(int argc, char *argv[]) if(code != CURLE_OK) { fprintf(stderr, "Failed to get '%s' [%s]\n", argv[1], errorBuffer); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } // Parse the (assumed) HTML code |