From patchwork Sun Oct 9 13:28:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugene Syromyatnikov X-Patchwork-Id: 9369113 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 CE10260487 for ; Mon, 10 Oct 2016 08:33:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0CE929325 for ; Mon, 10 Oct 2016 08:33:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5A0A2933B; Mon, 10 Oct 2016 08:33:04 +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 mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (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 09F2F29325 for ; Mon, 10 Oct 2016 08:33:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9A8UZDH053177; Mon, 10 Oct 2016 04:30:35 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u99DShbs016529 for ; Sun, 9 Oct 2016 09:28:43 -0400 Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u99DShfJ028285 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 9 Oct 2016 09:28:43 -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 1A31B85365; Sun, 9 Oct 2016 13:28:42 +0000 (UTC) Received: by mail-lf0-f65.google.com with SMTP id l131so5461471lfl.0; Sun, 09 Oct 2016 06:28:42 -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=hXfq6TNDP4KJMaQJAn9aFXGx6iu5mjNjxrJOwUuEJiQ=; b=ZT8Hzl3keyvKLcdEDMOHlertm/zEB2/nEHgydj4Y0igZRI051hNW8OkZrpon7iiq+s u6RorZJkkRSe/xsDQuCYxfF2u2aVcCGyO4S0K8u5BeFrUHgSKRCjrcLv0gtwzOo41MfX n8L0FWI+qL+VdP6MAAWFDvzc0ul114qV8EpfIgJwvud7BRYk/5AwU6m39j/WtWwDGzJp /yqpV/FFAIKSm0Y+15yqkflYBOeEx+XJhR9FFKaxg2mfqb6l2wc+dEnzu81juLq/seXA vs9kn4qeSlIdg5Qr3zQ40Y5emtC89SyxjoXmVRyj8MkW9WGiEN1oe0kkPrC60yxcgZE1 sknQ== 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=hXfq6TNDP4KJMaQJAn9aFXGx6iu5mjNjxrJOwUuEJiQ=; b=bn5/cfM/ZN8tiU8jPDCPNkvGi2WPxm6pWtg3hoWDEIwRBgqp2TKqDTn4k5ZpsGEyqs 3H7LvYtwKpvFKplKlrfWZkcFOLKCA7v/Xgzew3FmoG88uAwpPO7IhorX5yzYostg6V5B 7lBgEfIUnAzDfkAMOuogDsyXKHjhBjwKbUHkbTPQ4xqEvnbzXAQEUvPLXhjFc2C/2uoX Ci3yCbkgohdquwz9JWXiZFste+rMAz8MRLR7ed0PjrJulHr/dZKgvo989xedAGpGA7pL nGTNMrOzX3CZHWcnKhBvGTfeyUtALdXxs/IBDIU7hPeCvoRLSsFlLfExl+QGMG7hfwl1 0ICQ== X-Gm-Message-State: AA6/9Rn6yTb7VAU41i08GkVYfOPwWw6SijNkgbI66DHYMMZhaxZxXAi/CVlep0vLlji6Ww== X-Received: by 10.25.168.144 with SMTP id r138mr12288816lfe.136.1476019720393; Sun, 09 Oct 2016 06:28:40 -0700 (PDT) Received: from obsidian (broadband-46-188-15-144.2com.net. [46.188.15.144]) by smtp.gmail.com with ESMTPSA id 102sm5153325lft.33.2016.10.09.06.28.39 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 09 Oct 2016 06:28:39 -0700 (PDT) Date: Sun, 9 Oct 2016 16:28:37 +0300 From: Eugene Syromyatnikov To: strace-devel@lists.sourceforge.net Message-ID: <20161009132837.GA1936@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.25]); Sun, 09 Oct 2016 13:28:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 09 Oct 2016 13:28:42 +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.27 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 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 02/21] dm: whitespace fixes 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 --- dm.c | 87 +++++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/dm.c b/dm.c index 33a3972..d81983d 100644 --- a/dm.c +++ b/dm.c @@ -2,8 +2,8 @@ #ifdef HAVE_LINUX_DM_IOCTL_H -#include -#include +# include +# include static void dm_decode_device(const unsigned int code, const struct dm_ioctl *ioc) @@ -38,7 +38,7 @@ dm_decode_values(struct tcb *tcp, const unsigned int code, if (entering(tcp)) { switch (code) { case DM_TABLE_LOAD: - tprintf(", target_count=%"PRIu32"", + tprintf(", target_count=%" PRIu32, ioc->target_count); break; case DM_DEV_SUSPEND: @@ -47,7 +47,7 @@ dm_decode_values(struct tcb *tcp, const unsigned int code, case DM_DEV_RENAME: case DM_DEV_REMOVE: case DM_DEV_WAIT: - tprintf(", event_nr=%"PRIu32"", + tprintf(", event_nr=%" PRIu32, ioc->event_nr); break; } @@ -63,11 +63,11 @@ dm_decode_values(struct tcb *tcp, const unsigned int code, case DM_TABLE_DEPS: case DM_TABLE_STATUS: case DM_TARGET_MSG: - tprintf(", target_count=%"PRIu32"", + tprintf(", target_count=%" PRIu32, ioc->target_count); - tprintf(", open_count=%"PRIu32"", + tprintf(", open_count=%" PRIu32, ioc->open_count); - tprintf(", event_nr=%"PRIu32"", + tprintf(", event_nr=%" PRIu32, ioc->event_nr); break; } @@ -89,21 +89,23 @@ dm_decode_dm_target_spec(struct tcb *tcp, const struct dm_ioctl *ioc, { uint32_t i; uint32_t offset = ioc->data_start; + for (i = 0; i < ioc->target_count; i++) { - if (offset + (uint32_t)sizeof(struct dm_target_spec) >= offset && - offset + (uint32_t)sizeof(struct dm_target_spec) < extra_size) { + if (offset + (uint32_t) sizeof(struct dm_target_spec) >= offset && + offset + (uint32_t) sizeof(struct dm_target_spec) < extra_size) { uint32_t new_offset; const struct dm_target_spec *s = - (const struct dm_target_spec *)(extra + offset); - tprintf(", {sector_start=%"PRIu64", length=%"PRIu64"", - (uint64_t)s->sector_start, (uint64_t)s->length); + (const struct dm_target_spec *) (extra + offset); + tprintf(", {sector_start=%" PRIu64 ", length=%" PRIu64, + (uint64_t) s->sector_start, + (uint64_t) s->length); if (!entering(tcp)) - tprintf(", status=%"PRId32"", s->status); + tprintf(", status=%" PRId32, s->status); tprints(", target_type="); print_quoted_string(s->target_type, DM_MAX_TYPE_NAME, QUOTE_0_TERMINATED); tprints(", string="); - print_quoted_string((const char *)(s + 1), extra_size - + print_quoted_string((const char *) (s + 1), extra_size - (offset + sizeof(struct dm_target_spec)), QUOTE_0_TERMINATED); @@ -112,7 +114,8 @@ dm_decode_dm_target_spec(struct tcb *tcp, const struct dm_ioctl *ioc, new_offset = offset + s->next; else new_offset = ioc->data_start + s->next; - if (new_offset <= offset + (uint32_t)sizeof(struct dm_target_spec)) + if (new_offset <= offset + + (uint32_t) sizeof(struct dm_target_spec)) goto misplaced; offset = new_offset; } else { @@ -128,13 +131,15 @@ dm_decode_dm_target_deps(const struct dm_ioctl *ioc, const char *extra, uint32_t extra_size) { uint32_t offset = ioc->data_start; - if (offset + (uint32_t)offsetof(struct dm_target_deps, dev) >= offset && - offset + (uint32_t)offsetof(struct dm_target_deps, dev) <= extra_size) { + if (offset + (uint32_t) offsetof(struct dm_target_deps, dev) >= offset && + offset + (uint32_t) offsetof(struct dm_target_deps, dev) <= extra_size) { + uint32_t i; uint32_t space = (extra_size - (offset + offsetof(struct dm_target_deps, dev))) / sizeof(__u64); const struct dm_target_deps *s = - (const struct dm_target_deps *)(extra + offset); + (const struct dm_target_deps *) (extra + offset); + if (s->count > space) goto misplaced; tprints(", deps={"); @@ -154,21 +159,25 @@ dm_decode_dm_name_list(const struct dm_ioctl *ioc, const char *extra, uint32_t extra_size) { uint32_t offset = ioc->data_start; + while (1) { - if (offset + (uint32_t)offsetof(struct dm_name_list, name) >= offset && - offset + (uint32_t)offsetof(struct dm_name_list, name) < extra_size) { + if (offset + (uint32_t) offsetof(struct dm_name_list, name) >= offset && + offset + (uint32_t) offsetof(struct dm_name_list, name) < extra_size) { const struct dm_name_list *s = - (const struct dm_name_list *)(extra + offset); + (const struct dm_name_list *) (extra + offset); + if (!s->dev) break; - tprintf(", {dev=makedev(%u, %u), name=", major(s->dev), minor(s->dev)); + tprintf(", {dev=makedev(%u, %u), name=", major(s->dev), + minor(s->dev)); print_quoted_string(s->name, extra_size - (offset + offsetof(struct dm_name_list, name)), QUOTE_0_TERMINATED); tprints("}"); if (!s->next) break; - if (offset + s->next <= offset + (uint32_t)offsetof(struct dm_name_list, name)) + if (offset + s->next <= offset + + (uint32_t) offsetof(struct dm_name_list, name)) goto misplaced; offset = offset + s->next; } else { @@ -184,22 +193,25 @@ dm_decode_dm_target_versions(const struct dm_ioctl *ioc, const char *extra, uint32_t extra_size) { uint32_t offset = ioc->data_start; + while (1) { - if (offset + (uint32_t)offsetof(struct dm_target_versions, name) >= + if (offset + (uint32_t) offsetof(struct dm_target_versions, name) >= offset && - offset + (uint32_t)offsetof(struct dm_target_versions, name) < + offset + (uint32_t) offsetof(struct dm_target_versions, name) < extra_size) { const struct dm_target_versions *s = (const struct dm_target_versions *)(extra + offset); + tprints(", {name="); print_quoted_string(s->name, extra_size - (offset + offsetof(struct dm_target_versions, name)), QUOTE_0_TERMINATED); - tprintf(", version=%"PRIu32".%"PRIu32".%"PRIu32"}", + tprintf(", version=%" PRIu32 ".%" PRIu32 ".%" PRIu32 "}", s->version[0], s->version[1], s->version[2]); if (!s->next) break; - if (offset + s->next <= offset + (uint32_t)offsetof(struct dm_target_versions, name)) + if (offset + s->next <= offset + + (uint32_t) offsetof(struct dm_target_versions, name)) goto misplaced; offset = offset + s->next; } else { @@ -215,11 +227,14 @@ dm_decode_dm_target_msg(const struct dm_ioctl *ioc, const char *extra, uint32_t extra_size) { uint32_t offset = ioc->data_start; - if (offset + (uint32_t)offsetof(struct dm_target_msg, message) >= offset && - offset + (uint32_t)offsetof(struct dm_target_msg, message) < extra_size) { + + if (offset + (uint32_t) offsetof(struct dm_target_msg, message) >= offset && + offset + (uint32_t) offsetof(struct dm_target_msg, message) < extra_size) { const struct dm_target_msg *s = - (const struct dm_target_msg *)(extra + offset); - tprintf(", {sector=%"PRIu64", message=", (uint64_t)s->sector); + (const struct dm_target_msg *) (extra + offset); + + tprintf(", {sector=%" PRIu64 ", message=", + (uint64_t) s->sector); print_quoted_string(s->message, extra_size - offsetof(struct dm_target_msg, message), QUOTE_0_TERMINATED); @@ -234,6 +249,7 @@ dm_decode_string(const struct dm_ioctl *ioc, const char *extra, uint32_t extra_size) { uint32_t offset = ioc->data_start; + if (offset < extra_size) { tprints(", string="); print_quoted_string(extra + offset, extra_size - offset, @@ -250,7 +266,7 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) char *extra = NULL; uint32_t extra_size = 0; - if (umoven(tcp, arg, sizeof(ioc) - sizeof(ioc.data), (char *)&ioc) < 0) + if (umoven(tcp, arg, sizeof(ioc) - sizeof(ioc.data), (char *) &ioc) < 0) return 0; tprintf(", {version=%d.%d.%d", ioc.version[0], ioc.version[1], ioc.version[2]); @@ -276,7 +292,8 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) dm_decode_device(code, &ioc); dm_decode_values(tcp, code, &ioc); dm_decode_flags(&ioc); - if (!abbrev(tcp)) switch (code) { + if (!abbrev(tcp)) + switch (code) { case DM_DEV_WAIT: case DM_TABLE_STATUS: if (entering(tcp) || syserror(tcp)) @@ -308,7 +325,7 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) dm_decode_dm_target_msg(&ioc, extra, extra_size); } else if (!syserror(tcp) && - ioc.flags & DM_DATA_OUT_FLAG) { + ioc.flags & DM_DATA_OUT_FLAG) { dm_decode_string(&ioc, extra, extra_size); } break; @@ -318,7 +335,7 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) break; dm_decode_string(&ioc, extra, extra_size); break; - } + } skip: tprints("}");