Copilot commented on code in PR #13197:
URL: https://github.com/apache/trafficserver/pull/13197#discussion_r3306639996
##########
src/iocore/net/TLSCertCompression.cc:
##########
@@ -53,70 +55,81 @@ struct alg_info {
ssl_cert_decompression_func_t decompress_func;
#endif
} supported_algs[] = {
- {"zlib", 1,
#if HAVE_SSL_CTX_ADD_CERT_COMPRESSION_ALG
- compression_func_zlib, decompression_func_zlib
-#endif
- },
+ {"zlib", 1, compression_func_zlib, decompression_func_zlib },
#if HAVE_BROTLI_ENCODE_H
- {"brotli", 2,
-#if HAVE_SSL_CTX_ADD_CERT_COMPRESSION_ALG
- compression_func_brotli, decompression_func_brotli
-#endif
- },
+ {"brotli", 2, compression_func_brotli, decompression_func_brotli},
#endif
#if HAVE_ZSTD_H
- {"zstd", 3,
-#if HAVE_SSL_CTX_ADD_CERT_COMPRESSION_ALG
- compression_func_zstd, decompression_func_zstd
+ {"zstd", 3, compression_func_zstd, decompression_func_zstd },
+#endif
+ {nullptr, 0, nullptr, nullptr },
+#else
+#if HAVE_SSL_CTX_SET1_CERT_COMP_PREFERENCE && !defined(OPENSSL_NO_ZLIB)
+ {"zlib", 1},
+#endif
+#if HAVE_SSL_CTX_SET1_CERT_COMP_PREFERENCE && !defined(OPENSSL_NO_BROTLI)
+ {"brotli", 2},
#endif
- },
+#if HAVE_SSL_CTX_SET1_CERT_COMP_PREFERENCE && !defined(OPENSSL_NO_ZSTD)
+ {"zstd", 3},
+#endif
+ {nullptr, 0},
#endif
};
+alg_info const *
+find_algorithm(std::string const &name)
+{
+ for (auto const &alg : supported_algs) {
+ if (alg.name != nullptr && name == alg.name) {
+ return &alg;
+ }
+ }
+ return nullptr;
Review Comment:
`find_algorithm()` is a TU-local helper but currently has external linkage
(non-`static` and not in an anonymous namespace). This unnecessarily exports a
global symbol and increases the risk of name collisions at link time. Make the
function `static` (or move it into the existing anonymous namespace) so it has
internal linkage.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]