Re: [RFC/PATCHv2 2/6] add metadata-cache infrastructure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 13, 2011 at 10:45:52AM +0200, Bert Wesarg wrote:

> > It might make sense to put:
> >
> >  if (!c->mem.width)
> >          die("BUG: zero-width metadata-cache");
> >
> > into the initialization function to make it more clear, and make a note
> > in the API documentation.
> 
> That should be good. Thanks.

I've squashed in the patch below for my next re-roll.

diff --git a/Documentation/technical/api-metadata-cache.txt b/Documentation/technical/api-metadata-cache.txt
index 192a868..e335b96 100644
--- a/Documentation/technical/api-metadata-cache.txt
+++ b/Documentation/technical/api-metadata-cache.txt
@@ -102,9 +102,10 @@ Functions
 	specifies a human-readable name which will be used for storage
 	in `$GIT_DIR/cache/$name`. The `width` parameter specifies the
 	size, in units of `char`, of the data to be stored (e.g., use
-	`sizeof(uint32_t)` to store 32-bit integers). The `validity`
-	parameter is either NULL or a pointer to a function providing a
-	20-byte validity sha1.
+	`sizeof(uint32_t)` to store 32-bit integers). The `width`
+	parameter must be greater than 0. The `validity` parameter is
+	either NULL or a pointer to a function providing a 20-byte
+	validity sha1.
 
 `metadata_cache_lookup`::
 
diff --git a/metadata-cache.c b/metadata-cache.c
index e2e5ff8..025d3a5 100644
--- a/metadata-cache.c
+++ b/metadata-cache.c
@@ -261,6 +261,9 @@ static void metadata_cache_init(struct metadata_cache *c)
 	if (c->initialized)
 		return;
 
+	if (!c->mem.width)
+		die("BUG: tried to initialize zero-width metadata cache");
+
 	open_disk_cache(c, metadata_cache_path(c->mem.name));
 
 	ALLOC_GROW(autowrite, autowrite_nr+1, autowrite_alloc);

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]