Fix query return codes (rhbz#244236)
- count + skip over errors in rpmgiNext() instead of stopping iteration - add rpmgiNumErrors() for retrieving errors, use it in query
This commit is contained in:
parent
c54001150f
commit
9f34c32443
|
@ -381,7 +381,7 @@ static int rpmgiShowMatches(QVA_t qva, rpmts ts)
|
|||
if (qva->qva_source == RPMQV_DBOFFSET)
|
||||
break;
|
||||
}
|
||||
return ec;
|
||||
return rpmgiNumErrors(gi);
|
||||
}
|
||||
|
||||
int rpmcliShowMatches(QVA_t qva, rpmts ts)
|
||||
|
|
24
lib/rpmgi.c
24
lib/rpmgi.c
|
@ -33,6 +33,7 @@ struct rpmgi_s {
|
|||
rpmgiFlags flags; /*!< Iterator control bits. */
|
||||
int active; /*!< Iterator is active? */
|
||||
int i; /*!< Element index. */
|
||||
int errors;
|
||||
const char * hdrPath; /*!< Path to current iterator header. */
|
||||
Header h; /*!< Current iterator header. */
|
||||
|
||||
|
@ -157,7 +158,6 @@ static Header rpmgiReadHeader(rpmgi gi, const char * path)
|
|||
/**
|
||||
* Read next header from package, lazily expanding manifests as found.
|
||||
* @todo An empty file read as manifest truncates argv returning RPMRC_NOTFOUND.
|
||||
* @todo Errors, e.g. non-existent path in manifest, will terminate iteration.
|
||||
* @todo Chained manifests lose an arg someplace.
|
||||
* @param gi generalized iterator
|
||||
* @return RPMRC_OK on success
|
||||
|
@ -447,6 +447,7 @@ rpmgi rpmgiNew(rpmts ts, int tag, const void * keyp, size_t keylen)
|
|||
gi->flags = 0;
|
||||
gi->active = 0;
|
||||
gi->i = -1;
|
||||
gi->errors = 0;
|
||||
gi->hdrPath = NULL;
|
||||
gi->h = NULL;
|
||||
|
||||
|
@ -553,12 +554,22 @@ rpmRC rpmgiNext(rpmgi gi)
|
|||
goto enditer;
|
||||
}
|
||||
break;
|
||||
case RPMDBI_ARGLIST:
|
||||
case RPMDBI_ARGLIST:
|
||||
/* XXX gi->active initialize? */
|
||||
if (_rpmgi_debug < 0)
|
||||
fprintf(stderr, "*** gi %p\t%p[%d]: %s\n", gi, gi->argv, gi->i, gi->argv[gi->i]);
|
||||
/* Read next header, lazily expanding manifests as found. */
|
||||
rpmrc = rpmgiLoadReadHeader(gi);
|
||||
|
||||
/*
|
||||
* Read next header, lazily expanding manifests as found,
|
||||
* count + skip errors.
|
||||
*/
|
||||
rpmrc = RPMRC_NOTFOUND;
|
||||
while (gi->i < gi->argc) {
|
||||
if ((rpmrc = rpmgiLoadReadHeader(gi)) == RPMRC_OK)
|
||||
break;
|
||||
gi->errors++;
|
||||
gi->i++;
|
||||
}
|
||||
|
||||
if (rpmrc != RPMRC_OK) /* XXX check this */
|
||||
goto enditer;
|
||||
|
@ -663,3 +674,8 @@ rpmgiFlags rpmgiGetFlags(rpmgi gi)
|
|||
{
|
||||
return (gi != NULL ? gi->flags : RPMGI_NONE);
|
||||
}
|
||||
|
||||
int rpmgiNumErrors(rpmgi gi)
|
||||
{
|
||||
return (gi != NULL ? gi->errors : -1);
|
||||
}
|
||||
|
|
15
lib/rpmgi.h
15
lib/rpmgi.h
|
@ -111,13 +111,26 @@ rpmts rpmgiTs(rpmgi gi);
|
|||
* @param argv arg list
|
||||
* @param ftsOpts fts(3) flags
|
||||
* @param flags iterator flags
|
||||
* @returns RPMRC_OK on success
|
||||
* @return RPMRC_OK on success
|
||||
*/
|
||||
rpmRC rpmgiSetArgs(rpmgi gi, ARGV_t argv,
|
||||
int ftsOpts, rpmgiFlags flags);
|
||||
|
||||
|
||||
/** \ingroup rpmgi
|
||||
* Retrieve iterator flags
|
||||
* @param gi generalized iterator
|
||||
* @return iterator flags
|
||||
*/
|
||||
rpmgiFlags rpmgiGetFlags(rpmgi gi);
|
||||
|
||||
/** \ingroup rpmgi
|
||||
* Return number of errors (file not found etc) encountered during iteration
|
||||
* @param gi generalized iterator
|
||||
* @return number of errors
|
||||
*/
|
||||
int rpmgiNumErrors(rpmgi gi);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue