From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Tue, 09 Sep 2025 04:29:18 +0200 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uvo6g-000tzo-04 for lore@lore.pengutronix.de; Tue, 09 Sep 2025 04:29:18 +0200 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uvo6f-0004SJ-Cg for lore@pengutronix.de; Tue, 09 Sep 2025 04:29:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=r3mbvHqcBFBXC7prRX0BaLRcR6YmGGwo4l+6doPpYAs=; b=uKwZCUFwIeE2A+4n2zuY6zYb98 DJyAPOzCiTK9vifqJwI9rHwpDrrXHE5rpSVuGCiLWUQnRsXfYFxUkxMPofITfjUsjvO7qtxLq5CDy FlPvDNMTDSf2IfJGaxpcLvHTxFvYdMpoySC8AEykLAV4Z+l8YfdXzoN71Kqs6UOhZmKCJ0g1A3xlf BztmrxikwbVWZm8+wmEqTtFZuaPrCCEoXhqaXOa4RT9zqcZEbJExTmnlnoTN4XEHOH2cDC6ubUyiq 66kNWsH9v2l1fZ/hEXZqNvC6jTMfYM7MJUOIZOMjz/LRDknCWatcGFAMHnMvle/kXUWHMA+pEcE0a 2qC4khrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uvo5v-00000003h3M-1rUd; Tue, 09 Sep 2025 02:28:31 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uvgmd-00000001cKg-1PSP for barebox@lists.infradead.org; Mon, 08 Sep 2025 18:40:09 +0000 Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1uvgma-0001zn-5v; Mon, 08 Sep 2025 20:40:04 +0200 Message-ID: <96736e5f-b1f9-464b-92bd-d6c550245b64@pengutronix.de> Date: Mon, 8 Sep 2025 20:40:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Tobias Waldekranz , barebox@lists.infradead.org References: <20250828150637.2222474-1-tobias@waldekranz.com> <20250828150637.2222474-3-tobias@waldekranz.com> <8c5841c8-cbe4-4aab-8c5b-c75f119f5bc0@pengutronix.de> <87ldmp2t1f.fsf@waldekranz.com> Content-Language: en-US From: Ahmad Fatoum In-Reply-To: <87ldmp2t1f.fsf@waldekranz.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250908_114007_376859_D0D1F5C0 X-CRM114-Status: GOOD ( 22.48 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-5.3 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Subject: Re: [PATCH 2/5] dm: Add initial device mapper infrastructure X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.whiteo.stw.pengutronix.de) On 08.09.25 11:27, Tobias Waldekranz wrote: > On fre, sep 05, 2025 at 18:14, Ahmad Fatoum wrote: >> If someone looks at this code, because they have seen this error, they >> won't necessarily know how to interpret the %d. > > My intention was that it could be correlated with the first column from > the table generated by dm_asprint()... Fair enough. > >> Can you either add a comment above the iteration or rename the i to a >> more telling name? > > ...i.e., it is just an index (i). I'll add a comment describing that. Ok. I was initially wondering if that's the "level" (e.g. dm-verity on top of LVM) or something. A comment should be enough. >> We don't support different block sizes right now and you hardcode >> SECTOR_SIZE below anyway, but we like to pretend we could, so >> blk->blockbits would be more apt here. > > I made a conscious decision to use hardcode these everywhere as Linux > defines that a DM block _is_ 512B. You see these constants all over the > place in the target implementations in the kernel as well. > > From dmsetup(8): > | Devices are created by loading a table that specifies a target for > | each sector (512 bytes) in the logical device. > > So while Barebox might one day support other block sizes, I do not think > that DM ever will. > > What I also should have done is to have a comment detailing this, above > the hardcoded block size. If I add this, do you think we should stick > with the constants, or change to blk->blockbits? Ok, let's keep it hardcoded then. A single comment in the probe function is enough. >>> +char *dm_asprint(struct dm_device *dm) >>> +{ >>> + char **strv, *str, *tistr; >>> + struct dm_target *ti; >>> + int n = 0, strc; >>> + >>> + strc = 1 + dm_n_targets(dm); >>> + strv = xmalloc(strc * sizeof(*strv)); >> >> >> Meh, maybe we should have a growable string type... > > I have taken a stab at this in v2 with rasprintf(), "the realloc()ing > sprintf()". Let me know what you think. Looking forward to it! Cheers, Ahmad -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |