From bbf37faa0f764fde2a2ad2a49281f0c2cd6378dd Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Mon, 2 Feb 2009 21:13:42 +0000 Subject: [PATCH] Get rid of casts of free() argument to char*, except where it's casting away const (so as to make this change warning-neutral), and in unicode source (which we may want to keep in sync with another source), and krb5_xfree macro (to be handled separately). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21870 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/gssftp/ftp/cmds.c | 8 +++--- src/appl/gssftp/ftpd/ftpcmd.y | 42 ++++++++++++++++---------------- src/appl/gssftp/ftpd/popen.c | 2 +- src/kadmin/ktutil/ktutil_funcs.c | 6 ++--- src/kdc/kdc_util.c | 2 +- src/lib/krb5/ccache/cc_file.c | 6 ++--- src/lib/krb5/ccache/cc_keyring.c | 6 ++--- src/lib/krb5/krb/copy_princ.c | 2 +- src/lib/krb5/krb/parse.c | 4 +-- src/lib/krb5/rcache/rc_base.c | 16 ++++++------ src/lib/krb5/rcache/rc_conv.c | 4 +-- src/lib/krb5/rcache/rc_io.c | 7 +++--- src/tests/verify/kdb5_verify.c | 4 +-- src/util/ss/invocation.c | 4 +-- 14 files changed, 54 insertions(+), 59 deletions(-) diff --git a/src/appl/gssftp/ftp/cmds.c b/src/appl/gssftp/ftp/cmds.c index ac7a8039f..9afefe118 100644 --- a/src/appl/gssftp/ftp/cmds.c +++ b/src/appl/gssftp/ftp/cmds.c @@ -796,7 +796,7 @@ void mput(argc, argv) printf("%s\n", globerr); if (gargs) { blkfree(gargs); - free((char *)gargs); + free(gargs); } continue; } @@ -818,7 +818,7 @@ void mput(argc, argv) } if (gargs != NULL) { blkfree(gargs); - free((char *)gargs); + free(gargs); } } (void) signal(SIGINT, oldintr); @@ -1959,7 +1959,7 @@ static int globulize(cpp) printf("%s: %s\n", *cpp, globerr); if (globbed) { blkfree(globbed); - free((char *)globbed); + free(globbed); } return (0); } @@ -1969,7 +1969,7 @@ static int globulize(cpp) /* don't waste too much memory */ if (*globbed) { blkfree(globbed1); - free((char *)globbed); + free(globbed); } } return (1); diff --git a/src/appl/gssftp/ftpd/ftpcmd.y b/src/appl/gssftp/ftpd/ftpcmd.y index a57b43587..1b820f90d 100644 --- a/src/appl/gssftp/ftpd/ftpcmd.y +++ b/src/appl/gssftp/ftpd/ftpcmd.y @@ -200,12 +200,12 @@ cmd_list: /* empty */ cmd: USER SP username CRLF { user((char *) $3); - free((char *) $3); + free($3); } | PASS SP password CRLF { pass((char *) $3); - free((char *) $3); + free($3); } | PORT SP host_port CRLF { @@ -349,21 +349,21 @@ cmd: USER SP username CRLF if ($2 && $4 != NULL) retrieve((char *) 0, (char *) $4); if ($4 != NULL) - free((char *) $4); + free($4); } | STOR check_login SP pathname CRLF { if ($2 && $4 != NULL) store_file((char *) $4, "w", 0); if ($4 != NULL) - free((char *) $4); + free($4); } | APPE check_login SP pathname CRLF { if ($2 && $4 != NULL) store_file((char *) $4, "a", 0); if ($4 != NULL) - free((char *) $4); + free($4); } | NLST check_login CRLF { @@ -375,7 +375,7 @@ cmd: USER SP username CRLF if ($2 && $4 != NULL) send_file_list((char *) $4); if ($4 != NULL) - free((char *) $4); + free($4); } | LIST check_login CRLF { @@ -387,14 +387,14 @@ cmd: USER SP username CRLF if ($2 && $4 != NULL) retrieve("/bin/ls -lgA %s", (char *) $4); if ($4 != NULL) - free((char *) $4); + free($4); } | STAT check_login SP pathname CRLF { if ($2 && $4 != NULL) statfilecmd((char *) $4); if ($4 != NULL) - free((char *) $4); + free($4); } | STAT CRLF { @@ -405,7 +405,7 @@ cmd: USER SP username CRLF if ($2 && $4 != NULL) delete_file((char *) $4); if ($4 != NULL) - free((char *) $4); + free($4); } | RNTO SP pathname CRLF { @@ -416,7 +416,7 @@ cmd: USER SP username CRLF } else { reply(503, "Bad sequence of commands."); } - free((char *) $3); + free($3); } | ABOR CRLF { @@ -432,7 +432,7 @@ cmd: USER SP username CRLF if ($2 && $4 != NULL) cwd((char *) $4); if ($4 != NULL) - free((char *) $4); + free($4); } | HELP CRLF { @@ -462,14 +462,14 @@ cmd: USER SP username CRLF if ($2 && $4 != NULL) makedir((char *) $4); if ($4 != NULL) - free((char *) $4); + free($4); } | RMD nonguest SP pathname CRLF { if ($2 && $4 != NULL) removedir((char *) $4); if ($4 != NULL) - free((char *) $4); + free($4); } | PWD check_login CRLF { @@ -526,7 +526,7 @@ cmd: USER SP username CRLF reply(200, "CHMOD command successful."); } if ($8 != NULL) - free((char *) $8); + free($8); } | SITE SP IDLE CRLF { @@ -553,7 +553,7 @@ cmd: USER SP username CRLF if ($2 && $4 != NULL) store_file((char *) $4, "w", 1); if ($4 != NULL) - free((char *) $4); + free($4); } | SYST CRLF { @@ -584,7 +584,7 @@ cmd: USER SP username CRLF if ($2 && $4 != NULL) sizecmd((char *) $4); if ($4 != NULL) - free((char *) $4); + free($4); } /* @@ -617,7 +617,7 @@ cmd: USER SP username CRLF } } if ($4 != NULL) - free((char *) $4); + free($4); } | AUTH SP STRING CRLF { @@ -626,7 +626,7 @@ cmd: USER SP username CRLF | ADAT SP STRING CRLF { auth_data((char *) $3); - free((char *) $3); + free($3); } | QUIT CRLF { @@ -644,7 +644,7 @@ rcmd: RNFR check_login SP pathname CRLF if ($2 && $4) { fromname = renamefrom((char *) $4); if (fromname == (char *) 0 && $4) { - free((char *) $4); + free($4); } } } @@ -803,10 +803,10 @@ pathname: pathstring $$ = $1; else { reply(550, "%s", globerr); - free((char *) $1); + free($1); } } else - free((char *) $1); + free($1); } else $$ = $1; } diff --git a/src/appl/gssftp/ftpd/popen.c b/src/appl/gssftp/ftpd/popen.c index e9e589594..4f4f1586c 100644 --- a/src/appl/gssftp/ftpd/popen.c +++ b/src/appl/gssftp/ftpd/popen.c @@ -142,7 +142,7 @@ ftpd_popen(program, type) pfree: for (argc = 1; argv[argc] != NULL; argc++) { blkfree((char **)argv[argc]); - free((char *)argv[argc]); + free(argv[argc]); } return(iop); } diff --git a/src/kadmin/ktutil/ktutil_funcs.c b/src/kadmin/ktutil/ktutil_funcs.c index 168087518..c39448c20 100644 --- a/src/kadmin/ktutil/ktutil_funcs.c +++ b/src/kadmin/ktutil/ktutil_funcs.c @@ -43,12 +43,12 @@ krb5_error_code ktutil_free_kt_list(context, list) for (lp = list; lp;) { retval = krb5_kt_free_entry(context, lp->entry); - free((char *)lp->entry); + free(lp->entry); if (retval) break; prev = lp; lp = lp->next; - free((char *)prev); + free(prev); } return retval; } @@ -283,7 +283,7 @@ krb5_error_code ktutil_read_keytab(context, name, list) lp->entry = entry; } if (entry) - free((char *)entry); + free(entry); if (retval) { if (retval == KRB5_KT_END) retval = 0; diff --git a/src/kdc/kdc_util.c b/src/kdc/kdc_util.c index 28b4a37ca..140ba78b6 100644 --- a/src/kdc/kdc_util.c +++ b/src/kdc/kdc_util.c @@ -145,7 +145,7 @@ concat_authorization_data(krb5_authdata **first, krb5_authdata **second, *retdata[i] = **ptr; if (!(retdata[i]->contents = (krb5_octet *)malloc(retdata[i]->length))) { - free((char *)retdata[i]); + free(retdata[i]); retdata[i] = 0; krb5_free_authdata(kdc_context, retdata); return ENOMEM; diff --git a/src/lib/krb5/ccache/cc_file.c b/src/lib/krb5/ccache/cc_file.c index 9e54d1bdd..d8257a231 100644 --- a/src/lib/krb5/ccache/cc_file.c +++ b/src/lib/krb5/ccache/cc_file.c @@ -506,7 +506,7 @@ krb5_fcc_read_principal(krb5_context context, krb5_ccache id, krb5_principal *pr } tmpprinc->data = ALLOC (msize, krb5_data); if (tmpprinc->data == 0) { - free((char *)tmpprinc); + free(tmpprinc); return KRB5_CC_NOMEM; } } else @@ -531,8 +531,8 @@ krb5_fcc_read_principal(krb5_context context, krb5_ccache id, krb5_principal *pr while(--i >= 0) free(krb5_princ_component(context, tmpprinc, i)->data); free(krb5_princ_realm(context, tmpprinc)->data); - free((char *)tmpprinc->data); - free((char *)tmpprinc); + free(tmpprinc->data); + free(tmpprinc); return kret; } diff --git a/src/lib/krb5/ccache/cc_keyring.c b/src/lib/krb5/ccache/cc_keyring.c index 528f43f06..9353fd497 100644 --- a/src/lib/krb5/ccache/cc_keyring.c +++ b/src/lib/krb5/ccache/cc_keyring.c @@ -1388,7 +1388,7 @@ krb5_krcc_parse_principal(krb5_context context, krb5_ccache id, } tmpprinc->data = ALLOC(msize, krb5_data); if (tmpprinc->data == 0) { - free((char *) tmpprinc); + free(tmpprinc); return KRB5_CC_NOMEM; } } else @@ -1415,8 +1415,8 @@ krb5_krcc_parse_principal(krb5_context context, krb5_ccache id, while (--i >= 0) free(krb5_princ_component(context, tmpprinc, i)->data); free(krb5_princ_realm(context, tmpprinc)->data); - free((char *) tmpprinc->data); - free((char *) tmpprinc); + free(tmpprinc->data); + free(tmpprinc); return kret; } diff --git a/src/lib/krb5/krb/copy_princ.c b/src/lib/krb5/krb/copy_princ.c index 85dc816ad..14af7b5f3 100644 --- a/src/lib/krb5/krb/copy_princ.c +++ b/src/lib/krb5/krb/copy_princ.c @@ -49,7 +49,7 @@ krb5_copy_principal(krb5_context context, krb5_const_principal inprinc, krb5_pri tempprinc->data = malloc(nelems * sizeof(krb5_data)); if (tempprinc->data == 0) { - free((char *)tempprinc); + free(tempprinc); return ENOMEM; } diff --git a/src/lib/krb5/krb/parse.c b/src/lib/krb5/krb/parse.c index d55a488e3..5dd29fb43 100644 --- a/src/lib/krb5/krb/parse.c +++ b/src/lib/krb5/krb/parse.c @@ -148,7 +148,7 @@ k5_parse_name(krb5_context context, const char *name, } principal->data = (krb5_data *) malloc(sizeof(krb5_data) * components); if (principal->data == NULL) { - free((char *)principal); + free(principal); return ENOMEM; } principal->length = components; @@ -170,7 +170,7 @@ k5_parse_name(krb5_context context, const char *name, retval = krb5_get_default_realm(context, &default_realm); if (retval) { free(principal->data); - free((char *)principal); + free(principal); return(retval); } default_realm_size = strlen(default_realm); diff --git a/src/lib/krb5/rcache/rc_base.c b/src/lib/krb5/rcache/rc_base.c index ad69282a4..ea532b3d7 100644 --- a/src/lib/krb5/rcache/rc_base.c +++ b/src/lib/krb5/rcache/rc_base.c @@ -15,8 +15,6 @@ #include "rc-int.h" #include "k5-thread.h" -#define FREE(x) ((void) free((char *) (x))) - struct krb5_rc_typelist { const krb5_rc_ops *ops; struct krb5_rc_typelist *next; @@ -119,13 +117,13 @@ krb5_rc_default(krb5_context context, krb5_rcache *id) if ((retval = krb5_rc_resolve_type(context, id, krb5_rc_default_type(context)))) { - FREE(*id); + free(*id); return retval; } if ((retval = krb5_rc_resolve(context, *id, krb5_rc_default_name(context)))) { k5_mutex_destroy(&(*id)->lock); - FREE(*id); + free(*id); return retval; } (*id)->magic = KV5M_RCACHE; @@ -154,19 +152,19 @@ krb5_error_code krb5_rc_resolve_full(krb5_context context, krb5_rcache *idptr, type[residual - string_name] = '\0'; if (!(id = (krb5_rcache) malloc(sizeof(*id)))) { - FREE(type); + free(type); return KRB5_RC_MALLOC; } if ((retval = krb5_rc_resolve_type(context, &id,type))) { - FREE(type); - FREE(id); + free(type); + free(id); return retval; } - FREE(type); + free(type); if ((retval = krb5_rc_resolve(context, id,residual + 1))) { k5_mutex_destroy(&id->lock); - FREE(id); + free(id); return retval; } id->magic = KV5M_RCACHE; diff --git a/src/lib/krb5/rcache/rc_conv.c b/src/lib/krb5/rcache/rc_conv.c index 3370f45df..2684929a6 100644 --- a/src/lib/krb5/rcache/rc_conv.c +++ b/src/lib/krb5/rcache/rc_conv.c @@ -11,8 +11,6 @@ * An implementation for the default replay cache type. */ -#define FREE(x) ((void) free((char *) (x))) - #include "rc_base.h" /* @@ -31,7 +29,7 @@ krb5_auth_to_rep(krb5_context context, krb5_tkt_authent *auth, krb5_donot_replay return retval; /* shouldn't happen */ if ((retval = krb5_unparse_name(context, auth->authenticator->client, &rep->client))) { - FREE(rep->server); + free(rep->server); return retval; /* shouldn't happen. */ } return 0; diff --git a/src/lib/krb5/rcache/rc_io.c b/src/lib/krb5/rcache/rc_io.c index 82b56297b..683e1a907 100644 --- a/src/lib/krb5/rcache/rc_io.c +++ b/src/lib/krb5/rcache/rc_io.c @@ -40,7 +40,6 @@ #error find some way to use net-byte-order file version numbers. #endif -#define FREE(x) ((void) free((char *) (x))) #define UNIQUE getpid() /* hopefully unique number */ #define GETDIR (dir = getdir(), dirlen = strlen(dir) + sizeof(PATH_SEPARATOR) - 1) @@ -205,7 +204,7 @@ cleanup: if (d->fn) { if (!do_not_unlink) (void) unlink(d->fn); - FREE(d->fn); + free(d->fn); d->fn = NULL; } if (d->fd != -1) { @@ -299,7 +298,7 @@ cleanup: if (d->fn) { if (!do_not_unlink) (void) unlink(d->fn); - FREE(d->fn); + free(d->fn); d->fn = NULL; } if (d->fd >= 0) @@ -470,7 +469,7 @@ krb5_error_code krb5_rc_io_close(krb5_context context, krb5_rc_iostuff *d) { if (d->fn != NULL) { - FREE(d->fn); + free(d->fn); d->fn = NULL; } if (d->fd != -1) { diff --git a/src/tests/verify/kdb5_verify.c b/src/tests/verify/kdb5_verify.c index 92a375b55..be8b4ae5a 100644 --- a/src/tests/verify/kdb5_verify.c +++ b/src/tests/verify/kdb5_verify.c @@ -303,8 +303,8 @@ errout: } } - free((char *)pwd_key.contents); - free((char *)db_key.contents); + free(pwd_key.contents); + free(db_key.contents); if (kdbe.key_data[0].key_data_kvno != 1) { fprintf(stderr,"\tkvno did not match stored value for %s.\n", princ_name); diff --git a/src/util/ss/invocation.c b/src/util/ss/invocation.c index 8d4a193bc..f4efe0288 100644 --- a/src/util/ss/invocation.c +++ b/src/util/ss/invocation.c @@ -125,6 +125,6 @@ ss_delete_invocation(sci_idx) free(t->rqt_tables); while(t->info_dirs[0] != (char *)NULL) ss_delete_info_dir(sci_idx, t->info_dirs[0], &ignored_code); - free((char *)t->info_dirs); - free((char *)t); + free(t->info_dirs); + free(t); } -- 2.26.2