RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES rpm/python/ header-py.c rpmmodule.c rpm/rpmdb/...

From: Jeff Johnson <jbj@rpm5.org>
Date: Sun 09 Sep 2007 - 01:44:01 CEST
Message-Id: <20070908234401.B991E348459@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   09-Sep-2007 01:44:01
  Branch: HEAD                             Handle: 2007090900440000

  Modified files:
    rpm                     CHANGES
    rpm/python              header-py.c rpmmodule.c
    rpm/rpmdb               hdrinline.h header.c header.h pkgio.c rpmdb.c

  Log:
    - jbj: add size_t *lenp to headerUnload().
    - jbj: consistent naming in rpmdb/pkgio.c.

  Summary:
    Revision    Changes     Path
    1.1628      +2  -0      rpm/CHANGES
    1.56        +10 -7      rpm/python/header-py.c
    1.154       +1  -1      rpm/python/rpmmodule.c
    1.13        +4  -2      rpm/rpmdb/hdrinline.h
    1.65        +17 -34     rpm/rpmdb/header.c
    1.23        +3  -2      rpm/rpmdb/header.h
    1.4         +18 -10     rpm/rpmdb/pkgio.c
    1.157       +12 -8      rpm/rpmdb/rpmdb.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1627 -r1.1628 CHANGES
  --- rpm/CHANGES	8 Sep 2007 22:42:35 -0000	1.1627
  +++ rpm/CHANGES	8 Sep 2007 23:44:00 -0000	1.1628
  @@ -1,4 +1,6 @@
   4.5 -> 5.0:
  +    - jbj: add size_t *lenp to headerUnload().
  +    - jbj: consistent naming in rpmdb/pkgio.c
       - jbj: eliminate rpmNewSignature() and rpmFreeSignature().
       - jbj: bury rpmReadSignature/rpmWriteSignature.
       - jbj: rip rpmtsCleanDig() inlining the code.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/python/header-py.c
  ============================================================================
  $ cvs diff -u -r1.55 -r1.56 header-py.c
  --- rpm/python/header-py.c	31 Aug 2007 22:01:22 -0000	1.55
  +++ rpm/python/header-py.c	8 Sep 2007 23:44:00 -0000	1.56
  @@ -9,7 +9,7 @@
   
   #include "legacy.h"
   #include "misc.h"
  -#include "header_internal.h"
  +#include "header_internal.h"	/* XXX HEADERFLAG_ALLOCATED */
   
   #include "rpmts.h"	/* XXX rpmtsCreate/rpmtsFree */
   #define	_RPMEVR_INTERNAL
  @@ -449,7 +449,8 @@
   {
       char * buf;
       PyObject * rc;
  -    int len, legacy = 0;
  +    int legacy = 0;
  +    int nb;
       Header h;
       static char *kwlist[] = { "legacyHeader", NULL};
   
  @@ -462,17 +463,19 @@
   	h = headerCopy(s->h);	/* XXX strip region tags, etc */
   	headerFree(s->h);
       }
  -    len = headerSizeof(h);
  -    len -= 8;	/* XXX HEADER_MAGIC_NO */
  -    buf = headerUnload(h);
  +    {	size_t len;
  +	buf = headerUnload(h, &len);
  +	nb = len;
  +	nb -= 8;	/* XXX HEADER_MAGIC_NO */
  +    }
       h = headerFree(h);
   
  -    if (buf == NULL || len == 0) {
  +    if (buf == NULL || nb == 0) {
   	PyErr_SetString(pyrpmError, "can't unload bad header\n");
   	return NULL;
       }
   
  -    rc = PyString_FromStringAndSize(buf, len);
  +    rc = PyString_FromStringAndSize(buf, nb);
       buf = _free(buf);
   
       return rc;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/python/rpmmodule.c
  ============================================================================
  $ cvs diff -u -r1.153 -r1.154 rpmmodule.c
  --- rpm/python/rpmmodule.c	10 Aug 2007 19:01:19 -0000	1.153
  +++ rpm/python/rpmmodule.c	8 Sep 2007 23:44:00 -0000	1.154
  @@ -11,7 +11,7 @@
   
   #include "legacy.h"
   #include "misc.h"
  -#include "header_internal.h"
  +#include "header.h"
   
   #include "header-py.h"
   #include "rpmal-py.h"
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/hdrinline.h
  ============================================================================
  $ cvs diff -u -r1.12 -r1.13 hdrinline.h
  --- rpm/rpmdb/hdrinline.h	17 Aug 2007 05:36:05 -0000	1.12
  +++ rpm/rpmdb/hdrinline.h	8 Sep 2007 23:44:00 -0000	1.13
  @@ -128,13 +128,15 @@
   /** \ingroup header
    * Convert header to on-disk representation.
    * @param h		header (with pointers)
  + * @retval *lenp	length of header in bytes (or NULL);
    * @return		on-disk header blob (i.e. with offsets)
    */
   /*@unused@*/ static inline
  -/*@only@*/ /*@null@*/ void * headerUnload(Header h)
  +/*@only@*/ /*@null@*/
  +void * headerUnload(Header h, size_t * lenp)
   	/*@modifies h @*/
   {
  -    return (h2hv(h)->hdrunload) (h);
  +    return (h2hv(h)->hdrunload) (h, lenp);
   }
   
   /** \ingroup header
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/header.c
  ============================================================================
  $ cvs diff -u -r1.64 -r1.65 header.c
  --- rpm/rpmdb/header.c	8 Sep 2007 18:55:46 -0000	1.64
  +++ rpm/rpmdb/header.c	8 Sep 2007 23:44:00 -0000	1.65
  @@ -602,14 +602,14 @@
   
   /** \ingroup header
    * @param h		header
  - * @retval *lengthPtr	no. bytes in unloaded header blob
  + * @retval *lenp	no. bytes in unloaded header blob
    * @return		unloaded header blob (NULL on error)
    */
  -static /*@only@*/ /*@null@*/ void * doHeaderUnload(Header h,
  -		/*@out@*/ int * lengthPtr)
  -	/*@modifies h, *lengthPtr @*/
  -	/*@requires maxSet(lengthPtr) >= 0 @*/
  -	/*@ensures maxRead(result) == (*lengthPtr) @*/
  +static /*@only@*/ /*@null@*/
  +void * headerUnload(Header h, /*@out@*/ /*@null@*/ size_t * lenp)
  +	/*@modifies h, *lenp @*/
  +	/*@requires maxSet(lenp) >= 0 @*/
  +	/*@ensures maxRead(result) == (*lenp) @*/
   {
       void * sw;
       int_32 * ei = NULL;
  @@ -872,8 +872,8 @@
       if ((((char *)ei)+len) != te)
   	goto errxit;
   
  -    if (lengthPtr)
  -	*lengthPtr = len;
  +    if (lenp)
  +	*lenp = len;
   
       h->flags &= ~HEADERFLAG_SORTED;
       headerSort(h);
  @@ -890,22 +890,6 @@
       return (void *) ei;
   }
   
  -/** \ingroup header
  - * Convert header to on-disk representation.
  - * @param h		header (with pointers)
  - * @return		on-disk header blob (i.e. with offsets)
  - */
  -static /*@only@*/ /*@null@*/
  -void * headerUnload(Header h)
  -	/*@modifies h @*/
  -{
  -    int length;
  -/*@-boundswrite@*/
  -    void * uh = doHeaderUnload(h, &length);
  -/*@=boundswrite@*/
  -    return uh;
  -}
  -
   /**
    * Find matching (tag,type) entry in header.
    * @param h		header
  @@ -1298,10 +1282,9 @@
   	/*@modifies h @*/
   {
       Header nh;
  -    int length;
       /*@-onlytrans@*/
   /*@-boundswrite@*/
  -    void * uh = doHeaderUnload(h, &length);
  +    void * uh = headerUnload(h, NULL);
   /*@=boundswrite@*/
       const char * origin;
       int_32 instance = h->instance;
  @@ -1472,13 +1455,13 @@
   {
       FD_t fd = _fd;
       ssize_t nb;
  -    int length;
  +    size_t length;
       const void * uh;
   
       if (h == NULL)
   	return 1;
   /*@-boundswrite@*/
  -    uh = doHeaderUnload(h, &length);
  +    uh = headerUnload(h, &length);
   /*@=boundswrite@*/
       if (uh == NULL)
   	return 1;
  @@ -2051,14 +2034,14 @@
    * @param type		entry data type
    * @param p		entry data
    * @param c		entry item count
  - * @retval lengthPtr	no. bytes in returned data
  + * @retval *lenp	no. bytes in returned data
    * @return 		(malloc'ed) copy of entry data, NULL on error
    */
   /*@null@*/
   static void *
  -grabData(int_32 type, hPTR_t p, int_32 c, /*@out@*/ int * lengthPtr)
  -	/*@modifies *lengthPtr @*/
  -	/*@requires maxSet(lengthPtr) >= 0 @*/
  +grabData(int_32 type, hPTR_t p, int_32 c, /*@out@*/ int * lenp)
  +	/*@modifies *lenp @*/
  +	/*@requires maxSet(lenp) >= 0 @*/
   {
       void * data = NULL;
       int length;
  @@ -2071,8 +2054,8 @@
       }
   /*@=branchstate@*/
   
  -    if (lengthPtr)
  -	*lengthPtr = length;
  +    if (lenp)
  +	*lenp = length;
       return data;
   }
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/header.h
  ============================================================================
  $ cvs diff -u -r1.22 -r1.23 header.h
  --- rpm/rpmdb/header.h	19 Aug 2007 19:45:47 -0000	1.22
  +++ rpm/rpmdb/header.h	8 Sep 2007 23:44:00 -0000	1.23
  @@ -408,11 +408,12 @@
   /** \ingroup header
    * Convert header to on-disk representation.
    * @param h		header (with pointers)
  + * @retval *lenp	length of header in bytes (or NULL);
    * @return		on-disk header blob (i.e. with offsets)
    */
   typedef
  -/*@only@*/ /*@null@*/ void * (*HDRunload) (Header h)
  -        /*@modifies h @*/;
  +/*@only@*/ /*@null@*/ void * (*HDRunload) (Header h, size_t * lenp)
  +        /*@modifies h, *lenp @*/;
   
   /** \ingroup header
    * Convert header to on-disk representation, and then reload.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/pkgio.c
  ============================================================================
  $ cvs diff -u -r1.3 -r1.4 pkgio.c
  --- rpm/rpmdb/pkgio.c	8 Sep 2007 22:17:55 -0000	1.3
  +++ rpm/rpmdb/pkgio.c	8 Sep 2007 23:44:00 -0000	1.4
  @@ -20,8 +20,8 @@
   #include "debug.h"
   
   
  -/*@access entryInfo @*/		/* XXX rpmReadSignature */
  -/*@access indexEntry @*/	/* XXX rpmReadSignature */
  +/*@access entryInfo @*/		/* XXX rdSignature */
  +/*@access indexEntry @*/	/* XXX rdSignature */
   
   /**
    * Signature types stored in rpm lead.
  @@ -75,7 +75,7 @@
    * @param *msg		name to include in lead
    * @return		RPMRC_OK on success, RPMRC_FAIL on error
    */
  -static rpmRC writeLead(FD_t fd, void * ptr, const char ** msg)
  +static rpmRC wrLead(FD_t fd, void * ptr, const char ** msg)
   	/*@globals fileSystem @*/
   	/*@modifies fd, fileSystem @*/
   {
  @@ -116,7 +116,7 @@
    * @retval *msg		failure msg
    * @return		rpmRC return code
    */
  -static rpmRC readLead(FD_t fd, void * ptr, const char ** msg)
  +static rpmRC rdLead(FD_t fd, void * ptr, const char ** msg)
   	/*@modifies fd, *lead, *msg @*/
   {
       struct rpmlead ** leadp = ptr;
  @@ -204,7 +204,7 @@
    * @retval *msg		failure msg
    * @return		rpmRC return code
    */
  -static rpmRC rpmWriteSignature(void * _fd, void * ptr, const char ** msg)
  +static rpmRC wrSignature(void * _fd, void * ptr, const char ** msg)
   	/*@globals fileSystem @*/
   	/*@modifies _fd, sigh, fileSystem @*/
   {
  @@ -277,7 +277,7 @@
    * @retval *msg		failure msg
    * @return		rpmRC return code
    */
  -static rpmRC rpmReadSignature(void * _fd, void * ptr, const char ** msg)
  +static rpmRC rdSignature(void * _fd, void * ptr, const char ** msg)
   	/*@globals fileSystem @*/
   	/*@modifies _fd, *ptr, *msg, fileSystem @*/
   {
  @@ -483,9 +483,13 @@
       rpmRC rc = RPMRC_FAIL;
   
       if (!strcmp(fn, "Lead"))
  -	return readLead(fd, ptr, msg);
  +	return rdLead(fd, ptr, msg);
       if (!strcmp(fn, "Signature"))
  -	return rpmReadSignature(fd, ptr, msg);
  +	return rdSignature(fd, ptr, msg);
  +#ifdef	NOTYET
  +    if (!strcmp(fn, "Header"))
  +	return rdHeader(fd, ptr, msg);
  +#endif
       return rc;
   }
   
  @@ -494,9 +498,13 @@
       rpmRC rc = RPMRC_FAIL;
   
       if (!strcmp(fn, "Lead"))
  -	return writeLead(fd, ptr, msg);
  +	return wrLead(fd, ptr, msg);
       if (!strcmp(fn, "Signature"))
  -	return rpmWriteSignature(fd, ptr, msg);
  +	return wrSignature(fd, ptr, msg);
  +#ifdef	NOTYET
  +    if (!strcmp(fn, "Header"))
  +	return wrHeader(fd, ptr, msg);
  +#endif
       return rc;
   }
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/rpmdb.c
  ============================================================================
  $ cvs diff -u -r1.156 -r1.157 rpmdb.c
  --- rpm/rpmdb/rpmdb.c	8 Sep 2007 15:45:19 -0000	1.156
  +++ rpm/rpmdb/rpmdb.c	8 Sep 2007 23:44:00 -0000	1.157
  @@ -1862,9 +1862,11 @@
   	(void) headerGetMagic(mi->mi_h, NULL, &nb);
   /*@i@*/	key->data = (void *) &mi->mi_prevoffset;
   	key->size = sizeof(mi->mi_prevoffset);
  -	data->data = headerUnload(mi->mi_h);
  -	data->size = headerSizeof(mi->mi_h);
  -	data->size -= nb;	/* XXX HEADER_MAGIC_NO */
  +	{   size_t len;
  +	    data->data = headerUnload(mi->mi_h, &len);
  +	    data->size = len;	/* XXX data->size is uint32_t */
  +	    data->size -= nb;	/* XXX HEADER_MAGIC_NO */
  +	}
   
   	/* Check header digest/signature on blob export (if requested). */
   	if (mi->mi_hdrchk && mi->mi_ts) {
  @@ -3317,11 +3319,13 @@
   key->data = (void *) &mi_offset;
   /*@=immediatetrans@*/
   key->size = sizeof(mi_offset.ui);
  -nb = 0;
  -(void) headerGetMagic(h, NULL, &nb);
  -data->data = headerUnload(h);
  -data->size = headerSizeof(h);
  -data->size -= nb;	/* XXX HEADER_MAGIC_NO */
  +{   size_t len;
  +    nb = 0;
  +    (void) headerGetMagic(h, NULL, &nb);
  +    data->data = headerUnload(h, &len);
  +    data->size = len;	/* XXX data->size is uint32_t */
  +    data->size -= nb;	/* XXX HEADER_MAGIC_NO */
  +}
   
   		/* Check header digest/signature on blob export. */
   		if (hdrchk && ts) {
  @@ .
Received on Sun Sep 9 01:44:01 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.