diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-07-31 21:11:03 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:38:27 -0500 |
commit | e7952e9c14218d0c8c13973056ab8762876e5a79 (patch) | |
tree | 8ac9dde3279137b31f603922565414c28aafcf56 | |
parent | 49001a5b1b07e9a24e5f7efa0dfd880772bdb435 (diff) | |
download | samba-e7952e9c14218d0c8c13973056ab8762876e5a79.tar.gz samba-e7952e9c14218d0c8c13973056ab8762876e5a79.tar.bz2 samba-e7952e9c14218d0c8c13973056ab8762876e5a79.zip |
r17347: Some C++ warnings -- 271 left
(This used to be commit 641dac4f85c0e00484d90726bea1a4cb58c8235c)
-rw-r--r-- | source3/popt/popt.c | 107 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 36 | ||||
-rw-r--r-- | source3/torture/msgtest.c | 11 |
3 files changed, 83 insertions, 71 deletions
diff --git a/source3/popt/popt.c b/source3/popt/popt.c index 45a8778b55..d9e8411b9f 100644 --- a/source3/popt/popt.c +++ b/source3/popt/popt.c @@ -51,7 +51,7 @@ static char * strerror(int errno) { void poptSetExecPath(poptContext con, const char * path, int allowAbsolute) { - con->execPath = _free(con->execPath); + con->execPath = (const char *)_free(con->execPath); con->execPath = xstrdup(path); con->execAbsolute = allowAbsolute; /*@-nullstate@*/ /* LCL: con->execPath can be NULL? */ @@ -68,7 +68,7 @@ static void invokeCallbacksPRE(poptContext con, const struct poptOption * opt) if (opt->arg == NULL) continue; /* XXX program error. */ if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { /* Recurse on included sub-tables. */ - invokeCallbacksPRE(con, opt->arg); + invokeCallbacksPRE(con, (const struct poptOption *)opt->arg); } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK && (opt->argInfo & POPT_CBFLAG_PRE)) { /*@-castfcnptr@*/ @@ -91,7 +91,7 @@ static void invokeCallbacksPOST(poptContext con, const struct poptOption * opt) if (opt->arg == NULL) continue; /* XXX program error. */ if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { /* Recurse on included sub-tables. */ - invokeCallbacksPOST(con, opt->arg); + invokeCallbacksPOST(con, (const struct poptOption *)opt->arg); } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK && (opt->argInfo & POPT_CBFLAG_POST)) { /*@-castfcnptr@*/ @@ -119,7 +119,8 @@ static void invokeCallbacksOPTION(poptContext con, if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { /* Recurse on included sub-tables. */ if (opt->arg != NULL) /* XXX program error */ - invokeCallbacksOPTION(con, opt->arg, myOpt, myData, shorty); + invokeCallbacksOPTION(con, (const struct poptOption *)opt->arg, + myOpt, myData, shorty); } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK && !(opt->argInfo & POPT_CBFLAG_SKIPOPTION)) { /* Save callback info. */ @@ -153,7 +154,7 @@ static void invokeCallbacksOPTION(poptContext con, poptContext poptGetContext(const char * name, int argc, const char ** argv, const struct poptOption * options, int flags) { - poptContext con = malloc(sizeof(*con)); + poptContext con = (poptContext)malloc(sizeof(*con)); if (con == NULL) return NULL; /* XXX can't happen */ memset(con, 0, sizeof(*con)); @@ -168,7 +169,8 @@ poptContext poptGetContext(const char * name, int argc, const char ** argv, if (!(flags & POPT_CONTEXT_KEEP_FIRST)) con->os->next = 1; /* skip argv[0] */ - con->leftovers = calloc( (argc + 1), sizeof(*con->leftovers) ); + con->leftovers = (const char **)calloc( (argc + 1), + sizeof(*con->leftovers) ); /*@-dependenttrans -assignexpose@*/ /* FIX: W2DO? */ con->options = options; /*@=dependenttrans =assignexpose@*/ @@ -178,7 +180,8 @@ poptContext poptGetContext(const char * name, int argc, const char ** argv, con->execs = NULL; con->numExecs = 0; con->finalArgvAlloced = argc * 2; - con->finalArgv = calloc( con->finalArgvAlloced, sizeof(*con->finalArgv) ); + con->finalArgv = (const char **)calloc( con->finalArgvAlloced, + sizeof(*con->finalArgv) ); con->execAbsolute = 1; con->arg_strip = NULL; @@ -186,7 +189,7 @@ poptContext poptGetContext(const char * name, int argc, const char ** argv, con->flags |= POPT_CONTEXT_POSIXMEHARDER; if (name) { - char * t = malloc(strlen(name) + 1); + char * t = (char *)malloc(strlen(name) + 1); if (t) con->appName = strcpy(t, name); } @@ -202,9 +205,9 @@ static void cleanOSE(/*@special@*/ struct optionStackEntry *os) /*@releases os->nextArg, os->argv, os->argb @*/ /*@modifies os @*/ { - os->nextArg = _free(os->nextArg); - os->argv = _free(os->argv); - os->argb = PBM_FREE(os->argb); + os->nextArg = (const char *)_free(os->nextArg); + os->argv = (const char **)_free(os->argv); + os->argb = (pbm_set *)PBM_FREE(os->argb); } /*@-boundswrite@*/ @@ -216,7 +219,7 @@ void poptResetContext(poptContext con) while (con->os > con->optionStack) { cleanOSE(con->os--); } - con->os->argb = PBM_FREE(con->os->argb); + con->os->argb = (pbm_set *)PBM_FREE(con->os->argb); con->os->currAlias = NULL; con->os->nextCharArg = NULL; con->os->nextArg = NULL; @@ -230,12 +233,12 @@ void poptResetContext(poptContext con) if (con->finalArgv != NULL) for (i = 0; i < con->finalArgvCount; i++) { /*@-unqualifiedtrans@*/ /* FIX: typedef double indirection. */ - con->finalArgv[i] = _free(con->finalArgv[i]); + con->finalArgv[i] = (const char *)_free(con->finalArgv[i]); /*@=unqualifiedtrans@*/ } con->finalArgvCount = 0; - con->arg_strip = PBM_FREE(con->arg_strip); + con->arg_strip = ( pbm_set *)PBM_FREE(con->arg_strip); /*@-nullstate@*/ /* FIX: con->finalArgv != NULL */ return; /*@=nullstate@*/ @@ -280,13 +283,13 @@ static int handleExec(/*@special@*/ poptContext con, time 'round */ if ((con->finalArgvCount + 1) >= (con->finalArgvAlloced)) { con->finalArgvAlloced += 10; - con->finalArgv = realloc(con->finalArgv, + con->finalArgv = (const char **)realloc(con->finalArgv, sizeof(*con->finalArgv) * con->finalArgvAlloced); } i = con->finalArgvCount++; if (con->finalArgv != NULL) /* XXX can't happen */ - { char *s = malloc((longName ? strlen(longName) : 0) + 3); + { char *s = (char *)malloc((longName ? strlen(longName) : 0) + 3); if (s != NULL) { /* XXX can't happen */ if (longName) sprintf(s, "--%s", longName); @@ -375,12 +378,13 @@ static int execCommand(poptContext con) (!con->execAbsolute && strchr(item->argv[0], '/'))) return POPT_ERROR_NOARG; - argv = malloc(sizeof(*argv) * - (6 + item->argc + con->numLeftovers + con->finalArgvCount)); + argv = (const char **)malloc( + sizeof(*argv) * (6 + item->argc + con->numLeftovers + con->finalArgvCount)); if (argv == NULL) return POPT_ERROR_MALLOC; /* XXX can't happen */ if (!strchr(item->argv[0], '/') && con->execPath) { - char *s = alloca(strlen(con->execPath) + strlen(item->argv[0]) + sizeof("/")); + char *s = (char *)alloca( + strlen(con->execPath) + strlen(item->argv[0]) + sizeof("/")); sprintf(s, "%s/%s", con->execPath, item->argv[0]); argv[argc] = s; } else { @@ -474,7 +478,8 @@ findOption(const struct poptOption * opt, /*@null@*/ const char * longName, /* Recurse on included sub-tables. */ if (opt->arg == NULL) continue; /* XXX program error */ - opt2 = findOption(opt->arg, longName, shortName, callback, + opt2 = findOption((const struct poptOption *)opt->arg, longName, + shortName, callback, callbackData, singleDash); if (opt2 == NULL) continue; /* Sub-table data will be inheirited if no data yet. */ @@ -546,7 +551,7 @@ static const char * findNextArg(/*@special@*/ poptContext con, /*@innercontinue@*/ continue; arg = os->argv[i]; if (delete_arg) { - if (os->argb == NULL) os->argb = PBM_ALLOC(os->argc); + if (os->argb == NULL) os->argb = (pbm_set *)PBM_ALLOC(os->argc); if (os->argb != NULL) /* XXX can't happen */ PBM_SET(i, os->argb); } @@ -571,7 +576,7 @@ expandNextArg(/*@special@*/ poptContext con, const char * s) size_t tn = strlen(s) + 1; char c; - te = t = malloc(tn);; + te = t = (char *)malloc(tn);; if (t == NULL) return NULL; /* XXX can't happen */ while ((c = *s++) != '\0') { switch (c) { @@ -593,7 +598,7 @@ expandNextArg(/*@special@*/ poptContext con, const char * s) alen = strlen(a); tn += alen; *te = '\0'; - t = realloc(t, tn); + t = (char *)realloc(t, tn); te = t + strlen(t); strncpy(te, a, alen); te += alen; continue; @@ -604,7 +609,7 @@ expandNextArg(/*@special@*/ poptContext con, const char * s) *te++ = c; } *te = '\0'; - t = realloc(t, strlen(t) + 1); /* XXX memory leak, hard to plug */ + t = (char *)realloc(t, strlen(t) + 1); /* XXX memory leak, hard to plug */ return t; } /*@=boundswrite@*/ @@ -616,7 +621,7 @@ static void poptStripArg(/*@special@*/ poptContext con, int which) { /*@-sizeoftype@*/ if (con->arg_strip == NULL) - con->arg_strip = PBM_ALLOC(con->optionStack[0].argc); + con->arg_strip = (pbm_set *)PBM_ALLOC(con->optionStack[0].argc); if (con->arg_strip != NULL) /* XXX can't happen */ PBM_SET(which, con->arg_strip); /*@=sizeoftype@*/ @@ -742,7 +747,8 @@ int poptGetNextOpt(poptContext con) /* Make a copy we can hack at */ localOptString = optString = - strcpy(alloca(strlen(origOptString) + 1), origOptString); + strcpy((char *)alloca(strlen(origOptString) + 1), + origOptString); if (optString[0] == '\0') return POPT_ERROR_BADOPT; @@ -835,7 +841,7 @@ int poptGetNextOpt(poptContext con) return POPT_ERROR_BADOPERATION; } } else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) { - con->os->nextArg = _free(con->os->nextArg); + con->os->nextArg = (const char *)_free(con->os->nextArg); /*@-usedef@*/ /* FIX: W2DO? */ if (longArg) { /*@=usedef@*/ @@ -960,12 +966,13 @@ int poptGetNextOpt(poptContext con) if ((con->finalArgvCount + 2) >= (con->finalArgvAlloced)) { con->finalArgvAlloced += 10; - con->finalArgv = realloc(con->finalArgv, + con->finalArgv = (const char **)realloc(con->finalArgv, sizeof(*con->finalArgv) * con->finalArgvAlloced); } if (con->finalArgv != NULL) - { char *s = malloc((opt->longName ? strlen(opt->longName) : 0) + 3); + { char *s = (char *)malloc( + (opt->longName ? strlen(opt->longName) : 0) + 3); if (s != NULL) { /* XXX can't happen */ if (opt->longName) sprintf(s, "%s%s", @@ -1046,47 +1053,47 @@ poptContext poptFreeContext(poptContext con) if (con == NULL) return con; poptResetContext(con); - con->os->argb = _free(con->os->argb); + con->os->argb = (pbm_set *)_free(con->os->argb); if (con->aliases != NULL) for (i = 0; i < con->numAliases; i++) { item = con->aliases + i; /*@-modobserver -observertrans -dependenttrans@*/ - item->option.longName = _free(item->option.longName); - item->option.descrip = _free(item->option.descrip); - item->option.argDescrip = _free(item->option.argDescrip); + item->option.longName = (const char *)_free(item->option.longName); + item->option.descrip = (const char *)_free(item->option.descrip); + item->option.argDescrip = (const char *)_free(item->option.argDescrip); /*@=modobserver =observertrans =dependenttrans@*/ - item->argv = _free(item->argv); + item->argv = (const char **)_free(item->argv); } - con->aliases = _free(con->aliases); + con->aliases = (poptItem)_free(con->aliases); if (con->execs != NULL) for (i = 0; i < con->numExecs; i++) { item = con->execs + i; /*@-modobserver -observertrans -dependenttrans@*/ - item->option.longName = _free(item->option.longName); - item->option.descrip = _free(item->option.descrip); - item->option.argDescrip = _free(item->option.argDescrip); + item->option.longName = (const char *)_free(item->option.longName); + item->option.descrip = (const char *)_free(item->option.descrip); + item->option.argDescrip = (const char *)_free(item->option.argDescrip); /*@=modobserver =observertrans =dependenttrans@*/ - item->argv = _free(item->argv); + item->argv = (const char **)_free(item->argv); } - con->execs = _free(con->execs); - - con->leftovers = _free(con->leftovers); - con->finalArgv = _free(con->finalArgv); - con->appName = _free(con->appName); - con->otherHelp = _free(con->otherHelp); - con->execPath = _free(con->execPath); - con->arg_strip = PBM_FREE(con->arg_strip); + con->execs = (poptItem)_free(con->execs); + + con->leftovers = (const char **)_free(con->leftovers); + con->finalArgv = (const char **)_free(con->finalArgv); + con->appName = (const char *)_free(con->appName); + con->otherHelp = (const char *)_free(con->otherHelp); + con->execPath = (const char *)_free(con->execPath); + con->arg_strip = (pbm_set *)PBM_FREE(con->arg_strip); - con = _free(con); + con = (poptContext)_free(con); return con; } int poptAddAlias(poptContext con, struct poptAlias alias, /*@unused@*/ int flags) { - poptItem item = alloca(sizeof(*item)); + poptItem item = (poptItem)alloca(sizeof(*item)); memset(item, 0, sizeof(*item)); item->option.longName = alias.longName; item->option.shortName = alias.shortName; @@ -1121,7 +1128,7 @@ int poptAddItem(poptContext con, poptItem newItem, int flags) /*@notreached@*/ break; } - *items = realloc((*items), ((*nitems) + 1) * sizeof(**items)); + *items = (poptItem)realloc((*items), ((*nitems) + 1) * sizeof(**items)); if ((*items) == NULL) return 1; diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 8eb8790975..82052127c9 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -1043,7 +1043,7 @@ static mode_t unix_perms_from_wire( connection_struct *conn, SMB_STRUCT_STAT *ps ****************************************************************************/ static BOOL get_lanman2_dir_entry(connection_struct *conn, - void *inbuf, void *outbuf, + void *inbuf, char *outbuf, char *path_mask,uint32 dirtype,int info_level, int requires_resume_key, BOOL dont_descend,char **ppdata, @@ -1751,7 +1751,8 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd } } - *ppdata = SMB_REALLOC(*ppdata, max_data_bytes + DIR_ENTRY_SAFETY_MARGIN); + *ppdata = (char *)SMB_REALLOC( + *ppdata, max_data_bytes + DIR_ENTRY_SAFETY_MARGIN); if(*ppdata == NULL ) { talloc_destroy(ea_ctx); return ERROR_NT(NT_STATUS_NO_MEMORY); @@ -1759,7 +1760,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd pdata = *ppdata; /* Realloc the params space */ - *pparams = SMB_REALLOC(*pparams, 10); + *pparams = (char *)SMB_REALLOC(*pparams, 10); if (*pparams == NULL) { talloc_destroy(ea_ctx); return ERROR_NT(NT_STATUS_NO_MEMORY); @@ -2002,7 +2003,8 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd } } - *ppdata = SMB_REALLOC( *ppdata, max_data_bytes + DIR_ENTRY_SAFETY_MARGIN); + *ppdata = (char *)SMB_REALLOC( + *ppdata, max_data_bytes + DIR_ENTRY_SAFETY_MARGIN); if(*ppdata == NULL) { talloc_destroy(ea_ctx); return ERROR_NT(NT_STATUS_NO_MEMORY); @@ -2011,7 +2013,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd pdata = *ppdata; /* Realloc the params space */ - *pparams = SMB_REALLOC(*pparams, 6*SIZEOFWORD); + *pparams = (char *)SMB_REALLOC(*pparams, 6*SIZEOFWORD); if(*pparams == NULL ) { talloc_destroy(ea_ctx); return ERROR_NT(NT_STATUS_NO_MEMORY); @@ -2175,7 +2177,8 @@ static int call_trans2qfsinfo(connection_struct *conn, char *inbuf, char *outbuf return ERROR_DOS(ERRSRV,ERRinvdevice); } - *ppdata = SMB_REALLOC(*ppdata, max_data_bytes + DIR_ENTRY_SAFETY_MARGIN); + *ppdata = (char *)SMB_REALLOC( + *ppdata, max_data_bytes + DIR_ENTRY_SAFETY_MARGIN); if (*ppdata == NULL ) { return ERROR_NT(NT_STATUS_NO_MEMORY); } @@ -3016,7 +3019,8 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd } /* Copy the lock range data. */ - lock_data = talloc_memdup(data_ctx, pdata, total_data); + lock_data = (char *)talloc_memdup( + data_ctx, pdata, total_data); if (!lock_data) { talloc_destroy(data_ctx); return ERROR_NT(NT_STATUS_NO_MEMORY); @@ -3026,7 +3030,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd break; } - *pparams = SMB_REALLOC(*pparams,2); + *pparams = (char *)SMB_REALLOC(*pparams,2); if (*pparams == NULL) { talloc_destroy(data_ctx); return ERROR_NT(NT_STATUS_NO_MEMORY); @@ -3034,7 +3038,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd params = *pparams; SSVAL(params,0,0); data_size = max_data_bytes + DIR_ENTRY_SAFETY_MARGIN; - *ppdata = SMB_REALLOC(*ppdata, data_size); + *ppdata = (char *)SMB_REALLOC(*ppdata, data_size); if (*ppdata == NULL ) { talloc_destroy(data_ctx); return ERROR_NT(NT_STATUS_NO_MEMORY); @@ -3841,7 +3845,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char tran_call,fname, fsp ? fsp->fnum : -1, info_level,total_data)); /* Realloc the parameter size */ - *pparams = SMB_REALLOC(*pparams,2); + *pparams = (char *)SMB_REALLOC(*pparams,2); if (*pparams == NULL) { return ERROR_NT(NT_STATUS_NO_MEMORY); } @@ -4822,7 +4826,7 @@ static int call_trans2mkdir(connection_struct *conn, char *inbuf, char *outbuf, } /* Realloc the parameter and data sizes */ - *pparams = SMB_REALLOC(*pparams,2); + *pparams = (char *)SMB_REALLOC(*pparams,2); if(*pparams == NULL) { return ERROR_NT(NT_STATUS_NO_MEMORY); } @@ -4864,7 +4868,7 @@ static int call_trans2findnotifyfirst(connection_struct *conn, char *inbuf, char } /* Realloc the parameter and data sizes */ - *pparams = SMB_REALLOC(*pparams,6); + *pparams = (char *)SMB_REALLOC(*pparams,6); if (*pparams == NULL) { return ERROR_NT(NT_STATUS_NO_MEMORY); } @@ -4898,7 +4902,7 @@ static int call_trans2findnotifynext(connection_struct *conn, char *inbuf, char DEBUG(3,("call_trans2findnotifynext\n")); /* Realloc the parameter and data sizes */ - *pparams = SMB_REALLOC(*pparams,4); + *pparams = (char *)SMB_REALLOC(*pparams,4); if (*pparams == NULL) { return ERROR_NT(NT_STATUS_NO_MEMORY); } @@ -4967,7 +4971,7 @@ static int call_trans2ioctl(connection_struct *conn, char* inbuf, char* outbuf, if ((SVAL(inbuf,(smb_setup+4)) == LMCAT_SPL) && (SVAL(inbuf,(smb_setup+6)) == LMFUNC_GETJOBID)) { - *ppdata = SMB_REALLOC(*ppdata, 32); + *ppdata = (char *)SMB_REALLOC(*ppdata, 32); if (*ppdata == NULL) { return ERROR_NT(NT_STATUS_NO_MEMORY); } @@ -5289,7 +5293,7 @@ int reply_trans2(connection_struct *conn, char *inbuf,char *outbuf, if (state->total_data) { /* Can't use talloc here, the core routines do realloc on the * params and data. */ - state->data = SMB_MALLOC(state->total_data); + state->data = (char *)SMB_MALLOC(state->total_data); if (state->data == NULL) { DEBUG(0,("reply_trans2: data malloc fail for %u " "bytes !\n", (unsigned int)state->total_data)); @@ -5309,7 +5313,7 @@ int reply_trans2(connection_struct *conn, char *inbuf,char *outbuf, if (state->total_param) { /* Can't use talloc here, the core routines do realloc on the * params and data. */ - state->param = SMB_MALLOC(state->total_param); + state->param = (char *)SMB_MALLOC(state->total_param); if (state->param == NULL) { DEBUG(0,("reply_trans: param malloc fail for %u " "bytes !\n", (unsigned int)state->total_param)); diff --git a/source3/torture/msgtest.c b/source3/torture/msgtest.c index 557f4edf88..0c7b57f80c 100644 --- a/source3/torture/msgtest.c +++ b/source3/torture/msgtest.c @@ -66,7 +66,8 @@ void pong_message(int msg_type, struct process_id src, void *buf, size_t len) message_init(); if (argc != 3) { - fprintf(stderr, "%s: Usage - %s pid count\n", argv[0], argv[0]); + fprintf(stderr, "%s: Usage - %s pid count\n", argv[0], + argv[0]); exit(1); } @@ -115,11 +116,11 @@ void pong_message(int msg_type, struct process_id src, void *buf, size_t len) size_t ping_count = 0; printf("Sending pings for %d seconds\n", (int)timelimit); - while (timeval_elapsed(&tv) < timelimit) { + while (timeval_elapsed(&tv) < timelimit) { if(message_send_pid(pid_to_procid(pid), MSG_PING, - buf, 11, False)) ping_count++; + buf, 11, False)) ping_count++; if(message_send_pid(pid_to_procid(pid), MSG_PING, - NULL, 0, False)) ping_count++; + NULL, 0, False)) ping_count++; while (ping_count > pong_count + 20) { message_dispatch(); @@ -138,7 +139,7 @@ void pong_message(int msg_type, struct process_id src, void *buf, size_t len) } printf("ping rate of %.0f messages/sec\n", - (ping_count+pong_count)/timeval_elapsed(&tv)); + (ping_count+pong_count)/timeval_elapsed(&tv)); } return (0); |