src: Prefer #ifdef for a single condition

This commit is contained in:
Tatsuhiro Tsujikawa 2021-10-15 22:29:05 +09:00
parent 9fb05d5ea2
commit c790ee64a4
6 changed files with 15 additions and 15 deletions

View File

@ -304,7 +304,7 @@ read_quic_secret_file(const StringRef &path) {
FILE *open_file_for_write(const char *filename) {
std::array<char, STRERROR_BUFSIZE> errbuf;
#if defined O_CLOEXEC
#ifdef O_CLOEXEC
auto fd = open(filename, O_WRONLY | O_CLOEXEC | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR);
#else

View File

@ -503,9 +503,9 @@ int Connection::tls_handshake() {
// routine. We have to check HTTP/2 requirement if HTTP/2 was
// negotiated before sending finished message to the peer.
if ((rv != 1
#if defined(OPENSSL_IS_BORINGSSL)
#ifdef OPENSSL_IS_BORINGSSL
|| SSL_in_init(tls.ssl)
#endif // defined(OPENSSL_IS_BORINGSSL)
#endif // OPENSSL_IS_BORINGSSL
) &&
tls.wbuf.rleft()) {
// First write indicates that resumption stuff has done.
@ -543,7 +543,7 @@ int Connection::tls_handshake() {
return SHRPX_ERR_INPROGRESS;
}
#if defined(OPENSSL_IS_BORINGSSL)
#ifdef OPENSSL_IS_BORINGSSL
if (!tlsconf.no_postpone_early_data && SSL_in_early_data(tls.ssl) &&
SSL_in_init(tls.ssl)) {
auto nread = SSL_read(tls.ssl, buf.data(), buf.size());
@ -575,7 +575,7 @@ int Connection::tls_handshake() {
return SHRPX_ERR_INPROGRESS;
}
}
#endif // defined(OPENSSL_IS_BORINGSSL)
#endif // OPENSSL_IS_BORINGSSL
// Handshake was done
@ -613,7 +613,7 @@ int Connection::write_tls_pending_handshake() {
tls.wbuf.drain(nwrite);
}
#if defined(OPENSSL_IS_BORINGSSL)
#ifdef OPENSSL_IS_BORINGSSL
if (!SSL_in_init(tls.ssl)) {
// This will send a session ticket.
auto nwrite = SSL_write(tls.ssl, "", 0);
@ -641,7 +641,7 @@ int Connection::write_tls_pending_handshake() {
}
}
}
#endif // defined(OPENSSL_IS_BORINGSSL)
#endif // OPENSSL_IS_BORINGSSL
// We have to start read watcher, since later stage of code expects
// this.

View File

@ -964,7 +964,7 @@ int open_log_file(const char *path) {
strcmp(path, "/proc/self/fd/2") == 0) {
return STDERR_COPY;
}
#if defined O_CLOEXEC
#ifdef O_CLOEXEC
auto fd = open(path, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC,
S_IRUSR | S_IWUSR | S_IRGRP);

View File

@ -2648,7 +2648,7 @@ int time_t_from_asn1_time(time_t &t, const ASN1_TIME *at) {
return -1;
}
# if defined(OPENSSL_IS_BORINGSSL)
# ifdef OPENSSL_IS_BORINGSSL
char *s;
# else
unsigned char *s;

View File

@ -26,20 +26,20 @@
# include <openssl/opensslv.h>
# if defined(LIBRESSL_VERSION_NUMBER)
# ifdef LIBRESSL_VERSION_NUMBER
# define OPENSSL_1_1_API 0
# define OPENSSL_1_1_1_API 0
# define OPENSSL_3_0_0_API 0
# define LIBRESSL_IN_USE 1
# define LIBRESSL_LEGACY_API (LIBRESSL_VERSION_NUMBER < 0x20700000L)
# define LIBRESSL_2_7_API (LIBRESSL_VERSION_NUMBER >= 0x20700000L)
# else // !defined(LIBRESSL_VERSION_NUMBER)
# else // !LIBRESSL_VERSION_NUMBER
# define OPENSSL_1_1_API (OPENSSL_VERSION_NUMBER >= 0x1010000fL)
# define OPENSSL_1_1_1_API (OPENSSL_VERSION_NUMBER >= 0x10101000L)
# define OPENSSL_3_0_0_API (OPENSSL_VERSION_NUMBER >= 0x30000000L)
# define LIBRESSL_IN_USE 0
# define LIBRESSL_LEGACY_API 0
# define LIBRESSL_2_7_API 0
# endif // !defined(LIBRESSL_VERSION_NUMBER)
# endif // !LIBRESSL_VERSION_NUMBER
#endif // OPENSSL_COMPAT_H

View File

@ -1649,7 +1649,7 @@ std::mt19937 make_mt19937() {
}
int daemonize(int nochdir, int noclose) {
#if defined(__APPLE__)
#ifdef __APPLE__
pid_t pid;
pid = fork();
if (pid == -1) {
@ -1683,9 +1683,9 @@ int daemonize(int nochdir, int noclose) {
}
}
return 0;
#else // !defined(__APPLE__)
#else // !__APPLE__
return daemon(nochdir, noclose);
#endif // !defined(__APPLE__)
#endif // !__APPLE__
}
#ifdef ENABLE_HTTP3