From patchwork Thu Mar 26 21:24:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 1262388 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=crudebyte.com header.i=@crudebyte.com header.a=rsa-sha256 header.s=lizzy header.b=lbTBwCWT; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48pKTd1Fcdz9sR4 for ; Fri, 27 Mar 2020 09:31:33 +1100 (AEDT) Received: from localhost ([::1]:33588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHb2A-0007Cq-R4 for incoming@patchwork.ozlabs.org; Thu, 26 Mar 2020 18:31:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55798) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHb15-0006ek-A2 for qemu-devel@nongnu.org; Thu, 26 Mar 2020 18:30:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHb13-0007ZC-Vv for qemu-devel@nongnu.org; Thu, 26 Mar 2020 18:30:23 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:60355) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHb13-0006G6-Or for qemu-devel@nongnu.org; Thu, 26 Mar 2020 18:30:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=YBRAdZSum7slsAPGovqqlyFqpgUjqJhoi03R04g10bk=; b=lbTBw CWT0n02DHIYTX3FR5TnpEPETUKcriFZiMarMLKCuV2DWKxg0KUrd4tkkCjEcIGdLk+5EBux+ZpPZw llqCfefva1zj9yyHiWXC6/YgAKFlrpb7SOnucVcpiFy9wE5FVvauWJvuWd0mZUGqXopaBwzu/dTGn b9DfbdJI+2F83tPdAwZjv96dZMUrXBpqE61n+oQQW4J7TbyyVetb/GZw4rPAJWFhO6sMAI/l9e3Pm 5hPdkIg/j3tmcaxPyhRTIbezUHEqi8lC70GMp75jeJ/iPinut07cTkLl/gCySnSH+Sjth9uEpbAIa pTRDkAzrzVo41PQo1fEJqEScN6UZQ==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 26 Mar 2020 22:24:37 +0100 Subject: [PATCH v5 2/6] 9pfs readdir: rename max_count -> maxsize To: qemu-devel@nongnu.org Cc: Greg Kurz X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 91.194.90.13 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Although the 9p protocol specs use the term 'max_count' as argument for Treaddir, let's rename our variables for that to 'maxsize' instead, because 'max_count' is semantically completely wrong. This variable does not count integral entries, it is rather a maximum size (in bytes) of the destination (response) buffer being filled. Since this is just refactoring, hence this patch does not introduce any behaviour change at all. Signed-off-by: Christian Schoenebeck --- hw/9pfs/9p.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 9e046f7acb..1aff4f1fa8 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -2162,7 +2162,7 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp, static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, V9fsFidState *fidp, - uint32_t max_count) + uint32_t maxsize) { V9fsPath path; V9fsStat v9stat; @@ -2199,7 +2199,7 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, if (err < 0) { break; } - if ((count + v9stat.size + 2) > max_count) { + if ((count + v9stat.size + 2) > maxsize) { v9fs_readdir_unlock(&fidp->fs.dir); /* Ran out of buffer. Set dir back to old position and return */ @@ -2332,7 +2332,7 @@ static size_t v9fs_readdir_data_size(V9fsString *name) } static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, - int32_t max_count) + int32_t maxsize) { size_t size; V9fsQID qid; @@ -2357,7 +2357,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, } v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); - if ((count + v9fs_readdir_data_size(&name)) > max_count) { + if ((count + v9fs_readdir_data_size(&name)) > maxsize) { v9fs_readdir_unlock(&fidp->fs.dir); /* Ran out of buffer. Set dir back to old position and return */ @@ -2432,20 +2432,20 @@ static void coroutine_fn v9fs_readdir(void *opaque) size_t offset = 7; uint64_t initial_offset; int32_t count; - uint32_t max_count; + uint32_t maxsize; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; retval = pdu_unmarshal(pdu, offset, "dqd", &fid, - &initial_offset, &max_count); + &initial_offset, &maxsize); if (retval < 0) { goto out_nofid; } - trace_v9fs_readdir(pdu->tag, pdu->id, fid, initial_offset, max_count); + trace_v9fs_readdir(pdu->tag, pdu->id, fid, initial_offset, maxsize); /* Enough space for a R_readdir header: size[4] Rreaddir tag[2] count[4] */ - if (max_count > s->msize - 11) { - max_count = s->msize - 11; + if (maxsize > s->msize - 11) { + maxsize = s->msize - 11; warn_report_once( "9p: bad client: T_readdir with count > msize - 11" ); @@ -2465,7 +2465,7 @@ static void coroutine_fn v9fs_readdir(void *opaque) } else { v9fs_co_seekdir(pdu, fidp, initial_offset); } - count = v9fs_do_readdir(pdu, fidp, max_count); + count = v9fs_do_readdir(pdu, fidp, maxsize); if (count < 0) { retval = count; goto out;