ARGV_t const pendantry

- const on typedef'ed ARGV_t doesn't mean a thing, add a new,
  (exec* compatible) ARGV_const_t and use where appropriate consistently in
  argv.h, rpmcli.h etc
- popt's argv const is the wrong way around for exec() family, add explicit
  ARGV_t casts on popGetArgs() uses where needed
- compiler silence, aaahh...
This commit is contained in:
Panu Matilainen 2008-04-07 12:11:16 +03:00
parent d728ec28dc
commit c29adcee80
15 changed files with 47 additions and 54 deletions

View File

@ -2246,7 +2246,7 @@ int processSourceFiles(rpmSpec spec)
*/
static int checkFiles(StringBuf fileList)
{
static const char * av_ckfile[] = { "%{?__check_files}", NULL };
static char * const av_ckfile[] = { "%{?__check_files}", NULL };
StringBuf sb_stdout = NULL;
char * s;
int rc;

View File

@ -61,7 +61,7 @@ struct rpmfcTokens_s {
/**
*/
static int rpmfcExpandAppend(ARGV_t * argvp, const ARGV_t av)
static int rpmfcExpandAppend(ARGV_t * argvp, ARGV_const_t av)
{
ARGV_t argv = *argvp;
int argc = argvCount(argv);
@ -227,7 +227,7 @@ top:
return readBuff;
}
int rpmfcExec(ARGV_t av, StringBuf sb_stdin, StringBuf * sb_stdoutp,
int rpmfcExec(ARGV_const_t av, StringBuf sb_stdin, StringBuf * sb_stdoutp,
int failnonzero)
{
char * s = NULL;
@ -345,7 +345,7 @@ static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char * nsdep)
char *buf = NULL;
StringBuf sb_stdout = NULL;
StringBuf sb_stdin;
const char *av[2];
char *av[2];
rpmds * depsp, ds;
const char * N;
const char * EVR;
@ -1343,7 +1343,7 @@ typedef struct DepMsg_s * DepMsg_t;
*/
struct DepMsg_s {
const char * msg;
const char * argv[4];
char * const argv[4];
rpmTag ntag;
rpmTag vtag;
rpmTag ftag;

View File

@ -86,7 +86,7 @@ typedef const struct rpmfcTokens_s * rpmfcToken;
* @retval *sb_stdoutp helper output
* @param failnonzero IS non-zero helper exit status a failure?
*/
int rpmfcExec(ARGV_t av, StringBuf sb_stdin, StringBuf * sb_stdoutp,
int rpmfcExec(ARGV_const_t av, StringBuf sb_stdin, StringBuf * sb_stdoutp,
int failnonzero);
/** \ingroup rpmfc

View File

@ -675,7 +675,7 @@ int rpmQueryVerify(QVA_t qva, rpmts ts, const char * arg)
return res;
}
int rpmcliArgIter(rpmts ts, QVA_t qva, ARGV_t argv)
int rpmcliArgIter(rpmts ts, QVA_t qva, ARGV_const_t argv)
{
rpmRC rpmrc = RPMRC_NOTFOUND;
int ec = 0;
@ -755,7 +755,7 @@ int rpmcliArgIter(rpmts ts, QVA_t qva, ARGV_t argv)
return ec;
}
int rpmcliQuery(rpmts ts, QVA_t qva, const char ** argv)
int rpmcliQuery(rpmts ts, QVA_t qva, char * const * argv)
{
rpmVSFlags vsflags, ovsflags;
int ec = 0;

View File

@ -137,8 +137,7 @@ static int getSignid(Header sig, rpmSigTag sigtag, pgpKeyID_t signid)
* @param argv array of package file names (NULL terminated)
* @return 0 on success
*/
static int rpmReSign(rpmts ts,
QVA_t qva, const char ** argv)
static int rpmReSign(rpmts ts, QVA_t qva, ARGV_const_t argv)
{
FD_t fd = NULL;
FD_t ofd = NULL;
@ -398,9 +397,7 @@ exit:
* @param argv array of pubkey file names (NULL terminated)
* @return 0 on success
*/
static int rpmcliImportPubkeys(const rpmts ts,
QVA_t qva,
const char ** argv)
static int rpmcliImportPubkeys(const rpmts ts, QVA_t qva, ARGV_const_t argv)
{
const char * fn;
unsigned char * pkt = NULL;
@ -797,7 +794,7 @@ exit:
return res;
}
int rpmcliSign(rpmts ts, QVA_t qva, const char ** argv)
int rpmcliSign(rpmts ts, QVA_t qva, ARGV_const_t argv)
{
const char * arg;
int res = 0;

View File

@ -266,7 +266,7 @@ int showQueryPackage(QVA_t qva, rpmts ts, Header h);
* @param argv query argument(s) (or NULL)
* @return 0 on success, else no. of failures
*/
int rpmcliArgIter(rpmts ts, QVA_t qva, ARGV_t argv);
int rpmcliArgIter(rpmts ts, QVA_t qva, ARGV_const_t argv);
/** \ingroup rpmcli
* Display package information.
@ -276,7 +276,7 @@ int rpmcliArgIter(rpmts ts, QVA_t qva, ARGV_t argv);
* @param argv query argument(s) (or NULL)
* @return 0 on success, else no. of failures
*/
int rpmcliQuery(rpmts ts, QVA_t qva, const char ** argv);
int rpmcliQuery(rpmts ts, QVA_t qva, ARGV_const_t argv);
/** \ingroup rpmcli
* Display results of package verify.
@ -305,7 +305,7 @@ int rpmVerifySignatures(QVA_t qva, rpmts ts, FD_t fd, const char * fn);
* @param argv verify argument(s) (or NULL)
* @return 0 on success, else no. of failures
*/
int rpmcliVerify(rpmts ts, QVA_t qva, const char ** argv);
int rpmcliVerify(rpmts ts, QVA_t qva, ARGV_const_t argv);
/* ==================================================================== */
/** \name RPMBT */
@ -436,9 +436,10 @@ struct rpmInstallArguments_s {
* @param ia mode flags and parameters
* @param fileArgv array of package file names (NULL terminated)
* @return 0 on success
*
* @todo fileArgv is modified on errors, should be ARGV_const_t
*/
int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia,
const char ** fileArgv);
int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_t fileArgv);
/** \ingroup rpmcli
* Erase binary rpm package.
@ -448,8 +449,7 @@ int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia,
* @return 0 on success
*/
int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia,
const char ** argv);
int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_const_t argv);
/** \ingroup rpmcli
*/
@ -506,7 +506,7 @@ extern struct poptOption rpmSignPoptTable[];
* @param argv array of arguments (NULL terminated)
* @return 0 on success
*/
int rpmcliSign(rpmts ts, QVA_t qva, const char ** argv);
int rpmcliSign(rpmts ts, QVA_t qva, ARGV_const_t argv);
#ifdef __cplusplus
}

View File

@ -287,7 +287,7 @@ static rpmRC rpmgiWalkReadHeader(rpmgi gi)
* @param argv arg list to be globbed (or NULL)
* @returns RPMRC_OK on success
*/
static rpmRC rpmgiGlobArgv(rpmgi gi, ARGV_t argv)
static rpmRC rpmgiGlobArgv(rpmgi gi, ARGV_const_t argv)
{
const char * arg;
rpmRC rpmrc = RPMRC_OK;
@ -340,7 +340,7 @@ if (_rpmgi_debug < 0)
fprintf(stderr, "*** gi %p\tmi %p\n", gi, gi->mi);
if (gi->argv != NULL)
for (av = (const char **) gi->argv; *av != NULL; av++) {
for (av = gi->argv; *av != NULL; av++) {
rpmTag tag = RPMTAG_NAME;
const char * pat;
char * a, * ae;
@ -665,7 +665,7 @@ rpmts rpmgiTs(rpmgi gi)
return (gi != NULL ? gi->ts : NULL);
}
rpmRC rpmgiSetArgs(rpmgi gi, ARGV_t argv, int ftsOpts, rpmgiFlags flags)
rpmRC rpmgiSetArgs(rpmgi gi, ARGV_const_t argv, int ftsOpts, rpmgiFlags flags)
{
gi->ftsOpts = ftsOpts;
gi->flags = flags;

View File

@ -111,7 +111,7 @@ rpmts rpmgiTs(rpmgi gi);
* @param flags iterator flags
* @return RPMRC_OK on success
*/
rpmRC rpmgiSetArgs(rpmgi gi, ARGV_t argv,
rpmRC rpmgiSetArgs(rpmgi gi, ARGV_const_t argv,
int ftsOpts, rpmgiFlags flags);

View File

@ -187,21 +187,19 @@ void * rpmShowProgress(const void * arg,
return rc;
}
typedef const char * str_t;
struct rpmEIU {
Header h;
FD_t fd;
int numFailed;
int numPkgs;
char ** pkgURL;
str_t * fnp;
char ** fnp;
char * pkgState;
int prevx;
int pkgx;
int numRPMS;
int numSRPMS;
str_t * sourceURL;
char ** sourceURL;
int isSource;
int argc;
char ** argv;
@ -210,9 +208,7 @@ struct rpmEIU {
};
/** @todo Generalize --freshen policies. */
int rpmInstall(rpmts ts,
struct rpmInstallArguments_s * ia,
const char ** fileArgv)
int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_t fileArgv)
{
struct rpmEIU * eiu = memset(alloca(sizeof(*eiu)), 0, sizeof(*eiu));
rpmps ps;
@ -378,7 +374,7 @@ if (fileURL[0] == '=') {
if (eiu->numFailed) goto exit;
/* Continue processing file arguments, building transaction set. */
for (eiu->fnp = (const char**) eiu->pkgURL+eiu->prevx;
for (eiu->fnp = eiu->pkgURL+eiu->prevx;
*eiu->fnp != NULL;
eiu->fnp++, eiu->prevx++)
{
@ -649,11 +645,10 @@ exit:
return eiu->numFailed;
}
int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia,
const char ** argv)
int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_const_t argv)
{
int count;
const char ** arg;
char * const * arg;
int numFailed = 0;
int stopUninstall = 0;
int numPackages = 0;

View File

@ -422,7 +422,7 @@ int showVerifyPackage(QVA_t qva, rpmts ts, Header h)
return ec;
}
int rpmcliVerify(rpmts ts, QVA_t qva, const char ** argv)
int rpmcliVerify(rpmts ts, QVA_t qva, char * const * argv)
{
rpmVSFlags vsflags, ovsflags;
int ec = 0;

View File

@ -60,7 +60,7 @@ ARGint_t argiData(const ARGI_t argi)
return vals;
}
int argvCount(const ARGV_t argv)
int argvCount(ARGV_const_t argv)
{
int argc = 0;
if (argv)
@ -69,7 +69,7 @@ int argvCount(const ARGV_t argv)
return argc;
}
ARGV_t argvData(const ARGV_t argv)
ARGV_t argvData(ARGV_t argv)
{
return argv;
}
@ -89,7 +89,7 @@ int argvSort(ARGV_t argv, int (*compar)(const void *, const void *))
return 0;
}
ARGV_t argvSearch(ARGV_t argv, const char *val,
ARGV_t argvSearch(ARGV_const_t argv, const char *val,
int (*compar)(const void *, const void *))
{
if (argv == NULL)
@ -135,7 +135,7 @@ int argvAdd(ARGV_t * argvp, const char *val)
return 0;
}
int argvAppend(ARGV_t * argvp, const ARGV_t av)
int argvAppend(ARGV_t * argvp, ARGV_const_t av)
{
ARGV_t argv = *argvp;
int argc = argvCount(argv);

View File

@ -12,6 +12,7 @@ extern "C" {
#endif
typedef char ** ARGV_t;
typedef char * const *ARGV_const_t;
typedef int * ARGint_t;
struct ARGI_s {
@ -61,14 +62,14 @@ ARGint_t argiData(const ARGI_t argi);
* @param argv argv array
* @return no. of elements
*/
int argvCount(const ARGV_t argv);
int argvCount(ARGV_const_t argv);
/** \ingroup rpmargv
* Return data from argv array.
* @param argv argv array
* @return argv array data address
*/
ARGV_t argvData(const ARGV_t argv);
ARGV_t argvData(ARGV_t argv);
/** \ingroup rpmargv
* Compare argv arrays (qsort/bsearch).
@ -93,7 +94,7 @@ int argvSort(ARGV_t argv, int (*compar)(const void *, const void *));
* @param compar strcmp-like comparison function, or NULL for argvCmp()
* @return found string (NULL on failure)
*/
ARGV_t argvSearch(ARGV_t argv, const char *val,
ARGV_t argvSearch(ARGV_const_t argv, const char *val,
int (*compar)(const void *, const void *));
/** \ingroup rpmargv
@ -119,7 +120,7 @@ int argvAdd(ARGV_t * argvp, const char *val);
* @param av argv array to append
* @return 0 always
*/
int argvAppend(ARGV_t * argvp, const ARGV_t av);
int argvAppend(ARGV_t * argvp, ARGV_const_t av);
/** \ingroup rpmargv
* Split a string into an argv array.

View File

@ -104,9 +104,9 @@ static int open_dso(const char * path, pid_t * pidp, rpm_off_t *fsizep)
xx = dup2(pipes[1], STDOUT_FILENO);
xx = close(pipes[1]);
if ((lib = argvSearch(av, "library", NULL)) != NULL) {
*lib = path;
*lib = (char *) path;
unsetenv("MALLOC_CHECK_");
xx = execve(av[0], (char *const *)av+1, environ);
xx = execve(av[0], av+1, environ);
}
_exit(127);
}

10
rpmqv.c
View File

@ -714,7 +714,7 @@ int main(int argc, char *argv[])
if (!poptPeekArg(optCon)) {
argerror(_("no packages given for erase"));
} else {
ec += rpmErase(ts, ia, (const char **) poptGetArgs(optCon));
ec += rpmErase(ts, ia, (ARGV_const_t) poptGetArgs(optCon));
}
break;
@ -749,7 +749,7 @@ int main(int argc, char *argv[])
argerror(_("no packages given for install"));
} else {
/* FIX: ia->relocations[0].newPath undefined */
ec += rpmInstall(ts, ia, (const char **)poptGetArgs(optCon));
ec += rpmInstall(ts, ia, (ARGV_t) poptGetArgs(optCon));
}
break;
@ -762,7 +762,7 @@ int main(int argc, char *argv[])
argerror(_("no arguments given for query"));
qva->qva_specQuery = rpmspecQuery;
ec = rpmcliQuery(ts, qva, (const char **) poptGetArgs(optCon));
ec = rpmcliQuery(ts, qva, (ARGV_const_t) poptGetArgs(optCon));
qva->qva_specQuery = NULL;
break;
@ -775,7 +775,7 @@ int main(int argc, char *argv[])
if (!poptPeekArg(optCon)
&& !(qva->qva_source == RPMQV_ALL || qva->qva_source == RPMQV_HDLIST))
argerror(_("no arguments given for verify"));
ec = rpmcliVerify(ts, qva, (const char **) poptGetArgs(optCon));
ec = rpmcliVerify(ts, qva, (ARGV_const_t) poptGetArgs(optCon));
} break;
#endif /* IAM_RPMQV */
@ -791,7 +791,7 @@ int main(int argc, char *argv[])
if (!poptPeekArg(optCon))
argerror(_("no arguments given"));
ka->passPhrase = passPhrase;
ec = rpmcliSign(ts, ka, (const char **)poptGetArgs(optCon));
ec = rpmcliSign(ts, ka, (ARGV_const_t) poptGetArgs(optCon));
break;
#endif /* IAM_RPMK */

View File

@ -62,7 +62,7 @@ char buf[BUFSIZ];
if (optCon == NULL)
goto exit;
av = poptGetArgs(optCon);
av = (ARGV_t) poptGetArgs(optCon);
ac = argvCount(av);
if (ac == 0) {