From nobody Mon Feb 9 16:21:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510093977969921.1361373656647; Tue, 7 Nov 2017 14:32:57 -0800 (PST) Received: from localhost ([::1]:56093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCCQ6-0003if-8S for importer@patchew.org; Tue, 07 Nov 2017 17:32:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCCLM-00007x-6O for qemu-devel@nongnu.org; Tue, 07 Nov 2017 17:27:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCCLL-0004bj-18 for qemu-devel@nongnu.org; Tue, 07 Nov 2017 17:27:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCCLA-0004Bv-Qs; Tue, 07 Nov 2017 17:27:29 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF83D883B4; Tue, 7 Nov 2017 22:27:27 +0000 (UTC) Received: from localhost (ovpn-122-234.rdu2.redhat.com [10.10.122.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 984A25D9C9; Tue, 7 Nov 2017 22:27:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DF83D883B4 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jcody@redhat.com From: Jeff Cody To: qemu-devel@nongnu.org Date: Tue, 7 Nov 2017 17:27:19 -0500 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 07 Nov 2017 22:27:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 2/7] block/ssh: make compliant with coding guidelines X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-block@nongnu.org, mitake.hitoshi@lab.ntt.co.jp, rjones@redhat.com, namei.unix@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jeff Cody Reviewed-by: Eric Blake Reviewed-by: Darren Kenny Reviewed-by: Richard W.M. Jones --- block/ssh.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/block/ssh.c b/block/ssh.c index de81ec8..39cacc1 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -241,7 +241,7 @@ static int parse_uri(const char *filename, QDict *optio= ns, Error **errp) goto err; } =20 - if(uri->user && strcmp(uri->user, "") !=3D 0) { + if (uri->user && strcmp(uri->user, "") !=3D 0) { qdict_put_str(options, "user", uri->user); } =20 @@ -268,7 +268,7 @@ static int parse_uri(const char *filename, QDict *optio= ns, Error **errp) =20 err: if (uri) { - uri_free(uri); + uri_free(uri); } return -EINVAL; } @@ -342,7 +342,7 @@ static int check_host_key_knownhosts(BDRVSSHState *s, libssh2_knownhost_readfile(knh, knh_file, LIBSSH2_KNOWNHOST_FILE_OPENS= SH); =20 r =3D libssh2_knownhost_checkp(knh, host, port, hostkey, len, - LIBSSH2_KNOWNHOST_TYPE_PLAIN| + LIBSSH2_KNOWNHOST_TYPE_PLAIN | LIBSSH2_KNOWNHOST_KEYENC_RAW, &found); switch (r) { @@ -405,15 +405,18 @@ static int compare_fingerprint(const unsigned char *f= ingerprint, size_t len, unsigned c; =20 while (len > 0) { - while (*host_key_check =3D=3D ':') + while (*host_key_check =3D=3D ':') { host_key_check++; + } if (!qemu_isxdigit(host_key_check[0]) || - !qemu_isxdigit(host_key_check[1])) + !qemu_isxdigit(host_key_check[1])) { return 1; + } c =3D hex2decimal(host_key_check[0]) * 16 + hex2decimal(host_key_check[1]); - if (c - *fingerprint !=3D 0) + if (c - *fingerprint !=3D 0) { return c - *fingerprint; + } fingerprint++; len--; host_key_check +=3D 2; @@ -433,8 +436,8 @@ check_host_key_hash(BDRVSSHState *s, const char *hash, return -EINVAL; } =20 - if(compare_fingerprint((unsigned char *) fingerprint, fingerprint_len, - hash) !=3D 0) { + if (compare_fingerprint((unsigned char *) fingerprint, fingerprint_len, + hash) !=3D 0) { error_setg(errp, "remote host key does not match host_key_check '%= s'", hash); return -EPERM; @@ -507,7 +510,7 @@ static int authenticate(BDRVSSHState *s, const char *us= er, Error **errp) goto out; } =20 - for(;;) { + for (;;) { r =3D libssh2_agent_get_identity(agent, &identity, prev_identity); if (r =3D=3D 1) { /* end of list */ break; @@ -860,8 +863,8 @@ static int ssh_create(const char *filename, QemuOpts *o= pts, Error **errp) } =20 r =3D connect_to_ssh(&s, uri_options, - LIBSSH2_FXF_READ|LIBSSH2_FXF_WRITE| - LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC, + LIBSSH2_FXF_READ | LIBSSH2_FXF_WRITE | + LIBSSH2_FXF_CREAT | LIBSSH2_FXF_TRUNC, 0644, errp); if (r < 0) { ret =3D r; @@ -869,7 +872,7 @@ static int ssh_create(const char *filename, QemuOpts *o= pts, Error **errp) } =20 if (total_size > 0) { - libssh2_sftp_seek64(s.sftp_handle, total_size-1); + libssh2_sftp_seek64(s.sftp_handle, total_size - 1); r2 =3D libssh2_sftp_write(s.sftp_handle, c, 1); if (r2 < 0) { sftp_error_setg(errp, &s, "truncate failed"); @@ -1108,7 +1111,7 @@ static int ssh_write(BDRVSSHState *s, BlockDriverStat= e *bs, * works for me. */ if (r =3D=3D 0) { - ssh_seek(s, offset + written, SSH_SEEK_WRITE|SSH_SEEK_FORCE); + ssh_seek(s, offset + written, SSH_SEEK_WRITE | SSH_SEEK_FORCE); co_yield(s, bs); goto again; } @@ -1122,8 +1125,9 @@ static int ssh_write(BDRVSSHState *s, BlockDriverStat= e *bs, end_of_vec =3D i->iov_base + i->iov_len; } =20 - if (offset + written > s->attrs.filesize) + if (offset + written > s->attrs.filesize) { s->attrs.filesize =3D offset + written; + } } =20 return 0; --=20 2.9.5