From: Jay Satiro Date: Tue, 21 Feb 2023 04:28:14 +0000 (-0500) Subject: sectransp: fix compiler warning c89 mixed code/declaration X-Git-Tag: curl-8_0_0~167 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=47129b2b4be50d829ffcfed8de18a9249a56a7d0;p=thirdparty%2Fcurl.git sectransp: fix compiler warning c89 mixed code/declaration Since cbf57176 the Cirrus CI 'macOS arm64 SecureTransport http2' has been failing due to c89 warnings mixed code/declaration. That commit is not the cause so I assume something has changed in the CI outside of our configuration. Anyway, we don't mix code/declaration so this is the fix for that. Closes https://github.com/curl/curl/pull/10574 --- diff --git a/lib/vtls/sectransp.c b/lib/vtls/sectransp.c index 2e98169e26..b84d888608 100644 --- a/lib/vtls/sectransp.c +++ b/lib/vtls/sectransp.c @@ -2202,16 +2202,18 @@ static int append_cert_to_array(struct Curl_easy *data, const unsigned char *buf, size_t buflen, CFMutableArrayRef array) { - CFDataRef certdata = CFDataCreate(kCFAllocatorDefault, buf, buflen); char *certp; CURLcode result; + SecCertificateRef cacert; + CFDataRef certdata; + + certdata = CFDataCreate(kCFAllocatorDefault, buf, buflen); if(!certdata) { failf(data, "SSL: failed to allocate array for CA certificate"); return CURLE_OUT_OF_MEMORY; } - SecCertificateRef cacert = - SecCertificateCreateWithData(kCFAllocatorDefault, certdata); + cacert = SecCertificateCreateWithData(kCFAllocatorDefault, certdata); CFRelease(certdata); if(!cacert) { failf(data, "SSL: failed to create SecCertificate from CA certificate"); @@ -2425,11 +2427,15 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data, do { SecTrustRef trust; - OSStatus ret = SSLCopyPeerTrust(ctx, &trust); + OSStatus ret; + SecKeyRef keyRef; + OSStatus success; + + ret = SSLCopyPeerTrust(ctx, &trust); if(ret != noErr || !trust) break; - SecKeyRef keyRef = SecTrustCopyPublicKey(trust); + keyRef = SecTrustCopyPublicKey(trust); CFRelease(trust); if(!keyRef) break; @@ -2443,8 +2449,8 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data, #elif SECTRANSP_PINNEDPUBKEY_V2 - OSStatus success = SecItemExport(keyRef, kSecFormatOpenSSL, 0, NULL, - &publicKeyBits); + success = SecItemExport(keyRef, kSecFormatOpenSSL, 0, NULL, + &publicKeyBits); CFRelease(keyRef); if(success != errSecSuccess || !publicKeyBits) break; @@ -2987,12 +2993,13 @@ static CURLcode sectransp_connect_step3(struct Curl_cfilter *cf, struct Curl_easy *data) { struct ssl_connect_data *connssl = cf->ctx; + CURLcode result; DEBUGF(LOG_CF(data, cf, "connect_step3")); /* There is no step 3! * Well, okay, let's collect server certificates, and if verbose mode is on, * let's print the details of the server certificates. */ - const CURLcode result = collect_server_cert(cf, data); + result = collect_server_cert(cf, data); if(result) return result;