From 08d92cdb0477c4a226cb16ebc060beb735d447fc Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 28 Jul 2013 04:38:43 +0200 Subject: [PATCH 1/1] Simplify str(n)cmp() if conditions. --- src/connection.c | 8 ++++---- src/verify.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/connection.c b/src/connection.c index 710963c..316339e 100644 --- a/src/connection.c +++ b/src/connection.c @@ -186,7 +186,7 @@ void handle_connection(int client_socket) { } /* Check response of proxy server. */ - if (strncmp(buffer, "HTTP/1.0 200", 12) != 0) { + if (strncmp(buffer, "HTTP/1.0 200", 12)) { LOG(LOG_WARNING, "bad proxy response: %s", buffer); send_forwarding_failure(client_fd); goto out; @@ -357,7 +357,7 @@ static int initialize_tls_session_client(int peer_socket, /* The "invalid" hostname is special. If it's used we send an invalid * certificate to let the client know something is wrong. */ - use_invalid_cert = (strcmp(hostname, "invalid") == 0); + use_invalid_cert = (!strcmp(hostname, "invalid")); if (proxy_certificate_path(hostname, path, sizeof(path)) != 0) { LOG(LOG_ERROR, @@ -514,7 +514,7 @@ static int read_http_request(FILE *client_fd, char *request, size_t length) { while (fgets(buffer, sizeof(buffer), client_fd) != NULL) { /* End of header. */ - if (strcmp(buffer, "\n") == 0 || strcmp(buffer, "\r\n") == 0) { + if (!strcmp(buffer, "\n") || !strcmp(buffer, "\r\n")) { break; } } @@ -821,7 +821,7 @@ static int parse_request(const char *request, char *host, char *port, char *position; /* scanf() doesn't check spaces. */ - if (strncmp(request, "CONNECT ", 8) != 0) { + if (strncmp(request, "CONNECT ", 8)) { return -1; } /* Check request and extract data, "host:port" is not yet separated. */ diff --git a/src/verify.c b/src/verify.c index 96c49a5..2b49f1d 100644 --- a/src/verify.c +++ b/src/verify.c @@ -148,7 +148,7 @@ int verify_tls_connection(gnutls_session_t session, const char *hostname) { fclose(file); /* Check if the server certificate matches our stored certificate. */ - if (strcmp(stored_cert, server_cert) != 0) { + if (strcmp(stored_cert, server_cert)) { LOG(LOG_ERROR, "verify_tls_connection(): server certificate changed!", path, strerror(errno)); -- 2.44.1