I originally meant to post only the "vector.h" patch, but then
(independently) nbdkit wouldn't build. Hence the other (rust plugin)
patch.
Laszlo
Laszlo Ersek (2):
common/utils: document empty_vector compound literal assignment
plugins/rust: restrict predicates-{tree,core} to {1.0.7,1.0.5}
common/utils/vector.h | 8 +++++++-
plugins/rust/Cargo.toml | 2 ++
2 files changed, 9 insertions(+), 1 deletion(-)
base-commit: 45b72f5bd8fc1b475fa130d06c86cd877bf595d5
Laszlo Ersek
2023-Mar-28 16:25 UTC
[Libguestfs] [nbdkit PATCH 1/2] common/utils: document empty_vector compound literal assignment
We usually zero-initialize vectors like
string_vector names = empty_vector;
Allocating and zeroing separately is frequently useful however. Document
the pattern
string_vector names;
names = (string_vector)empty_vector;
where "(string_vector)empty_vector" is a compound literal.
Link: http://mid.mail-archive.com/20230221183810.vjilfbmj3woqivlj at redhat.com
Suggested-by: Eric Blake <eblake at redhat.com>
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
Notes:
I'll pick this patch to libnbd as well, once merged in nbdkit.
context:-U10
common/utils/vector.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/common/utils/vector.h b/common/utils/vector.h
index ac28c0b5363a..7337d26893eb 100644
--- a/common/utils/vector.h
+++ b/common/utils/vector.h
@@ -55,28 +55,34 @@
/* Use of this macro defines a new type called ?name? containing an
* extensible vector of ?type? elements. For example:
*
* DEFINE_VECTOR_TYPE (string_vector, char *);
*
* defines a new type called ?string_vector? as a vector of ?char *?.
* You can create variables of this type:
*
* string_vector names = empty_vector;
*
+ * or
+ *
+ * string_vector names;
+ * names = (string_vector)empty_vector;
+ *
* where ?names.ptr[]? will be an array of strings and ?names.len?
* will be the number of strings. There are no get/set accessors. To
* iterate over the strings you can use the ?.ptr? field directly:
*
* for (size_t i = 0; i < names.len; ++i)
* printf ("%s\n", names.ptr[i]);
*
- * Initializing with ?empty_vector? sets ?.ptr = NULL? and ?.len = 0?.
+ * Initializing with ?empty_vector?, or assigning the compound literal
+ * ?(string_vector)empty_vector?, sets ?.ptr = NULL? and ?.len = 0?.
*
* DEFINE_VECTOR_TYPE also defines utility functions. For the full
* list see the definition below, but useful functions include:
*
* ?name?_append (eg. ?string_vector_append?)
* - Append a new element at the end. This operation is cheap.
*
* ?name?_insert (eg. ?string_vector_insert?)
* - Insert a new element at the beginning, middle or end. This
* operation is more expensive because existing elements may need
Laszlo Ersek
2023-Mar-28 16:25 UTC
[Libguestfs] [nbdkit PATCH 2/2] plugins/rust: restrict predicates-{tree, core} to {1.0.7, 1.0.5}
The beautiful world of uncontained dependencies:
- We restrict mockall to 0.11.0, which in practice currently expands to
0.11.4,
- mockall depends on predicates-tree,
- predicates-tree depends on predicates-core,
- approx. two weeks ago, predicates-tree and predicates-core have seen
*PATCHLEVEL* upgrades (1.0.7 -> 1.0.9, and 1.0.5 -> 1.0.6, respectively)
that now require "rustc 1.64.0 or newer".
RHEL-9.2 will eventually ship rustc 1.66, but RHEL-9.2 has not been
released. The above rustc requirement bump breaks the nbdkit build on
RHEL-9.1 -- which provides rustc 1.62. Restrict predicates-{tree,core} to
{1.0.7,1.0.5}.
(Side commentary: when such things can happen via a *patchlevel* upgrade,
that makes a total mockery of "semantic versioning"
<https://en.wikipedia.org/wiki/Software_versioning#Semantic_versioning>.)
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
plugins/rust/Cargo.toml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/plugins/rust/Cargo.toml b/plugins/rust/Cargo.toml
index 45d8a755e6e3..64ed193a0008 100644
--- a/plugins/rust/Cargo.toml
+++ b/plugins/rust/Cargo.toml
@@ -29,6 +29,8 @@ errno = "0.2.5"
lazy_static = "1.2.0"
memoffset = "0.6.3"
mockall = "0.11.0"
+predicates-core = "=1.0.5"
+predicates-tree = "=1.0.7"
[[example]]
name = "ramdisk"
On 3/28/23 18:25, Laszlo Ersek wrote:> I originally meant to post only the "vector.h" patch, but then > (independently) nbdkit wouldn't build. Hence the other (rust plugin) > patch. > > Laszlo > > Laszlo Ersek (2): > common/utils: document empty_vector compound literal assignment > plugins/rust: restrict predicates-{tree,core} to {1.0.7,1.0.5} > > common/utils/vector.h | 8 +++++++- > plugins/rust/Cargo.toml | 2 ++ > 2 files changed, 9 insertions(+), 1 deletion(-) > > > base-commit: 45b72f5bd8fc1b475fa130d06c86cd877bf595d5Merged as commit range 45b72f5bd8fc..da7458d7071e. Thanks, Laszlo
Apparently Analagous Threads
- [nbdkit PATCH 0/2] various
- Re: [PATCH nbdkit 1/9] common: Add a generic implementation of vectors.
- [PATCH libnbd 1/5] common/utils: Copy simple vector library from nbdkit.
- [PATCH nbdkit 3/5] vddk: Miscellaneous improvements to reexec code.
- [PATCH libnbd 0/5] info: --map: Coalesce adjacent extents of the same type.