From patchwork Sun Oct 9 13:31:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugene Syromyatnikov X-Patchwork-Id: 9369119 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2730460487 for ; Mon, 10 Oct 2016 08:33:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 194FA29325 for ; Mon, 10 Oct 2016 08:33:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E52F2933B; Mon, 10 Oct 2016 08:33:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A3D4029325 for ; Mon, 10 Oct 2016 08:33:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9A8Uird036855; Mon, 10 Oct 2016 04:30:44 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u99DVSpr017015 for ; Sun, 9 Oct 2016 09:31:28 -0400 Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u99DVS1C012931 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 9 Oct 2016 09:31:28 -0400 Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50677C03BD5C; Sun, 9 Oct 2016 13:31:27 +0000 (UTC) Received: by mail-lf0-f65.google.com with SMTP id p80so5476167lfp.1; Sun, 09 Oct 2016 06:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=0ggsHt/XHSnJhJnDwNBG2uhejLWrGPDTnRwJlcy4WYU=; b=irE5rPTKmG4S62QuPpB1bfso69N4SgC6J4B1SE005XYlqqlIugdC/eivmDX9Fectlq 1LaKv6rhCaTOqhsUk02F3UA8M3j/xTlLZa3h9CZyYL6qGay18JmPS/JAUX+QbM3mCV98 gjUYcSjN4u1Nyl3rUHSwRK0jGEZ0ouK/uQfHK5M/P7gF9FAvKd5tBsohEW7soUi2X80D sOFI8KY2+iYJQ1qmOOv9Jehow6xp0m0a5lvomkYGQn70igFa/lROhGBZDf4AChlE8T+X XgR360Qkpu6jCHfcta48Agr3N9Ba2IhCw+8ThtNX74onxM4Khp8Jwu3+AHX3KMSwx6FI fZmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=0ggsHt/XHSnJhJnDwNBG2uhejLWrGPDTnRwJlcy4WYU=; b=Ms1k43HAMhN/piX01AGaGiM1W1R+JWN5GSJ5Vzxa2bUGgAkEy/WwgktFfOdZmFqH4f GhWTq/+qZc0kR3DYRzQoAz9PjHPYIlrLeMCUAQFf7wBdy8nv/shvpalLTHjhTwwp9AcU YgAcqAwJimkOMXS0h0KKPhnf/9VoqAqZ95ivGKMkEUU8kieSxXtT+uk1cBI3gh7MOBiy /bV5aHDjI9QzIaubO7KoQVh+Y5SFrvbNxAiIfR5AbDmJq42yDJtpV8sM20j1Fqp4mWa7 zSC3i/Lt752w3l5bmgF3H0G4eQ/mZMIYA5OWY5iAvaLtoXkogahShHJJSBllRLZu0fQu hdMg== X-Gm-Message-State: AA6/9Rmb30XH2zQVmARNCJrtEAIT0YLWW7nfG5mhHYptLqd8WuqLdbUbnycLZmcq/zWygw== X-Received: by 10.25.158.143 with SMTP id h137mr12163257lfe.83.1476019885417; Sun, 09 Oct 2016 06:31:25 -0700 (PDT) Received: from obsidian (broadband-46-188-15-144.2com.net. [46.188.15.144]) by smtp.gmail.com with ESMTPSA id n14sm5181396lfn.7.2016.10.09.06.31.24 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 09 Oct 2016 06:31:24 -0700 (PDT) Date: Sun, 9 Oct 2016 16:31:22 +0300 From: Eugene Syromyatnikov To: strace-devel@lists.sourceforge.net Message-ID: <20161009133122.GA4364@obsidian> References: <20161005.192828.566127461630656590.yamato@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161005.192828.566127461630656590.yamato@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 09 Oct 2016 13:31:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 09 Oct 2016 13:31:27 +0000 (UTC) for IP:'209.85.215.65' DOMAIN:'mail-lf0-f65.google.com' HELO:'mail-lf0-f65.google.com' FROM:'evgsyr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.67 (BAYES_50, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.215.65 mail-lf0-f65.google.com 209.85.215.65 mail-lf0-f65.google.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Mon, 10 Oct 2016 04:29:54 -0400 Cc: dm-devel@redhat.com, mpatocka@redhat.com, yamato@redhat.com Subject: [dm-devel] [PATCH 18/21] tests/ioctl_dm: Allow passing size and data_start to init_s X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP --- tests/ioctl_dm.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/tests/ioctl_dm.c b/tests/ioctl_dm.c index 6967ca2..c120ed2 100644 --- a/tests/ioctl_dm.c +++ b/tests/ioctl_dm.c @@ -21,32 +21,30 @@ static struct s { } u; } s; -static void init_s(void) +static void init_s(struct dm_ioctl *s, size_t size, size_t offs) { - memset(&s, 0, sizeof s); - s.ioc.version[0] = DM_VERSION_MAJOR; - s.ioc.version[1] = 1; - s.ioc.version[2] = 2; - s.ioc.data_size = sizeof(s); - s.ioc.data_start = offsetof(struct s, u); - s.ioc.dev = 0x1234; - strcpy(s.ioc.name, "nnn"); - strcpy(s.ioc.uuid, "uuu"); + memset(s, 0, size); + s->version[0] = DM_VERSION_MAJOR; + s->version[1] = 1; + s->version[2] = 2; + s->data_size = size; + s->data_start = offs; + s->dev = 0x1234; + strcpy(s->name, "nnn"); + strcpy(s->uuid, "uuu"); } int main(void) { - init_s(); - s.ioc.data_size = sizeof(s.ioc); - s.ioc.data_start = 0; + init_s(&s.ioc, sizeof(s.ioc), 0); ioctl(-1, DM_VERSION, &s); printf("ioctl(-1, DM_VERSION, " "{version=4.1.2, data_size=%zu, data_start=0, " "dev=makedev(18, 52), name=\"nnn\", uuid=\"uuu\", flags=0}) = " "-1 EBADF (%m)\n", sizeof(s.ioc)); - init_s(); + init_s(&s.ioc, sizeof(s), offsetof(struct s, u)); s.ioc.target_count = 1; s.u.ts.target_spec.sector_start = 0x10; s.u.ts.target_spec.length = 0x20; @@ -62,7 +60,7 @@ main(void) "length=32, target_type=\"tgt\", string=\"tparams\"}}) = " "-1 EBADF (%m)\n", s.ioc.data_size, s.ioc.data_start); - init_s(); + init_s(&s.ioc, sizeof(s), offsetof(struct s, u)); s.u.tm.target_msg.sector = 0x1234; strcpy(s.u.string + offsetof(struct dm_target_msg, message), "tmsg"); @@ -73,7 +71,7 @@ main(void) "{sector=4660, message=\"tmsg\"}}) = -1 EBADF (%m)\n", s.ioc.data_size, s.ioc.data_start); - init_s(); + init_s(&s.ioc, sizeof(s), offsetof(struct s, u)); strcpy(s.u.string, "10 20 30 40"); ioctl(-1, DM_DEV_SET_GEOMETRY, &s); printf("ioctl(-1, DM_DEV_SET_GEOMETRY, " @@ -82,7 +80,7 @@ main(void) "string=\"10 20 30 40\"}) = -1 EBADF (%m)\n", s.ioc.data_size, s.ioc.data_start); - init_s(); + init_s(&s.ioc, sizeof(s), offsetof(struct s, u)); strcpy(s.u.string, "new-name"); ioctl(-1, DM_DEV_RENAME, &s); printf("ioctl(-1, DM_DEV_RENAME, " @@ -91,7 +89,7 @@ main(void) "flags=0, string=\"new-name\"}) = -1 EBADF (%m)\n", s.ioc.data_size, s.ioc.data_start); - init_s(); + init_s(&s.ioc, sizeof(s), offsetof(struct s, u)); s.ioc.target_count = -1U; ioctl(-1, DM_TABLE_LOAD, &s); printf("ioctl(-1, DM_TABLE_LOAD, "