From patchwork Wed Feb 20 02:19:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 221943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BF0D72C0091 for ; Wed, 20 Feb 2013 13:19:21 +1100 (EST) Received: from localhost ([::1]:53078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7zHD-0001Am-UV for incoming@patchwork.ozlabs.org; Tue, 19 Feb 2013 21:19:19 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7zH3-0001AF-TG for qemu-devel@nongnu.org; Tue, 19 Feb 2013 21:19:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U7zH2-0004In-4K for qemu-devel@nongnu.org; Tue, 19 Feb 2013 21:19:09 -0500 Received: from mail-vb0-f48.google.com ([209.85.212.48]:48478) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7zH2-0004IM-04 for qemu-devel@nongnu.org; Tue, 19 Feb 2013 21:19:08 -0500 Received: by mail-vb0-f48.google.com with SMTP id fc21so4628368vbb.21 for ; Tue, 19 Feb 2013 18:19:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=RMYbTlV9sxZCyJNKg5b2CHA8JKEdF/7JcQ3vFVJzB+0=; b=T0c0hB+WMwPdXzl7vQoTY8kGekvsxrAfNUdWhIkszDkY0RQMV6NdMWqJSRIQg+zSQS WBdT0EdIBHi/LhR0nL2U8TSbxaHB34sKE/DNfiNj531oo/NmhJBiqUqqTY+0a2s9nfuP A+P+1wRpkT437t+uJ29uGwvGDQ49QtbsiegTppw3N0PnEN3f56cmCX/DynKrT+eHYJ4N 3jE2ShmUDx9xSbZEDgUAd6vLmNl0O4nTTB7/p7nju0/uKcAcTdDjM/tohhS86vrlTUiv vGg37Tu2THv0L5iH3dL/1a8JwTUj4JA7vL21sT/V3D3NWnTX598aHgjiphdNqvsaoWfl yQAg== MIME-Version: 1.0 X-Received: by 10.52.18.235 with SMTP id z11mr20738061vdd.39.1361326747307; Tue, 19 Feb 2013 18:19:07 -0800 (PST) Received: by 10.220.232.201 with HTTP; Tue, 19 Feb 2013 18:19:07 -0800 (PST) In-Reply-To: <51233955.9090500@redhat.com> References: <076e2799-0389-4bc2-ae53-717a9f89206a@TX2EHSMHS042.ehs.local> <5114BA5F.8030606@msgid.tls.msk.ru> <51233955.9090500@redhat.com> Date: Wed, 20 Feb 2013 12:19:07 +1000 X-Google-Sender-Auth: IHo0QhIeTdoTxJ8uJLmJvis-0YI Message-ID: From: Peter Crosthwaite To: Gerd Hoffmann X-Gm-Message-State: ALoCoQkqRHp2dPzFym5GWmB7X9yerj2RW/Fk8yciWotKm/G5lsqhaq/NMoWFL47flJPcg41loRLq X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.212.48 Cc: vineshp@xilinx.com, peter.maydell@linaro.org, aliguori@us.ibm.com, i.mitsyanko@samsung.com, stefanha@gmail.com, Michael Tokarev , qemu-devel@nongnu.org, jues@xilinx.com, edgar.iglesias@gmail.com, afaerber@suse.de Subject: Re: [Qemu-devel] [PATCH v9 1/3] iov: Factor out hexdumper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 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-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Tue, Feb 19, 2013 at 6:35 PM, Gerd Hoffmann wrote: > Hi, > >> I ran git blame on it and its actually Gerds code. Gerd you want >> co-authorship and the (c) of this hexdump.c? > > Yes. > > And don't break iov_hexdump() behavior please. I suggest to just > iov_to_buf() into a temporary buffer, then pass that to a single hexdump > call. Done, thanks for the correction. Do you have a lightweight test vector that exercises this? The iovec stuff in my areas is all limited to single iovec element. Interdiff below. Regards, Peter When calling hexdump for each iovec element the buffer offsets > printed are wrong for all but the first iovec element. > > cheers, > Gerd > > diff --git a/util/hexdump.c b/util/hexdump.c index 0bf0f38..0d0efc8 100644 --- a/util/hexdump.c +++ b/util/hexdump.c @@ -1,12 +1,11 @@ /* * Helper to hexdump a buffer * + * Copyright (c) 2013 Red Hat, Inc. + * Copyright (c) 2013 Gerd Hoffmann * Copyright (c) 2013 Peter Crosthwaite * Copyright (c) 2013 Xilinx, Inc * - * Based on git commit 3a1dca94d6dba00fe0fd4c4a28449f57e01b9b6c - * Author: Gerd Hoffmann - * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. * diff --git a/util/iov.c b/util/iov.c index 91d79ae..99f0b50 100644 --- a/util/iov.c +++ b/util/iov.c @@ -202,11 +202,16 @@ void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt, FILE *fp, const char *prefix, size_t limit) { int v; - for (v = 0; v < iov_cnt && limit; v++) { - int size = limit < iov[v].iov_len ? limit : iov[v].iov_len; - hexdump(iov[v].iov_base, fp, prefix, size); - limit -= size; + size_t size = 0; + char *buf; + + for (v = 0; v < iov_cnt; v++) { + size += iov[v].iov_len; } + size = size > limit ? limit : size; + buf = g_malloc(size); + iov_to_buf(iov, iov_cnt, 0, buf, size); + g_free(buf); }