From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iRhX9-00040t-RJ for mharc-grub-devel@gnu.org; Mon, 04 Nov 2019 13:56:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48278) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iRhX7-00040l-7N for grub-devel@gnu.org; Mon, 04 Nov 2019 13:56:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iRhX4-0003Ff-LZ for grub-devel@gnu.org; Mon, 04 Nov 2019 13:56:56 -0500 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:36375) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iRhX3-0003FM-Fh for grub-devel@gnu.org; Mon, 04 Nov 2019 13:56:54 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 086F459C; Mon, 4 Nov 2019 13:56:51 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 04 Nov 2019 13:56:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=eAy5PXMlvtucItdlSgfrbEz+l48 M3bJn0rpvXcTOiCo=; b=k5119EQYoKzWThC0lLAPepgXMX9X4hcrCuBZWnhYq3l Pmx/1rN1jRpnyr6ROJuFAOgto0WUmVmGVzs1bVgvuFpPO25Rimg3azo3AB7vHkxo vZFWwcfQIG3OkCSNiCWTdrG6vfre0v5GgUTKsAy5ZWQgVfvTCBIf4IMDGzHyLbnK PeFaHAvnl6RkMOzVMVVRtfibdCCUEw95NuoagZ10sW85OkHjoPGrzlX7DM+rBqXv KIZFK9P/hwEK+pD2/VoR5D9JSNtRWZu42ScixL6unVz5uZEZ9T04KA5tzLQgPYxz 42ckzZJd0AO6wlN3ryNUd+74N17d8+0cI52twerlgbQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=eAy5PX MlvtucItdlSgfrbEz+l48M3bJn0rpvXcTOiCo=; b=IFZ13OBBmJodfLkO8iIs9G 0x0gRSsGZOPYUFb8COtPjWWrmW1BtubzfEvyuc3BliY8CLVcZjjRmz8tsiufFszL oIB1ouhlbzgG9zgn7jftWyrUBiIxVDHjxueFe5W3QQUjwMcnvnYCAKKyskgTDNVC 3+Y3ZOXJXD+Dc90HVmiOpTjQF2Ua/x+l/jCzny38GGKkqk7XPHPbdTtgeACa5C4+ XRV8QW/2NWVaz8Vzn7WDOaDcTvwS4BfMAAQXMJtY7raV6r0smGIJIHbm9SClPgMl SSb8bWUkVge8SNUyUnsqL0iCwjmGq7msBtnJv8n239tkTjyKU0LNOv8q3W5EuVKQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedruddufedguddvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecukfhppeekledrud dvrdehledrgeehnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from NSJAIL (x590c3b2d.dyn.telefonica.de [89.12.59.45]) by mail.messagingengine.com (Postfix) with ESMTPA id 9F32A306005B; Mon, 4 Nov 2019 13:56:50 -0500 (EST) Received: from localhost (10.192.0.11 [10.192.0.11]) by NSJAIL (OpenSMTPD) with ESMTPSA id 6ae80548 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 4 Nov 2019 18:56:48 +0000 (UTC) Date: Mon, 4 Nov 2019 19:56:48 +0100 From: Patrick Steinhardt To: Daniel Kiper Cc: Max Tottenham , The development of GNU GRUB Subject: Re: [PATCH 2/6] jsmn: Add convenience functions Message-ID: <20191104185648.GA2540@ncase> References: <20191104102620.GA923@akamai.com> <20191104110053.GA2673@ncase> <20191104174251.u2y7dtkj4rvg5zkt@tomti.i.net-space.pl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wac7ysb48OaltWcw" Content-Disposition: inline In-Reply-To: <20191104174251.u2y7dtkj4rvg5zkt@tomti.i.net-space.pl> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.24 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Nov 2019 18:56:58 -0000 --wac7ysb48OaltWcw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 04, 2019 at 06:42:51PM +0100, Daniel Kiper wrote: > On Mon, Nov 04, 2019 at 12:00:53PM +0100, Patrick Steinhardt wrote: > > On Mon, Nov 04, 2019 at 10:26:21AM +0000, Max Tottenham wrote: > > > On 11/02, Patrick Steinhardt wrote: > > > > The newly added jsmn library is a really bare-bones library that > > > > focusses on simplicity. Because of that, it is lacking some functio= ns > > > > for convenience to abstract away some of its inner workings and to = make > > > > code easier to read. As such, we're now adding some functions that = are > > > > going to be used by the LUKS2 implementation later on. > > > > > > > > Signed-off-by: Patrick Steinhardt > > > > --- > > > > include/grub/jsmn.h | 108 ++++++++++++++++++++++++++++++++++++++++= ++++ > > > > 1 file changed, 108 insertions(+) > > > > > > > > > > Would it not make sense to keep the additions in a separate header fr= om > > > the vendored upstream library? That way it'll likely be easier to pull > > > in any updates. > > > > Yeah, I thought about that, too. I wasn't sure about where > > "jsmn.h" and our own extension should live, though, which is why > > I just bailed for now and waited on some feedback. I could > > imagine two things: > > > > - We create "include/grub/json.h" with an API that uses > > GRUB's coding style. It would thus work as a wrapper around > > the jsmn API and contain functions like "grub_json_parse", > > "grub_json_get_object" and also a struct "grub_json_t" that > > contains all things required to work with the parsed JSON > > object. The implementation would be contained in > > "gurb-core/lib/json.c" and use "grub-core/lib/jsmn.h", > > which would be the unmodified upstream library. This would > > allow us to swap out the JSON parser in the future more > > easily without breaking any users and also make the API > > feel less foreign. > > > > - Or there is both a "include/grub/jsmn.h" and > > "include/grub/json.h", where the former one is the > > unmodified JSMN dependency and the latter one provides our > > own extended functions. >=20 > I would like to see JSON functionality in a module. Good example is > in commit 461f1d8af (zstd: Import upstream zstd-1.3.6). So, please > create grub-core/lib/json and put jsmn.h there in unmodified form. > Then create json.c and put all required module and convenience > functions there. If you need some globally available stuff please > put it into include/grub/json.h. Last but not least, I want to ask > you to describe jsmn.h import steps in docs/grub-dev.texi. Good example > is in commit 35b909062 (gnulib: Upgrade Gnulib and switch to bootstrap > tool). Thanks a lot for your advice. Just to make sure we're on the same page about the globally available stuff. I take you'd like to have "json.h" in "include/grub/json.h", but "json.h" will need to include "jsmn.h" with `#define JSMN_HEADER` in order to make struct and function declarations available. I guess it's kind of backwards to have headers in "include/" include headers from "grub-core/lib", but I can't really see a way around it without either re-declaring the same things as in "jsmn.h" or by creating a wrapping API around "jsmn.h". Patrick --wac7ysb48OaltWcw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEtmscHsieVjl9VyNUEXxntp6r8SwFAl3AdG4ACgkQEXxntp6r 8SwhfhAAqPH1HVs4ek4QEZFLAQN3VvTgsuZx1TJMgOYEoyYEZtaC872QIEUnja3K UP+0MjyVDq01YlLkthHjeTXZDuKnoExy/RwVge3DuN2+Izajp0ey0UdbXqAEyF+e dtsDRVsVPiJQzeZckcSMGgmZ41idNqr1L0mDax3SA+BHQ7y92gWLuXMcb8G6+an2 OyuPb14ji4ntO0V4ukq3O7g1JLMvT1SuEkBRf4TgVdpa4nCl/08xYD3C7iEIrva1 bSOURyXjYLiiwGryv7JfQX594p5uyE21F7mdSvm1atZkPBsDyhIbubKxejLLdF8Q D6+9OOHPIe61uvmqb2LvXnu+MkON36LCzG30ra2uevqduF8jAe6bM8Q/7IVWJmeG sL/kARmLxP6aQCigj5q8yxOysjxFuxB4GJosSYb67vwN7WOb71ylbS/TsYeF+F8y QfZJTEBiUV7HmqYgKXReshAo5GnVTQdSGzUcb0KB2NH1UqoS3uRc7En/hT0gVY5e nOeMjArCBXdKPEDs0A687ERk/yUpHHSmS938JxWrCxwQUbfjAOb8jLCuEn3GjKVL SwRPie1UruyWSt52LrP84gOoJCwscTRO6+n7n5/hVMjOnO0T90Yq1YfNlF0TR7yT KEEImjTTg4H1N5kqhLpvV1Z0F9OpUI+npEbgOkC3+lCXybtfdSw= =LM3E -----END PGP SIGNATURE----- --wac7ysb48OaltWcw--