diff options
author | Nicolas Noble <nicolasnoble@users.noreply.github.com> | 2015-03-07 17:22:20 -0800 |
---|---|---|
committer | Nicolas Noble <nicolasnoble@users.noreply.github.com> | 2015-03-07 17:22:20 -0800 |
commit | 75c60c1a43a2b2a7b21967d7ea6d2dda5a351348 (patch) | |
tree | e1a64c2292d313ca08dea9288c7fc55b108b0db2 /src/core | |
parent | 3631e82c890de1ff0382ab3062b2d05193604046 (diff) | |
parent | 2ad8d21158df8b9a7e37b0a966f76b52a61f25e6 (diff) |
Merge pull request #981 from sahlberg/231
strcmp: change all !str[n]cmp to str[n]cmp == 0
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/iomgr/resolve_address_posix.c | 2 | ||||
-rw-r--r-- | src/core/security/credentials.c | 12 | ||||
-rw-r--r-- | src/core/security/google_default_credentials.c | 4 | ||||
-rw-r--r-- | src/core/security/json_token.c | 2 | ||||
-rw-r--r-- | src/core/security/security_context.c | 4 | ||||
-rw-r--r-- | src/core/security/server_secure_chttp2.c | 6 | ||||
-rw-r--r-- | src/core/tsi/fake_transport_security.c | 4 | ||||
-rw-r--r-- | src/core/tsi/ssl_transport_security.c | 5 | ||||
-rw-r--r-- | src/core/tsi/transport_security.c | 2 |
9 files changed, 21 insertions, 20 deletions
diff --git a/src/core/iomgr/resolve_address_posix.c b/src/core/iomgr/resolve_address_posix.c index 85085dc37d..9a9283c93c 100644 --- a/src/core/iomgr/resolve_address_posix.c +++ b/src/core/iomgr/resolve_address_posix.c @@ -109,7 +109,7 @@ grpc_resolved_addresses *grpc_blocking_resolve_address( }; int i; for (i = 0; i < (int)(sizeof(svc) / sizeof(svc[0])); i++) { - if (!strcmp(port, svc[i][0])) { + if (strcmp(port, svc[i][0]) == 0) { s = getaddrinfo(host, svc[i][1], &hints, &result); break; } diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c index 7e72b238c8..3ad1e7edd7 100644 --- a/src/core/security/credentials.c +++ b/src/core/security/credentials.c @@ -348,7 +348,7 @@ static void jwt_get_request_metadata(grpc_credentials *creds, { gpr_mu_lock(&c->cache_mu); if (c->cached.service_url != NULL && - !strcmp(c->cached.service_url, service_url) && + strcmp(c->cached.service_url, service_url) == 0 && c->cached.jwt_md != NULL && (gpr_time_cmp(gpr_time_sub(c->cached.jwt_expiration, gpr_now()), refresh_threshold) > 0)) { @@ -957,7 +957,7 @@ static grpc_credentials_array get_creds_array(grpc_credentials **creds_addr) { grpc_credentials *creds = *creds_addr; result.creds_array = creds_addr; result.num_creds = 1; - if (!strcmp(creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE)) { + if (strcmp(creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE) == 0) { result = *grpc_composite_credentials_get_credentials(creds); } return result; @@ -995,7 +995,7 @@ const grpc_credentials_array *grpc_composite_credentials_get_credentials( grpc_credentials *creds) { const grpc_composite_credentials *c = (const grpc_composite_credentials *)creds; - GPR_ASSERT(!strcmp(creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE)); + GPR_ASSERT(strcmp(creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE) == 0); return &c->inner; } @@ -1003,14 +1003,14 @@ grpc_credentials *grpc_credentials_contains_type( grpc_credentials *creds, const char *type, grpc_credentials **composite_creds) { size_t i; - if (!strcmp(creds->type, type)) { + if (strcmp(creds->type, type) == 0) { if (composite_creds != NULL) *composite_creds = NULL; return creds; - } else if (!strcmp(creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE)) { + } else if (strcmp(creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE) == 0) { const grpc_credentials_array *inner_creds_array = grpc_composite_credentials_get_credentials(creds); for (i = 0; i < inner_creds_array->num_creds; i++) { - if (!strcmp(type, inner_creds_array->creds_array[i]->type)) { + if (strcmp(type, inner_creds_array->creds_array[i]->type) == 0) { if (composite_creds != NULL) *composite_creds = creds; return inner_creds_array->creds_array[i]; } diff --git a/src/core/security/google_default_credentials.c b/src/core/security/google_default_credentials.c index dc0e453b87..bdc907e7b3 100644 --- a/src/core/security/google_default_credentials.c +++ b/src/core/security/google_default_credentials.c @@ -75,8 +75,8 @@ static void on_compute_engine_detection_http_response( size_t i; for (i = 0; i < response->hdr_count; i++) { grpc_httpcli_header *header = &response->hdrs[i]; - if (!strcmp(header->key, "Metadata-Flavor") && - !strcmp(header->value, "Google")) { + if (strcmp(header->key, "Metadata-Flavor") == 0 && + strcmp(header->value, "Google") == 0) { detector->success = 1; break; } diff --git a/src/core/security/json_token.c b/src/core/security/json_token.c index 26d57036a6..40b612b206 100644 --- a/src/core/security/json_token.c +++ b/src/core/security/json_token.c @@ -257,7 +257,7 @@ static char *dot_concat_and_free_strings(char *str1, char *str2) { } const EVP_MD *openssl_digest_from_algorithm(const char *algorithm) { - if (!strcmp(algorithm, GRPC_JWT_RSA_SHA256_ALGORITHM)) { + if (strcmp(algorithm, GRPC_JWT_RSA_SHA256_ALGORITHM) == 0) { return EVP_sha256(); } else { gpr_log(GPR_ERROR, "Unknown algorithm %s.", algorithm); diff --git a/src/core/security/security_context.c b/src/core/security/security_context.c index 62264e4105..e180cad52b 100644 --- a/src/core/security/security_context.c +++ b/src/core/security/security_context.c @@ -421,7 +421,7 @@ static grpc_security_status ssl_channel_check_call_host( /* If the target name was overridden, then the original target_name was 'checked' transitively during the previous peer check at the end of the handshake. */ - if (c->overridden_target_name != NULL && !strcmp(host, c->target_name)) { + if (c->overridden_target_name != NULL && strcmp(host, c->target_name) == 0) { return GRPC_SECURITY_OK; } else { return GRPC_SECURITY_ERROR; @@ -610,7 +610,7 @@ grpc_channel *grpc_ssl_channel_create(grpc_credentials *ssl_creds, for (i = 0; args && i < args->num_args; i++) { grpc_arg *arg = &args->args[i]; - if (!strcmp(arg->key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) && + if (strcmp(arg->key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == 0 && arg->type == GRPC_ARG_STRING) { overridden_target_name = arg->value.string; break; diff --git a/src/core/security/server_secure_chttp2.c b/src/core/security/server_secure_chttp2.c index b15c553b82..c155b80b7e 100644 --- a/src/core/security/server_secure_chttp2.c +++ b/src/core/security/server_secure_chttp2.c @@ -139,11 +139,11 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr, grp /* create security context */ if (creds == NULL) goto error; - if (!strcmp(creds->type, GRPC_CREDENTIALS_TYPE_SSL)) { + if (strcmp(creds->type, GRPC_CREDENTIALS_TYPE_SSL) == 0) { status = grpc_ssl_server_security_context_create( grpc_ssl_server_credentials_get_config(creds), &ctx); - } else if (!strcmp(creds->type, - GRPC_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY)) { + } else if (strcmp(creds->type, + GRPC_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY) == 0) { ctx = grpc_fake_server_security_context_create(); status = GRPC_SECURITY_OK; } diff --git a/src/core/tsi/fake_transport_security.c b/src/core/tsi/fake_transport_security.c index f58f04ea20..9ce1ddb95e 100644 --- a/src/core/tsi/fake_transport_security.c +++ b/src/core/tsi/fake_transport_security.c @@ -102,8 +102,8 @@ static tsi_result tsi_fake_handshake_message_from_string( const char* msg_string, tsi_fake_handshake_message* msg) { int i; for (i = 0; i < TSI_FAKE_HANDSHAKE_MESSAGE_MAX; i++) { - if (!strncmp(msg_string, tsi_fake_handshake_message_strings[i], - strlen(tsi_fake_handshake_message_strings[i]))) { + if (strncmp(msg_string, tsi_fake_handshake_message_strings[i], + strlen(tsi_fake_handshake_message_strings[i])) == 0) { *msg = i; return TSI_OK; } diff --git a/src/core/tsi/ssl_transport_security.c b/src/core/tsi/ssl_transport_security.c index dc43f7e270..33645ca8b8 100644 --- a/src/core/tsi/ssl_transport_security.c +++ b/src/core/tsi/ssl_transport_security.c @@ -1083,7 +1083,8 @@ static int does_entry_match_name(const char* entry, size_t entry_length, if (entry_length == 0) return 0; } - if ((name_length == entry_length) && !strncmp(name, entry, entry_length)) { + if ((name_length == entry_length) && + strncmp(name, entry, entry_length) == 0) { return 1; /* Perfect match. */ } if (entry[0] != '*') return 0; @@ -1110,7 +1111,7 @@ static int does_entry_match_name(const char* entry, size_t entry_length, name_subdomain_length--; } return ((entry_length > 0) && (name_subdomain_length == entry_length) && - !strncmp(entry, name_subdomain, entry_length)); + strncmp(entry, name_subdomain, entry_length) == 0); } static int ssl_server_handshaker_factory_servername_callback(SSL* ssl, int* ap, diff --git a/src/core/tsi/transport_security.c b/src/core/tsi/transport_security.c index c8c74c5de5..f4ab9d2bc6 100644 --- a/src/core/tsi/transport_security.c +++ b/src/core/tsi/transport_security.c @@ -208,7 +208,7 @@ const tsi_peer_property* tsi_peer_get_property_by_name(const tsi_peer* self, return property; } if (name != NULL && property->name != NULL && - !strcmp(property->name, name)) { + strcmp(property->name, name) == 0) { return property; } } |