From owner-svn-src-head@freebsd.org Tue May 29 10:29:44 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EDB21F70418; Tue, 29 May 2018 10:29:43 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F82C82672; Tue, 29 May 2018 10:29:43 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 672C51ABA5; Tue, 29 May 2018 10:29:43 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4TAThdd040237; Tue, 29 May 2018 10:29:43 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4TAThKj040236; Tue, 29 May 2018 10:29:43 GMT (envelope-from des@FreeBSD.org) Message-Id: <201805291029.w4TAThKj040236@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Tue, 29 May 2018 10:29:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334319 - head/lib/libfetch X-SVN-Group: head X-SVN-Commit-Author: des X-SVN-Commit-Paths: head/lib/libfetch X-SVN-Commit-Revision: 334319 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2018 10:29:44 -0000 Author: des Date: Tue May 29 10:29:43 2018 New Revision: 334319 URL: https://svnweb.freebsd.org/changeset/base/334319 Log: Fix a few (but far from all) style issues. MFC after: 3 weeks Modified: head/lib/libfetch/http.c Modified: head/lib/libfetch/http.c ============================================================================== --- head/lib/libfetch/http.c Tue May 29 10:29:04 2018 (r334318) +++ head/lib/libfetch/http.c Tue May 29 10:29:43 2018 (r334319) @@ -780,9 +780,9 @@ http_parse_authenticate(const char *cp, http_auth_chal goto out; } init_http_auth_challenge(cs->challenges[cs->count]); - if (!strcasecmp(key, "basic")) { + if (strcasecmp(key, "basic") == 0) { cs->challenges[cs->count]->scheme = HTTPAS_BASIC; - } else if (!strcasecmp(key, "digest")) { + } else if (strcasecmp(key, "digest") == 0) { cs->challenges[cs->count]->scheme = HTTPAS_DIGEST; } else { cs->challenges[cs->count]->scheme = HTTPAS_UNKNOWN; @@ -811,25 +811,27 @@ http_parse_authenticate(const char *cp, http_auth_chal if (lex != HTTPHL_WORD && lex != HTTPHL_STRING) goto out; - if (!strcasecmp(key, "realm")) + if (strcasecmp(key, "realm") == 0) { cs->challenges[cs->count]->realm = - strdup(value); - else if (!strcasecmp(key, "qop")) + strdup(value); + } else if (strcasecmp(key, "qop") == 0) { cs->challenges[cs->count]->qop = - strdup(value); - else if (!strcasecmp(key, "nonce")) + strdup(value); + } else if (strcasecmp(key, "nonce") == 0) { cs->challenges[cs->count]->nonce = - strdup(value); - else if (!strcasecmp(key, "opaque")) + strdup(value); + } else if (strcasecmp(key, "opaque") == 0) { cs->challenges[cs->count]->opaque = - strdup(value); - else if (!strcasecmp(key, "algorithm")) + strdup(value); + } else if (strcasecmp(key, "algorithm") == 0) { cs->challenges[cs->count]->algo = - strdup(value); - else if (!strcasecmp(key, "stale")) + strdup(value); + } else if (strcasecmp(key, "stale") == 0) { cs->challenges[cs->count]->stale = - strcasecmp(value, "no"); - /* Else ignore unknown attributes */ + strcasecmp(value, "no"); + } else { + /* ignore unknown attributes */ + } /* Comma or Next challenge or End */ lex = http_header_lex(&cp, key); @@ -1262,8 +1264,8 @@ http_digest_auth(conn_t *conn, const char *hdr, http_a c->algo = strdup(""); if (asprintf(&options, "%s%s%s%s", - *c->algo? ",algorithm=" : "", c->algo, - c->opaque? ",opaque=" : "", c->opaque?c->opaque:"")== -1) + *c->algo? ",algorithm=" : "", c->algo, + c->opaque? ",opaque=" : "", c->opaque?c->opaque:"") < 0) return (-1); if (!c->qop) { @@ -1349,8 +1351,8 @@ http_authorize(conn_t *conn, const char *hdr, http_aut } /* Error if "Digest" was specified and there is no Digest challenge */ - if (!digest && (parms->scheme && - !strcasecmp(parms->scheme, "digest"))) { + if (!digest && + (parms->scheme && strcasecmp(parms->scheme, "digest") == 0)) { DEBUGF("Digest auth in env, not supported by peer\n"); return (-1); } @@ -1359,7 +1361,8 @@ http_authorize(conn_t *conn, const char *hdr, http_aut * challenge, do the basic thing. Don't need a challenge for this, * so no need to check basic!=NULL */ - if (!digest || (parms->scheme && !strcasecmp(parms->scheme,"basic"))) + if (!digest || + (parms->scheme && strcasecmp(parms->scheme, "basic") == 0)) return (http_basic_auth(conn,hdr,parms->user,parms->password)); /* Else, prefer digest. We just checked that it's not NULL */ @@ -1851,11 +1854,12 @@ http_request_body(struct url *URL, const char *op, str if (new) free(new); if (verbose) - fetch_info("%d redirect to %s", conn->err, p); + fetch_info("%d redirect to %s", + conn->err, p); if (*p == '/') /* absolute path */ - new = fetchMakeURL(url->scheme, url->host, url->port, p, - url->user, url->pwd); + new = fetchMakeURL(url->scheme, url->host, + url->port, p, url->user, url->pwd); else new = fetchParseURL(p); if (new == NULL) { @@ -1865,7 +1869,8 @@ http_request_body(struct url *URL, const char *op, str } /* Only copy credentials if the host matches */ - if (!strcmp(new->host, url->host) && !*new->user && !*new->pwd) { + if (strcmp(new->host, url->host) == 0 && + !*new->user && !*new->pwd) { strcpy(new->user, url->user); strcpy(new->pwd, url->pwd); }