summaryrefslogtreecommitdiffstats
path: root/source3/popt
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-07-25 18:47:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:28:59 -0500
commit70faa40a2dc67344d530dec8d12186cdf177ee4a (patch)
tree8aae9ae02b5572e30c2e58205347412bb808c2c7 /source3/popt
parent5e066d5ee1b2e8d15a7af80313eb2b622a511b00 (diff)
downloadsamba-70faa40a2dc67344d530dec8d12186cdf177ee4a.tar.gz
samba-70faa40a2dc67344d530dec8d12186cdf177ee4a.tar.xz
samba-70faa40a2dc67344d530dec8d12186cdf177ee4a.zip
r24048: Fix the C++ warnings in our version of popt
(This used to be commit fd3683c1b3d89a47d59643b0f5751726cb2c89f9)
Diffstat (limited to 'source3/popt')
-rw-r--r--source3/popt/poptconfig.c8
-rw-r--r--source3/popt/popthelp.c38
-rw-r--r--source3/popt/poptparse.c16
3 files changed, 32 insertions, 30 deletions
diff --git a/source3/popt/poptconfig.c b/source3/popt/poptconfig.c
index 5941c2b7045..837828ccf92 100644
--- a/source3/popt/poptconfig.c
+++ b/source3/popt/poptconfig.c
@@ -18,7 +18,7 @@ static void configLine(poptContext con, char * line)
/*@=type@*/
const char * entryType;
const char * opt;
- poptItem item = alloca(sizeof(*item));
+ poptItem item = (poptItem)alloca(sizeof(*item));
int i, j;
/*@-boundswrite@*/
@@ -114,7 +114,7 @@ int poptReadConfigFile(poptContext con, const char * fn)
return POPT_ERROR_ERRNO;
}
- file = alloca(fileLength + 1);
+ file = (const char *)alloca(fileLength + 1);
if (read(fd, (char *)file, fileLength) != fileLength) {
rc = errno;
(void) close(fd);
@@ -127,7 +127,7 @@ int poptReadConfigFile(poptContext con, const char * fn)
return POPT_ERROR_ERRNO;
/*@-boundswrite@*/
- dst = buf = alloca(fileLength + 1);
+ dst = buf = (char *)alloca(fileLength + 1);
chptr = file;
end = (file + fileLength);
@@ -179,7 +179,7 @@ int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
#endif
if ((home = getenv("HOME"))) {
- fn = alloca(strlen(home) + 20);
+ fn = (char *)alloca(strlen(home) + 20);
strcpy(fn, home);
strcat(fn, "/.popt");
rc = poptReadConfigFile(con, fn);
diff --git a/source3/popt/popthelp.c b/source3/popt/popthelp.c
index 70566a389e2..e965ff6168e 100644
--- a/source3/popt/popthelp.c
+++ b/source3/popt/popthelp.c
@@ -76,7 +76,7 @@ getTableTranslationDomain(/*@null@*/ const struct poptOption *table)
if (table != NULL)
for (opt = table; opt->longName || opt->shortName || opt->arg; opt++) {
if (opt->argInfo == POPT_ARG_INTL_DOMAIN)
- return opt->arg;
+ return (char *)opt->arg;
}
return NULL;
}
@@ -131,7 +131,7 @@ singleOptionDefaultValue(int lineLength,
/*@*/
{
const char * defstr = D_(translation_domain, "default");
- char * le = malloc(4*lineLength + 1);
+ char * le = (char *)malloc(4*lineLength + 1);
char * l = le;
if (le == NULL) return NULL; /* XXX can't happen */
@@ -176,7 +176,7 @@ singleOptionDefaultValue(int lineLength,
} break;
case POPT_ARG_NONE:
default:
- l = _free(l);
+ l = (char *)_free(l);
return NULL;
/*@notreached@*/ break;
}
@@ -214,7 +214,7 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
if (argDescrip) nb += strlen(argDescrip);
/*@-boundswrite@*/
- left = malloc(nb);
+ left = (char *)malloc(nb);
if (left == NULL) return; /* XXX can't happen */
left[0] = '\0';
left[maxLeftCol] = '\0';
@@ -242,7 +242,7 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
if (opt->argInfo & POPT_ARGFLAG_SHOW_DEFAULT) {
defs = singleOptionDefaultValue(lineLength, opt, translation_domain);
if (defs) {
- char * t = malloc((help ? strlen(help) : 0) +
+ char * t = (char *)malloc((help ? strlen(help) : 0) +
strlen(defs) + sizeof(" "));
if (t) {
char * te = t;
@@ -252,7 +252,7 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
}
*te++ = ' ';
strcpy(te, defs);
- defs = _free(defs);
+ defs = (char *)_free(defs);
}
defs = t;
}
@@ -323,7 +323,7 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
goto out;
}
- left = _free(left);
+ left = (char *)_free(left);
if (defs) {
help = defs; defs = NULL;
}
@@ -354,9 +354,9 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
out:
/*@-dependenttrans@*/
- defs = _free(defs);
+ defs = (char *)_free(defs);
/*@=dependenttrans@*/
- left = _free(left);
+ left = (char *)_free(left);
}
/**
@@ -375,7 +375,7 @@ static int maxArgWidth(const struct poptOption * opt,
while (opt->longName || opt->shortName || opt->arg) {
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
if (opt->arg) /* XXX program error */
- len = maxArgWidth(opt->arg, translation_domain);
+ len = maxArgWidth((const struct poptOption *)opt->arg, translation_domain);
if (len > max) max = len;
} else if (!(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) {
len = sizeof(" ")-1;
@@ -461,14 +461,15 @@ static void singleTableHelp(poptContext con, FILE * fp,
for (opt = table; (opt->longName || opt->shortName || opt->arg); opt++) {
if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_INCLUDE_TABLE)
continue;
- sub_transdom = getTableTranslationDomain(opt->arg);
+ sub_transdom = getTableTranslationDomain(
+ (const struct poptOption *)opt->arg);
if (sub_transdom == NULL)
sub_transdom = translation_domain;
if (opt->descrip)
fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip));
- singleTableHelp(con, fp, opt->arg, left, sub_transdom);
+ singleTableHelp(con, fp, (const struct poptOption *)opt->arg, left, sub_transdom);
}
}
@@ -653,7 +654,7 @@ static int singleTableUsage(poptContext con, FILE * fp, int cursor,
done->opts[done->nopts++] = (const void *) opt->arg;
/*@=boundswrite@*/
}
- cursor = singleTableUsage(con, fp, cursor, opt->arg,
+ cursor = singleTableUsage(con, fp, cursor, (const struct poptOption *)opt->arg,
translation_domain, done);
} else if ((opt->longName || opt->shortName) &&
!(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) {
@@ -680,7 +681,7 @@ static int showShortOptions(const struct poptOption * opt, FILE * fp,
/*@requires maxRead(str) >= 0 @*/
{
/* bufsize larger then the ascii set, lazy alloca on top level call. */
- char * s = (str != NULL ? str : memset(alloca(300), 0, 300));
+ char * s = (str != NULL ? str : (char *)memset(alloca(300), 0, 300));
int len = 0;
/*@-boundswrite@*/
@@ -690,7 +691,8 @@ static int showShortOptions(const struct poptOption * opt, FILE * fp,
s[strlen(s)] = opt->shortName;
else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE)
if (opt->arg) /* XXX program error */
- len = showShortOptions(opt->arg, fp, s);
+ len = showShortOptions(
+ (const struct poptOption *)opt->arg, fp, s);
}
/*@=boundswrite@*/
@@ -704,14 +706,14 @@ static int showShortOptions(const struct poptOption * opt, FILE * fp,
void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags)
{
- poptDone done = memset(alloca(sizeof(*done)), 0, sizeof(*done));
+ poptDone done = (poptDone)memset(alloca(sizeof(*done)), 0, sizeof(*done));
int cursor;
done->nopts = 0;
done->maxopts = 64;
cursor = done->maxopts * sizeof(*done->opts);
/*@-boundswrite@*/
- done->opts = memset(alloca(cursor), 0, cursor);
+ done->opts = (const void **)memset(alloca(cursor), 0, cursor);
done->opts[done->nopts++] = (const void *) con->options;
/*@=boundswrite@*/
@@ -732,7 +734,7 @@ void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags)
void poptSetOtherOptionHelp(poptContext con, const char * text)
{
- con->otherHelp = _free(con->otherHelp);
+ con->otherHelp = (const char *)_free(con->otherHelp);
con->otherHelp = xstrdup(text);
}
/*@=type@*/
diff --git a/source3/popt/poptparse.c b/source3/popt/poptparse.c
index 537ec443981..b03deef0850 100644
--- a/source3/popt/poptparse.c
+++ b/source3/popt/poptparse.c
@@ -27,10 +27,10 @@ int poptDupArgv(int argc, const char **argv,
nb += strlen(argv[i]) + 1;
}
- dst = malloc(nb);
+ dst = (char *)malloc(nb);
if (dst == NULL) /* XXX can't happen */
return POPT_ERROR_MALLOC;
- argv2 = (void *) dst;
+ argv2 = (const char **) dst;
dst += (argc + 1) * sizeof(*argv);
/*@-branchstate@*/
@@ -59,10 +59,10 @@ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
const char * src;
char quote = '\0';
int argvAlloced = POPT_ARGV_ARRAY_GROW_DELTA;
- const char ** argv = malloc(sizeof(*argv) * argvAlloced);
+ const char ** argv = (const char **)malloc(sizeof(*argv) * argvAlloced);
int argc = 0;
int buflen = strlen(s) + 1;
- char * buf = memset(alloca(buflen), 0, buflen);
+ char * buf = (char*)memset(alloca(buflen), 0, buflen);
int rc = POPT_ERROR_MALLOC;
if (argv == NULL) return rc;
@@ -86,7 +86,7 @@ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
buf++, argc++;
if (argc == argvAlloced) {
argvAlloced += POPT_ARGV_ARRAY_GROW_DELTA;
- argv = realloc(argv, sizeof(*argv) * argvAlloced);
+ argv = (const char **)realloc(argv, sizeof(*argv) * argvAlloced);
if (argv == NULL) goto exit;
}
argv[argc] = buf;
@@ -149,7 +149,7 @@ int poptConfigFileToString(FILE *fp, char ** argstrp, /*@unused@*/ int flags)
if (fp == NULL)
return POPT_ERROR_NULLARG;
- argstr = calloc(maxargvlen, sizeof(*argstr));
+ argstr = (char *)calloc(maxargvlen, sizeof(*argstr));
if (argstr == NULL) return POPT_ERROR_MALLOC;
while (fgets(line, (int)maxlinelen, fp) != NULL) {
@@ -183,7 +183,7 @@ int poptConfigFileToString(FILE *fp, char ** argstrp, /*@unused@*/ int flags)
argvlen += (t = q - p) + (sizeof(" --")-1);
if (argvlen >= maxargvlen) {
maxargvlen = (t > maxargvlen) ? t*2 : maxargvlen*2;
- argstr = realloc(argstr, maxargvlen);
+ argstr = (char *)realloc(argstr, maxargvlen);
if (argstr == NULL) return POPT_ERROR_MALLOC;
}
strcat(argstr, " --");
@@ -212,7 +212,7 @@ int poptConfigFileToString(FILE *fp, char ** argstrp, /*@unused@*/ int flags)
argvlen += t + (sizeof("' --='")-1);
if (argvlen >= maxargvlen) {
maxargvlen = (t > maxargvlen) ? t*2 : maxargvlen*2;
- argstr = realloc(argstr, maxargvlen);
+ argstr = (char *)realloc(argstr, maxargvlen);
if (argstr == NULL) return POPT_ERROR_MALLOC;
}
strcat(argstr, " --");