From: Viktor Szakats Date: Tue, 25 Feb 2025 13:38:41 +0000 (+0100) Subject: build: set `-O3` and tune WinCE in CI, fix `getpart`, `vtls_scache` fallouts X-Git-Tag: curl-8_13_0~332 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c028a243f2edfc64fa7e3199261e277104a3be98;p=thirdparty%2Fcurl.git build: set `-O3` and tune WinCE in CI, fix `getpart`, `vtls_scache` fallouts - GHA/windows/WinCE: - set `-O3 -DNDEBUG` C flags manually for the CMake mingw32ce build. CMake doesn't recognize the platform and fails to add them. To match autotools (using `-O2`), and hit similar compiler warnings. - enable parallel builds for cmake. - tune parallelism for cmake using unity batches. - tune parallelism for autotools. Follow-up to 2a292c39846107228201674d686be5b3ed96674d #15975 - tests: fix potentially uninitialized value in `readline()` in `getpart.c`. Detected by gcc 4.4.0 `-O2` (Windows CE) jobs: ``` tests/server/getpart.c: In function 'getpart': tests/server/getpart.c:298: error: 'datalen' may be used uninitialized in this function ``` Ref: https://github.com/curl/curl/actions/runs/13522595237/job/37785147505?pr=16476#step:11:25 Follow-up to 592880a3caf0b6f48b1dda6fbcf6a734237fcd43 - vtls_scache: rework returning pointer to avoid compiler warning seen with `-O3` gcc 4.4.0 builds (Windows CE/schannel): ``` lib/vtls/schannel.c: In function 'schannel_connect_step1': lib/vtls/vtls_scache.c:975: error: dereferencing pointer 'old_cred.4474' does break strict-aliasing rules lib/vtls/vtls_scache.c:985: error: dereferencing pointer 'old_cred.4474' does break strict-aliasing rules lib/vtls/schannel.c:959: note: initialized from here ``` Ref: https://github.com/curl/curl/actions/runs/13523868335/job/37789610845#step:9:25 Follow-up to fa0ccd9f1fbbbd77bf50b26e3ba231ea6c729474 #15774 Closes #16476 --- diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 991935c753..670265146a 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -593,6 +593,7 @@ jobs: timeout-minutes: 10 env: toolchain-version: '0.59.1' + MAKEFLAGS: -j 4 strategy: matrix: build: [autotools, cmake] @@ -629,12 +630,13 @@ jobs: -DCMAKE_SYSTEM_NAME=WindowsCE \ -DCMAKE_SYSTEM_VERSION=8.0 \ -DCMAKE_SYSTEM_PROCESSOR=arm \ + -DCMAKE_C_FLAGS='-O3 -DNDEBUG' \ -DCMAKE_C_COMPILER_TARGET=arm-mingw32ce \ -DCMAKE_C_COMPILER=arm-mingw32ce-gcc \ -DCMAKE_RC_COMPILER=arm-mingw32ce-windres \ -DMINGW32CE_LIBRARY_DIR="$HOME/opt/mingw32ce/arm-mingw32ce/lib" \ -DCMAKE_IGNORE_PREFIX_PATH="$(brew --prefix)" \ - -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \ + -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=50 -DCURL_TEST_BUNDLES=ON \ -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_STATIC_CURL=OFF \ -DCURL_WERROR=ON \ -DCURL_USE_SCHANNEL=ON \ @@ -663,7 +665,7 @@ jobs: if [ '${{ matrix.build }}' = 'cmake' ]; then cmake --build bld else - make -j5 -C bld + make -C bld fi - name: 'curl info' @@ -677,7 +679,7 @@ jobs: if [ '${{ matrix.build }}' = 'cmake' ]; then cmake --build bld --target testdeps else - make -j5 -C bld -C tests + make -C bld -C tests fi - name: 'build examples' @@ -687,7 +689,7 @@ jobs: if [ '${{ matrix.build }}' = 'cmake' ]; then cmake --build bld --target curl-examples else - make -j5 -C bld examples + make -C bld examples fi msvc: diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index 8c6fa06982..e05196e475 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -898,7 +898,6 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) unsigned char alpn_buffer[128]; #endif SECURITY_STATUS sspi_status = SEC_E_OK; - struct Curl_schannel_cred *old_cred = NULL; CURLcode result; DEBUGASSERT(backend); @@ -955,9 +954,10 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) /* check for an existing reusable credential handle */ if(ssl_config->primary.cache_session) { + struct Curl_schannel_cred *old_cred; Curl_ssl_scache_lock(data); - if(Curl_ssl_scache_get_obj(cf, data, connssl->peer.scache_key, - (void **)&old_cred)) { + old_cred = Curl_ssl_scache_get_obj(cf, data, connssl->peer.scache_key); + if(old_cred) { backend->cred = old_cred; DEBUGF(infof(data, "schannel: reusing existing credential handle")); diff --git a/lib/vtls/sectransp.c b/lib/vtls/sectransp.c index 25d5874e09..9e98b15a9f 100644 --- a/lib/vtls/sectransp.c +++ b/lib/vtls/sectransp.c @@ -1333,8 +1333,9 @@ static CURLcode sectransp_connect_step1(struct Curl_cfilter *cf, size_t ssl_sessionid_len; Curl_ssl_scache_lock(data); - if(Curl_ssl_scache_get_obj(cf, data, connssl->peer.scache_key, - (void **)&ssl_sessionid)) { + ssl_sessionid = Curl_ssl_scache_get_obj(cf, data, + connssl->peer.scache_key); + if(ssl_sessionid) { /* we got a session id, use it! */ err = SSLSetPeerID(backend->ssl_ctx, ssl_sessionid, strlen(ssl_sessionid)); diff --git a/lib/vtls/vtls_scache.c b/lib/vtls/vtls_scache.c index f93eecd2ae..7118affb88 100644 --- a/lib/vtls/vtls_scache.c +++ b/lib/vtls/vtls_scache.c @@ -962,31 +962,29 @@ out: return result; } -bool Curl_ssl_scache_get_obj(struct Curl_cfilter *cf, - struct Curl_easy *data, - const char *ssl_peer_key, - void **sobj) +void *Curl_ssl_scache_get_obj(struct Curl_cfilter *cf, + struct Curl_easy *data, + const char *ssl_peer_key) { struct Curl_ssl_scache *scache = cf_ssl_scache_get(data); struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf); struct Curl_ssl_scache_peer *peer = NULL; CURLcode result; + void *sobj; - *sobj = NULL; if(!scache) - return FALSE; + return NULL; result = cf_ssl_find_peer_by_key(data, scache, ssl_peer_key, conn_config, &peer); if(result) - return FALSE; + return NULL; - if(peer) - *sobj = peer->sobj; + sobj = peer ? peer->sobj : NULL; CURL_TRC_SSLS(data, "%s cached session for '%s'", - *sobj ? "Found" : "No", ssl_peer_key); - return !!*sobj; + sobj ? "Found" : "No", ssl_peer_key); + return sobj; } void Curl_ssl_scache_remove_all(struct Curl_cfilter *cf, diff --git a/lib/vtls/vtls_scache.h b/lib/vtls/vtls_scache.h index b42873f787..c3188ebbd1 100644 --- a/lib/vtls/vtls_scache.h +++ b/lib/vtls/vtls_scache.h @@ -85,12 +85,11 @@ void Curl_ssl_scache_unlock(struct Curl_easy *data); * @param cf the connection filter wanting to use it * @param data the transfer involved * @param ssl_peer_key the key for lookup - * @param sobj on return, the object for the peer key or NULL + * @retval sobj the object for the peer key or NULL */ -bool Curl_ssl_scache_get_obj(struct Curl_cfilter *cf, - struct Curl_easy *data, - const char *ssl_peer_key, - void **sobj); +void *Curl_ssl_scache_get_obj(struct Curl_cfilter *cf, + struct Curl_easy *data, + const char *ssl_peer_key); typedef void Curl_ssl_scache_obj_dtor(void *sobj); diff --git a/tests/server/getpart.c b/tests/server/getpart.c index b48db7f0d0..6bf6cc5d6d 100644 --- a/tests/server/getpart.c +++ b/tests/server/getpart.c @@ -130,8 +130,10 @@ static int readline(char **buffer, size_t *bufsize, size_t *length, for(;;) { int bytestoread = curlx_uztosi(*bufsize - offset); - if(!fgets(*buffer + offset, bytestoread, stream)) + if(!fgets(*buffer + offset, bytestoread, stream)) { + *length = 0; return (offset != 0) ? GPE_OK : GPE_END_OF_FILE; + } *length = offset + line_length(*buffer + offset, bytestoread); if(*(*buffer + *length - 1) == '\n')