Splint fiddles.
authorjbj <devnull@localhost>
Sat, 7 Dec 2002 21:27:09 +0000 (21:27 +0000)
committerjbj <devnull@localhost>
Sat, 7 Dec 2002 21:27:09 +0000 (21:27 +0000)
CVS patchset: 5920
CVS date: 2002/12/07 21:27:09

build/rpmfc.c
build/rpmfc.h
lib/rpmds.c
lib/rpmds.h

index 8c7f3af..2dae2c5 100644 (file)
@@ -274,12 +274,16 @@ static int rpmfcSaveArg(/*@out@*/ ARGV_t * argvp, const char * key)
     return rc;
 }
 
-static char * rpmfcFileDep(char * buf, int ix, rpmds this)
+static char * rpmfcFileDep(/*@returned@*/ char * buf, int ix,
+               /*@null@*/ rpmds this)
        /*@modifies buf @*/
 {
     int_32 tagN = rpmdsTagN(this);
     char deptype = 'X';
 
+/*@-boundswrite@*/
+    buf[0] = '\0';
+/*@=boundswrite@*/
     switch (tagN) {
     case RPMTAG_PROVIDENAME:
        deptype = 'P';
@@ -288,8 +292,11 @@ static char * rpmfcFileDep(char * buf, int ix, rpmds this)
        deptype = 'R';
        break;
     }
-    sprintf(buf, "%08d%c %s %s 0x%08x", ix, deptype,
+/*@-nullpass@*/
+    if (this != NULL)
+       sprintf(buf, "%08d%c %s %s 0x%08x", ix, deptype,
                rpmdsN(this), rpmdsEVR(this), rpmdsFlags(this));
+/*@=nullpass@*/
     return buf;
 };
 
@@ -356,6 +363,7 @@ static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char * nsdep)
            N = pav[i];
            EVR = "";
            Flags = dsContext;
+/*@-branchstate@*/
            if (pav[i+1] && strchr("=<>", *pav[i+1])) {
                i++;
                for (s = pav[i]; *s; s++) {
@@ -378,6 +386,7 @@ assert(*s != '\0');
                EVR = pav[i];
 assert(EVR != NULL);
            }
+/*@=branchstate@*/
 
            this = rpmdsSingle(tagN, N, EVR, Flags);
            xx = rpmdsMerge(depsp, this);
@@ -1319,14 +1328,14 @@ int rpmfcGenerateDepends(const Spec spec, Package pkg)
 
     /* Copy (and delete) manually generated dependencies to dictionary. */
     ds = rpmdsNew(pkg->header, RPMTAG_PROVIDENAME, scareMem);
-    rpmdsMerge(&fc->provides, ds);
+    xx = rpmdsMerge(&fc->provides, ds);
     ds = rpmdsFree(ds);
     xx = headerRemoveEntry(pkg->header, RPMTAG_PROVIDENAME);
     xx = headerRemoveEntry(pkg->header, RPMTAG_PROVIDEVERSION);
     xx = headerRemoveEntry(pkg->header, RPMTAG_PROVIDEFLAGS);
 
     ds = rpmdsNew(pkg->header, RPMTAG_REQUIRENAME, scareMem);
-    rpmdsMerge(&fc->requires, ds);
+    xx = rpmdsMerge(&fc->requires, ds);
     ds = rpmdsFree(ds);
     xx = headerRemoveEntry(pkg->header, RPMTAG_REQUIRENAME);
     xx = headerRemoveEntry(pkg->header, RPMTAG_REQUIREVERSION);
@@ -1362,6 +1371,7 @@ assert(ac == c);
                        p, c);
 
     /* Add Provides: */
+/*@-branchstate@*/
     if (fc->provides != NULL && (c = fc->provides->Count) > 0) {
        p = (const void **) fc->provides->N;
        xx = headerAddEntry(pkg->header, RPMTAG_PROVIDENAME, RPM_STRING_ARRAY_TYPE,
@@ -1386,6 +1396,7 @@ assert(ac == c);
        xx = headerAddEntry(pkg->header, RPMTAG_REQUIREFLAGS, RPM_INT32_TYPE,
                        p, c);
     }
+/*@=branchstate@*/
 
     /* Add dependency dictionary(#dependencies) */
     p = (const void **) argiData(fc->ddictx);
index a682bae..1f91fb0 100644 (file)
@@ -29,7 +29,9 @@ struct rpmfc_s {
     ARGV_t ddict;      /*!< (#dependencies) file depends dictionary */
     ARGI_t ddictx;     /*!< (#dependencies) file->dependency mapping */
 
+/*@relnull@*/
     rpmds provides;    /*!< (#provides) package provides */
+/*@relnull@*/
     rpmds requires;    /*!< (#requires) package requires */
 
     StringBuf sb_java; /*!< concatenated list of java colored files. */
@@ -84,6 +86,8 @@ struct rpmfcTokens_s {
     int colors;
 };
 
+/**
+ */
 typedef struct rpmfcTokens_s * rpmfcToken;
 
 #ifdef __cplusplus
@@ -110,39 +114,49 @@ int rpmfcColoring(const char * fmstr)
  */
 void rpmfcPrint(const char * msg, rpmfc fc, FILE * fp)
        /*@globals fileSystem @*/
-       /*@modifies *fp, fileSystem @*/;
+       /*@modifies *fp, fc, fileSystem @*/;
+
 /**
  * Destroy a file classifier.
  * @param fc           file classifier
  * @return             NULL always
  */
+/*@-exportlocal@*/
 /*@null@*/
 rpmfc rpmfcFree(/*@only@*/ /*@null@*/ rpmfc fc)
        /*@modifies fc @*/;
+/*@=exportlocal@*/
 
 /**
  * Create a file classifier.
  * @return             new file classifier
  */
+/*@-exportlocal@*/
 rpmfc rpmfcNew(void)
        /*@*/;
+/*@=exportlocal@*/
 
 /**
  * Build file class dictionary and mappings.
  * @param fc           file classifier
+ * @param argv         files to classify
  * @return             0 on success
  */
+/*@-exportlocal@*/
 int rpmfcClassify(rpmfc fc, ARGV_t argv)
        /*@globals global_fmagic, fileSystem, internalState @*/
        /*@modifies fc, global_fmagic, fileSystem, internalState @*/;
+/*@=exportlocal@*/
 
 /**
  * Build file/package dependency dictionary and mappings.
  * @param fc           file classifier
  * @return             0 on success
  */
+/*@-exportlocal@*/
 int rpmfcApply(rpmfc fc)
        /*@modifies fc @*/;
+/*@=exportlocal@*/
 
 /**
  * Generate package dependencies.
index 2645bae..2f80d76 100644 (file)
@@ -517,6 +517,7 @@ rpmds rpmdsInit(/*@null@*/ rpmds ds)
     /*@=refcounttrans@*/
 }
 
+/*@-bounds@*/
 static const char ** rpmdsDupArgv(const char ** argv, int argc)
        /*@*/
 {
@@ -540,15 +541,18 @@ assert(argv[ac] != NULL);
     av[ac] = NULL;
     return av;
 }
+/*@=bounds@*/
 
 static rpmds rpmdsDup(const rpmds this)
-       /*@*/
+       /*@modifies this @*/
 {
     rpmds ds = xcalloc(1, sizeof(*ds));
     size_t nb;
 
-    ds->h = (this->h ? headerLink(this->h) : NULL);
+    ds->h = (this->h != NULL ? headerLink(this->h) : NULL);
+/*@-assignexpose@*/
     ds->Type = this->Type;
+/*@=assignexpose@*/
     ds->tagN = this->tagN;
     ds->Count = this->Count;
     ds->i = this->i;
@@ -556,31 +560,37 @@ static rpmds rpmdsDup(const rpmds this)
     ds->u = this->u;
 
     nb = (ds->Count+1) * sizeof(*ds->N);
-    ds->N = (ds->h
+    ds->N = (ds->h != NULL
        ? memcpy(xmalloc(nb), this->N, nb)
        : rpmdsDupArgv(this->N, this->Count) );
     ds->Nt = this->Nt;
 
     nb = (ds->Count+1) * sizeof(*ds->EVR);
-    ds->EVR = (ds->h
+    ds->EVR = (ds->h != NULL
        ? memcpy(xmalloc(nb), this->EVR, nb)
        : rpmdsDupArgv(this->EVR, this->Count) );
     ds->EVRt = this->EVRt;
 
     nb = (ds->Count * sizeof(*ds->Flags));
-    ds->Flags = (ds->h
+    ds->Flags = (ds->h != NULL
        ? this->Flags
        : memcpy(xmalloc(nb), this->Flags, nb) );
     ds->Ft = this->Ft;
 
+/*@-compmempass@*/ /* FIX: ds->Flags is kept, not only */
     return rpmdsLink(ds, (ds ? ds->Type : NULL));
+/*@=compmempass@*/
 
 }
 
+/*@-bounds@*/
 int rpmdsFind(rpmds ds, rpmds this)
 {
     int comparison;
 
+    if (ds == NULL || this == NULL)
+       return -1;
+
     ds->l = 0;
     ds->u = ds->Count;
     while (ds->l < ds->u) {
@@ -596,13 +606,14 @@ int rpmdsFind(rpmds ds, rpmds this)
            ds->u = ds->i;
        else if (comparison > 0)
            ds->l = ds->i + 1;
-       else {
+       else
            return ds->i;
-       }
     }
     return -1;
 }
+/*@=bounds@*/
 
+/*@-bounds@*/
 int rpmdsMerge(rpmds * dsp, rpmds this)
 {
     rpmds ds;
@@ -616,12 +627,14 @@ int save;
        return -1;
 
     /* If not initialized yet, dup the 1st entry. */
+/*@-branchstate@*/
     if (*dsp == NULL) {
        save = this->Count;
        this->Count = 1;
        *dsp = rpmdsDup(this);
        this->Count = save;
     }
+/*@=branchstate@*/
     ds = *dsp;
 
     /*
@@ -629,6 +642,7 @@ int save;
      */
 save = this->i;
     this = rpmdsInit(this);
+    if (this != NULL)
     while (rpmdsNext(this) >= 0) {
        /*
         * If this entry is already present, don't bother.
@@ -666,9 +680,12 @@ save = this->i;
        ds->Count++;
 
     }
+/*@-nullderef@*/
 this->i = save;
+/*@=nullderef@*/
     return 0;
 }
+/*@=bounds@*/
 
 /**
  * Split EVR into epoch, version, and release components.
index a121fdb..ee0d6da 100644 (file)
@@ -273,8 +273,8 @@ rpmds rpmdsInit(/*@null@*/ rpmds ds)
  * @return             dependency index (or -1 if not found)
  */
 /*@null@*/
-int rpmdsFind(rpmds ds, rpmds this)
-       /*@*/;
+int rpmdsFind(rpmds ds, /*@null@*/ rpmds this)
+       /*@modifies ds, this @*/;
 
 /**
  * Merge a dependency set maintaining (N,EVR,Flags) sorted order.
@@ -283,8 +283,8 @@ int rpmdsFind(rpmds ds, rpmds this)
  * @return             (merged) dependency index
  */
 /*@null@*/
-int rpmdsMerge(/*@out@*/ rpmds * dsp, rpmds this)
-       /*@*/;
+int rpmdsMerge(/*@out@*/ rpmds * dsp, /*@null@*/ rpmds this)
+       /*@modifies *dsp, this @*/;
 
 /**
  * Compare two versioned dependency ranges, looking for overlap.