src: Add static to constexpr char[]

This commit is contained in:
Tatsuhiro Tsujikawa 2017-09-20 23:53:42 +09:00
parent c23fc86a23
commit cc6f759190
3 changed files with 8 additions and 6 deletions

View File

@ -84,7 +84,7 @@ int exec_read_command(Process &proc, char *const argv[]) {
rv = shrpx_signal_unblock_all(); rv = shrpx_signal_unblock_all();
if (rv != 0) { if (rv != 0) {
constexpr char msg[] = "Unblocking all signals failed\n"; static constexpr char msg[] = "Unblocking all signals failed\n";
while (write(STDERR_FILENO, msg, str_size(msg)) == -1 && errno == EINTR) while (write(STDERR_FILENO, msg, str_size(msg)) == -1 && errno == EINTR)
; ;
nghttp2_Exit(EXIT_FAILURE); nghttp2_Exit(EXIT_FAILURE);
@ -95,7 +95,7 @@ int exec_read_command(Process &proc, char *const argv[]) {
rv = execv(argv[0], argv); rv = execv(argv[0], argv);
if (rv == -1) { if (rv == -1) {
constexpr char msg[] = "Could not execute command\n"; static constexpr char msg[] = "Could not execute command\n";
while (write(STDERR_FILENO, msg, str_size(msg)) == -1 && errno == EINTR) while (write(STDERR_FILENO, msg, str_size(msg)) == -1 && errno == EINTR)
; ;
nghttp2_Exit(EXIT_FAILURE); nghttp2_Exit(EXIT_FAILURE);

View File

@ -70,7 +70,7 @@ void test_shrpx_tls_create_lookup_tree(void) {
CU_ASSERT(-1 == tree->lookup(StringRef{})); CU_ASSERT(-1 == tree->lookup(StringRef{}));
CU_ASSERT(5 == tree->lookup(hostnames[5])); CU_ASSERT(5 == tree->lookup(hostnames[5]));
CU_ASSERT(6 == tree->lookup(hostnames[6])); CU_ASSERT(6 == tree->lookup(hostnames[6]));
constexpr char h6[] = "pdylay.sourceforge.net"; static constexpr char h6[] = "pdylay.sourceforge.net";
for (int i = 0; i < 7; ++i) { for (int i = 0; i < 7; ++i) {
CU_ASSERT(-1 == tree->lookup(StringRef{h6 + i, str_size(h6) - i})); CU_ASSERT(-1 == tree->lookup(StringRef{h6 + i, str_size(h6) - i}));
} }
@ -119,7 +119,8 @@ void test_shrpx_tls_create_lookup_tree(void) {
void test_shrpx_tls_cert_lookup_tree_add_ssl_ctx(void) { void test_shrpx_tls_cert_lookup_tree_add_ssl_ctx(void) {
int rv; int rv;
constexpr char nghttp2_certfile[] = NGHTTP2_SRC_DIR "/test.nghttp2.org.pem"; static constexpr char nghttp2_certfile[] =
NGHTTP2_SRC_DIR "/test.nghttp2.org.pem";
auto nghttp2_ssl_ctx = SSL_CTX_new(SSLv23_server_method()); auto nghttp2_ssl_ctx = SSL_CTX_new(SSLv23_server_method());
auto nghttp2_ssl_ctx_del = defer(SSL_CTX_free, nghttp2_ssl_ctx); auto nghttp2_ssl_ctx_del = defer(SSL_CTX_free, nghttp2_ssl_ctx);
auto nghttp2_tls_ctx_data = make_unique<tls::TLSContextData>(); auto nghttp2_tls_ctx_data = make_unique<tls::TLSContextData>();
@ -129,7 +130,8 @@ void test_shrpx_tls_cert_lookup_tree_add_ssl_ctx(void) {
CU_ASSERT(1 == rv); CU_ASSERT(1 == rv);
constexpr char examples_certfile[] = NGHTTP2_SRC_DIR "/test.example.com.pem"; static constexpr char examples_certfile[] =
NGHTTP2_SRC_DIR "/test.example.com.pem";
auto examples_ssl_ctx = SSL_CTX_new(SSLv23_server_method()); auto examples_ssl_ctx = SSL_CTX_new(SSLv23_server_method());
auto examples_ssl_ctx_del = defer(SSL_CTX_free, examples_ssl_ctx); auto examples_ssl_ctx_del = defer(SSL_CTX_free, examples_ssl_ctx);
auto examples_tls_ctx_data = make_unique<tls::TLSContextData>(); auto examples_tls_ctx_data = make_unique<tls::TLSContextData>();

View File

@ -716,7 +716,7 @@ template <typename OutputIt, typename Generator>
OutputIt random_alpha_digit(OutputIt first, OutputIt last, Generator &gen) { OutputIt random_alpha_digit(OutputIt first, OutputIt last, Generator &gen) {
// If we use uint8_t instead char, gcc 6.2.0 complains by shouting // If we use uint8_t instead char, gcc 6.2.0 complains by shouting
// char-array initialized from wide string. // char-array initialized from wide string.
constexpr char s[] = static constexpr char s[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
std::uniform_int_distribution<> dis(0, 26 * 2 + 10 - 1); std::uniform_int_distribution<> dis(0, 26 * 2 + 10 - 1);
for (; first != last; ++first) { for (; first != last; ++first) {