From patchwork Tue Jul 9 07:40:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11036579 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1D4B1395 for ; Tue, 9 Jul 2019 07:42:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC6F9286C6 for ; Tue, 9 Jul 2019 07:42:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF934286D5; Tue, 9 Jul 2019 07:42:34 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 6530C286C6 for ; Tue, 9 Jul 2019 07:42:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3DC430C132C; Tue, 9 Jul 2019 07:42:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8E745C2F3; Tue, 9 Jul 2019 07:42:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1315941F53; Tue, 9 Jul 2019 07:42:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x697fvJn031139 for ; Tue, 9 Jul 2019 03:41:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 489DC53E20; Tue, 9 Jul 2019 07:41:57 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B988418A56; Tue, 9 Jul 2019 07:41:54 +0000 (UTC) Received: from m9a0001g.houston.softwaregrp.com (m9a0001g.houston.softwaregrp.com [15.124.64.66]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8EAF9A3B6E; Tue, 9 Jul 2019 07:41:39 +0000 (UTC) Received: FROM m9a0001g.houston.softwaregrp.com (15.121.0.191) BY m9a0001g.houston.softwaregrp.com WITH ESMTP; Tue, 9 Jul 2019 07:41:43 +0000 Received: from M4W0334.microfocus.com (2002:f78:1192::f78:1192) by M9W0068.microfocus.com (2002:f79:bf::f79:bf) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Tue, 9 Jul 2019 07:40:02 +0000 Received: from NAM01-BY2-obe.outbound.protection.outlook.com (15.124.8.11) by M4W0334.microfocus.com (15.120.17.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10 via Frontend Transport; Tue, 9 Jul 2019 07:40:02 +0000 Received: from CH2PR18MB3349.namprd18.prod.outlook.com (52.132.246.91) by CH2PR18MB3319.namprd18.prod.outlook.com (52.132.246.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.18; Tue, 9 Jul 2019 07:40:01 +0000 Received: from CH2PR18MB3349.namprd18.prod.outlook.com ([fe80::8818:7a86:93d7:561a]) by CH2PR18MB3349.namprd18.prod.outlook.com ([fe80::8818:7a86:93d7:561a%6]) with mapi id 15.20.2052.020; Tue, 9 Jul 2019 07:40:01 +0000 From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Thread-Topic: [PATCH 1/4] libmultipath: make vector_foreach_slot_backwards work as expected Thread-Index: AQHVNimDUxYQLNpEdEa0CRBeYYtu6w== Date: Tue, 9 Jul 2019 07:40:01 +0000 Message-ID: <20190709073909.32112-2-martin.wilck@suse.com> References: <20190709073909.32112-1-martin.wilck@suse.com> In-Reply-To: <20190709073909.32112-1-martin.wilck@suse.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6P192CA0014.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:83::27) To CH2PR18MB3349.namprd18.prod.outlook.com (2603:10b6:610:2c::27) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Martin.Wilck@suse.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [94.218.227.174] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 79d86345-1d44-420c-0350-08d70440a630 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:CH2PR18MB3319; x-ms-traffictypediagnostic: CH2PR18MB3319: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 0093C80C01 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(979002)(4636009)(376002)(346002)(366004)(136003)(396003)(39860400002)(189003)(199004)(386003)(14444005)(52116002)(6506007)(6512007)(107886003)(110136005)(81166006)(81156014)(478600001)(54906003)(8936002)(26005)(2616005)(256004)(6436002)(4326008)(72206003)(6486002)(316002)(76176011)(102836004)(5660300002)(36756003)(44832011)(4744005)(66556008)(66476007)(73956011)(1076003)(66446008)(7736002)(305945005)(6116002)(3846002)(486006)(68736007)(14454004)(86362001)(66066001)(99286004)(66946007)(64756008)(71190400001)(71200400001)(476003)(53936002)(186003)(11346002)(2906002)(8676002)(50226002)(25786009)(446003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:CH2PR18MB3319; H:CH2PR18MB3349.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: suse.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 9cBslYuHZW4efMQfSRK2JDBgnrfjlK+r/3M4eyjL6T5Q5LCcR223cgtrjjmNfOADAT5+hd7Vbt0xncGgTlu8rkluwsyvkOR8L6nRmHepUB6bx4O6XFg3hlqwIh00W5vJtvyFX6l8e7Uo2a+575Evw666TWOP0OtbySeGcBbr405FR5lm3teTp6v4Vy39MAI+mhGVcqZ3gVQzTuOBUUMtNqQOL8ZEEnhDERb+i6cuUNDpx9Gam+T9HGI+4fRexQWedAeoEM1k5OzTBlMle/CT3NCVlu0oVr10xh7k0D1sv2N0GaxYyXPHKpxsREIyeQR/iGYQjoGph/pZcw+PoQzgJ7IPS47e70sDa+QxBKcWb5tuRf1SfPqzANOY9HVghhdGPVPhotOTOHvef1CdsKTgLON+8tRbYbhqHZ+oZgNP3zw= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 79d86345-1d44-420c-0350-08d70440a630 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2019 07:40:01.2994 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 856b813c-16e5-49a5-85ec-6f081e13b527 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Martin.Wilck@suse.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR18MB3319 X-OriginatorOrg: suse.com X-Greylist: Sender passed SPF test, ACL 243 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 09 Jul 2019 07:41:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 09 Jul 2019 07:41:45 +0000 (UTC) for IP:'15.124.64.66' DOMAIN:'m9a0001g.houston.softwaregrp.com' HELO:'m9a0001g.houston.softwaregrp.com' FROM:'Martin.Wilck@suse.com' RCPT:'' X-RedHat-Spam-Score: 0.001 (SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY) 15.124.64.66 m9a0001g.houston.softwaregrp.com 15.124.64.66 m9a0001g.houston.softwaregrp.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id x697fvJn031139 X-loop: dm-devel@redhat.com Cc: "dm-devel@redhat.com" , Martin Wilck Subject: [dm-devel] [PATCH 1/4] libmultipath: make vector_foreach_slot_backwards work as expected 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 09 Jul 2019 07:42:33 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP From: Benjamin Marzinski All of the code that uses vector_foreach_slot_backwards() treats "i" as the index of the entry "p", but the way it was coded, that wasn't the case. "i" was the number of the entry counting from 1, not 0. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/vector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmultipath/vector.h b/libmultipath/vector.h index 41d2b896..344dffd5 100644 --- a/libmultipath/vector.h +++ b/libmultipath/vector.h @@ -40,7 +40,7 @@ typedef struct _vector *vector; #define vector_foreach_slot_after(v,p,i) \ for (; (v) && i < VECTOR_SIZE(v) && ((p) = (v)->slot[i]); i++) #define vector_foreach_slot_backwards(v,p,i) \ - for (i = VECTOR_SIZE(v); i > 0 && ((p) = (v)->slot[i-1]); i--) + for (i = VECTOR_SIZE(v) - 1; (int)i >= 0 && ((p) = (v)->slot[i]); i--) #define identity(x) (x) /*