[lvm-devel] [PATCH 03/12] Add id_format_and_copy() uuid function to allocate and format a uuid.

Dave Wysochanski dwysocha at redhat.com
Fri Sep 10 16:56:28 UTC 2010


On Fri, 2010-09-10 at 11:30 +0200, Zdenek Kabelac wrote:
> Dne 9.9.2010 22:13, Dave Wysochanski napsal(a):
> > Add supporting uuid function to allocate memory and call id_write_format.
> > Will be used from reporting functions as well as property functions.
> > 
> > Signed-off-by: Dave Wysochanski <dwysocha at redhat.com>
> > ---
> >  lib/uuid/uuid.c |   15 +++++++++++++++
> >  lib/uuid/uuid.h |    2 ++
> >  2 files changed, 17 insertions(+), 0 deletions(-)
> > 
> > diff --git a/lib/uuid/uuid.c b/lib/uuid/uuid.c
> > index de3f0cd..6608473 100644
> > --- a/lib/uuid/uuid.c
> > +++ b/lib/uuid/uuid.c
> > @@ -206,3 +206,18 @@ int id_read_format(struct id *id, const char *buffer)
> >  
> >  	return id_valid(id);
> >  }
> > +
> > +char *id_format_and_copy(struct dm_pool *mem, struct id *id)
> > +{
> > +	char *repstr = NULL;
> > +
> > +	if (!(repstr = dm_pool_alloc(mem, 40))) {
> > +		log_error("dm_pool_alloc failed");
> > +		return NULL;
> > +	}
> > +
> > +	if (!id_write_format(id, repstr, 40))
> > +		return_NULL;
> > +
> > +	return repstr;
> > +}
> > diff --git a/lib/uuid/uuid.h b/lib/uuid/uuid.h
> > index 0029639..6c1169a 100644
> > --- a/lib/uuid/uuid.h
> > +++ b/lib/uuid/uuid.h
> > @@ -54,4 +54,6 @@ int id_write_format(const struct id *id, char *buffer, size_t size);
> >   */
> >  int id_read_format(struct id *id, const char *buffer);
> >  
> > +char *id_format_and_copy(struct dm_pool *mem, struct id *id);
> 
> const struct id*
> 
> Please consider 'const' in case you do not plane to modify id inside this
> function.
> 
> Zdenek
> 

Updated in my patchset.




More information about the lvm-devel mailing list