diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-11-05 09:48:22 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-11-05 09:48:22 +0000 |
commit | 422d354f8c90fea170ce40abd4f03d0c82c895e9 (patch) | |
tree | fc13c077f8c2334c800342385cf3e1c859db1b4c | |
parent | 9d2b75ad9fc8b26c968abb5394cbc39c9008d41b (diff) |
Remove xfree(), like already done for RCS. From Michael W Bombardieri,
ok mmcc
34 files changed, 297 insertions, 372 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c index e744b05f797..6d79296403a 100644 --- a/usr.bin/cvs/add.c +++ b/usr.bin/cvs/add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: add.c,v 1.111 2015/01/16 06:40:06 deraadt Exp $ */ +/* $OpenBSD: add.c,v 1.112 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> @@ -20,6 +20,7 @@ #include <errno.h> #include <fcntl.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -146,7 +147,7 @@ cvs_add_entry(struct cvs_file *cf) entlist = cvs_ent_open(cf->file_wd); cvs_ent_add(entlist, entry); - xfree(entry); + free(entry); } else { add_entry(cf); } @@ -252,7 +253,7 @@ cvs_add_tobranch(struct cvs_file *cf, char *tag) (void)xsnprintf(attic, PATH_MAX, "%s/%s/%s%s", repo, CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT); - xfree(cf->file_rpath); + free(cf->file_rpath); cf->file_rpath = xstrdup(attic); cf->repo_fd = open(cf->file_rpath, O_CREAT|O_RDONLY); @@ -277,7 +278,7 @@ cvs_add_tobranch(struct cvs_file *cf, char *tag) if (rcs_rev_add(cf->file_rcs, RCS_HEAD_REV, msg, -1, NULL) == -1) fatal("cvs_add_tobranch: failed to create first branch " "revision"); - xfree(msg); + free(msg); if (rcs_findrev(cf->file_rcs, cf->file_rcs->rf_head) == NULL) fatal("cvs_add_tobranch: cannot find newly added revision"); @@ -359,7 +360,7 @@ add_directory(struct cvs_file *cf) entlist = cvs_ent_open(cf->file_wd); cvs_ent_add(entlist, p); - xfree(p); + free(p); } } @@ -381,10 +382,8 @@ add_directory(struct cvs_file *cf) } cvs_printf("%s\n", msg); - if (tag != NULL) - xfree(tag); - if (date != NULL) - xfree(date); + free(tag); + free(date); cvs_get_repository_name(cf->file_path, repo, PATH_MAX); line_list = cvs_trigger_getlines(CVS_PATH_LOGINFO, repo); @@ -400,8 +399,7 @@ add_directory(struct cvs_file *cf) cvs_trigger_freeinfo(&files_info); cvs_trigger_freelist(line_list); - if (loginfo != NULL) - xfree(loginfo); + free(loginfo); } } @@ -564,5 +562,5 @@ add_entry(struct cvs_file *cf) entlist = cvs_ent_open(cf->file_wd); cvs_ent_add(entlist, entry); } - xfree(entry); + free(entry); } diff --git a/usr.bin/cvs/admin.c b/usr.bin/cvs/admin.c index 6a3120df20b..543fbcc71ac 100644 --- a/usr.bin/cvs/admin.c +++ b/usr.bin/cvs/admin.c @@ -1,4 +1,4 @@ -/* $OpenBSD: admin.c,v 1.65 2015/01/16 06:40:06 deraadt Exp $ */ +/* $OpenBSD: admin.c,v 1.66 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2005 Joris Vink <joris@openbsd.org> @@ -23,6 +23,7 @@ #include <errno.h> #include <fcntl.h> #include <libgen.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -304,8 +305,8 @@ cvs_admin_local(struct cvs_file *cf) while (!TAILQ_EMPTY(&(cf->file_rcs->rf_access))) { rap = TAILQ_FIRST(&(cf->file_rcs->rf_access)); TAILQ_REMOVE(&(cf->file_rcs->rf_access), rap, ra_list); - xfree(rap->ra_name); - xfree(rap); + free(rap->ra_name); + free(rap); } /* no synced anymore */ cf->file_rcs->rf_flags &= ~RCS_SYNCED; diff --git a/usr.bin/cvs/annotate.c b/usr.bin/cvs/annotate.c index 8aaa8b3a3e5..07b5eb7bc29 100644 --- a/usr.bin/cvs/annotate.c +++ b/usr.bin/cvs/annotate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: annotate.c,v 1.64 2015/01/16 06:40:06 deraadt Exp $ */ +/* $OpenBSD: annotate.c,v 1.65 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2007 Tobias Stoeckmann <tobias@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -235,7 +235,7 @@ cvs_annotate_local(struct cvs_file *cf) p[line->l_len] = '\0'; if (line->l_needsfree) - xfree(line->l_line); + free(line->l_line); line->l_line = p; line->l_len++; line->l_needsfree = 1; @@ -244,9 +244,9 @@ cvs_annotate_local(struct cvs_file *cf) line->l_delta->rd_author, date, line->l_line); if (line->l_needsfree) - xfree(line->l_line); - xfree(line); + free(line->l_line); + free(line); } - xfree(alines); + free(alines); } diff --git a/usr.bin/cvs/buf.c b/usr.bin/cvs/buf.c index 3e468388821..051c30fe2cd 100644 --- a/usr.bin/cvs/buf.c +++ b/usr.bin/cvs/buf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.c,v 1.82 2015/02/05 12:59:57 millert Exp $ */ +/* $OpenBSD: buf.c,v 1.83 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -119,15 +119,15 @@ buf_load_fd(int fd) void buf_free(BUF *b) { - if (b->cb_buf != NULL) - xfree(b->cb_buf); - xfree(b); + if (b == NULL) + return; + free(b->cb_buf); + free(b); } /* * Free the buffer <b>'s structural information but do not free the contents - * of the buffer. Instead, they are returned and should be freed later using - * xfree(). + * of the buffer. Instead, they are returned and should be freed later. */ void * buf_release(BUF *b) @@ -135,7 +135,7 @@ buf_release(BUF *b) void *tmp; tmp = b->cb_buf; - xfree(b); + free(b); return (tmp); } diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c index ea1a0ddd0d3..182a2f5df66 100644 --- a/usr.bin/cvs/checkout.c +++ b/usr.bin/cvs/checkout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: checkout.c,v 1.169 2015/01/16 06:40:06 deraadt Exp $ */ +/* $OpenBSD: checkout.c,v 1.170 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -360,8 +360,7 @@ checkout_check_repository(int argc, char **argv) mc->mc_flags & MODULE_RUN_ON_CHECKOUT) cvs_exec(mc->mc_prog, NULL, 0); - if (module_repo_root != NULL) - xfree(module_repo_root); + free(module_repo_root); } if (mc->mc_canfree == 1) { @@ -371,17 +370,17 @@ checkout_check_repository(int argc, char **argv) &(mc->mc_modules), fl); RB_REMOVE(cvs_flisthead, &(mc->mc_modules), fl); - xfree(fl->file_path); - xfree(fl); + free(fl->file_path); + free(fl); } } while ((ip = TAILQ_FIRST(&checkout_ign_pats)) != NULL) { TAILQ_REMOVE(&checkout_ign_pats, ip, ip_list); - xfree(ip); + free(ip); } - xfree(mc); + free(mc); } } @@ -634,5 +633,5 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags) } } - xfree(entry); + free(entry); } diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index ca137abcff9..5254e00e46c 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.124 2015/01/16 06:40:06 deraadt Exp $ */ +/* $OpenBSD: client.c,v 1.125 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -190,7 +190,7 @@ client_check_directory(char *data, char *repository) entlist = cvs_ent_open(parent); cvs_ent_add(entlist, entry); - xfree(entry); + free(entry); } void @@ -273,7 +273,7 @@ cvs_client_connect_to_server(void) resp = client_get_supported_responses(); cvs_client_send_request("Valid-responses %s", resp); - xfree(resp); + free(resp); cvs_client_send_request("valid-requests"); cvs_client_get_responses(); @@ -339,7 +339,7 @@ cvs_client_send_request(char *fmt, ...) cvs_log(LP_TRACE, "%s", data); cvs_remote_output(data); - xfree(data); + free(data); } void @@ -361,7 +361,7 @@ cvs_client_read_response(void) (*resp->hdlr)(data); - xfree(cmd); + free(cmd); } void @@ -391,7 +391,7 @@ cvs_client_send_logmsg(char *msg) } } - xfree(buf); + free(buf); } void @@ -439,16 +439,11 @@ cvs_client_senddir(const char *dir) cvs_client_send_request("Sticky %s", buf); - if (tag != NULL) - xfree(tag); - if (date != NULL) - xfree(date); + free(tag); + free(date); } - if (d != NULL) - xfree(d); - - if (lastdir != NULL) - xfree(lastdir); + free(d); + free(lastdir); lastdir = xstrdup(dir); } @@ -637,12 +632,12 @@ cvs_client_checkedin(char *data) dir = cvs_remote_input(); e = cvs_remote_input(); - xfree(dir); + free(dir); entlist = cvs_ent_open(data); newent = cvs_ent_parse(e); ent = cvs_ent_get(entlist, newent->ce_name); - xfree(e); + free(e); rcsnum_tostr(newent->ce_rev, rev, sizeof(rev)); @@ -685,7 +680,7 @@ cvs_client_checkedin(char *data) cvs_ent_free(newent); cvs_ent_add(entlist, entry); - xfree(entry); + free(entry); } void @@ -730,10 +725,10 @@ cvs_client_updated(char *data) flen = strtonum(len, 0, INT_MAX, &errstr); if (errstr != NULL) fatal("cvs_client_updated: %s: %s", len, errstr); - xfree(len); + free(len); cvs_strtomode(mode, &fmode); - xfree(mode); + free(mode); fmode &= ~cvs_umask; time(&now); @@ -742,7 +737,7 @@ cvs_client_updated(char *data) timebuf[strcspn(timebuf, "\n")] = '\0'; e = cvs_ent_parse(en); - xfree(en); + free(en); sticky[0] = '\0'; if (e->ce_tag != NULL) { @@ -767,7 +762,7 @@ cvs_client_updated(char *data) cvs_ent_add(ent, entry); } - xfree(entry); + free(entry); (void)unlink(fpath); if ((fd = open(fpath, O_CREAT | O_WRONLY | O_TRUNC)) == -1) @@ -788,7 +783,7 @@ cvs_client_updated(char *data) (void)close(fd); - xfree(rpath); + free(rpath); } void @@ -826,15 +821,15 @@ cvs_client_merged(char *data) fpath = rpath + strlen(repo) + 1; if ((wdir = dirname(fpath)) == NULL) fatal("cvs_client_merged: dirname: %s", strerror(errno)); - xfree(repo); + free(repo); flen = strtonum(len, 0, INT_MAX, &errstr); if (errstr != NULL) fatal("cvs_client_merged: %s: %s", len, errstr); - xfree(len); + free(len); cvs_strtomode(mode, &fmode); - xfree(mode); + free(mode); fmode &= ~cvs_umask; time(&now); @@ -844,7 +839,7 @@ cvs_client_merged(char *data) ent = cvs_ent_open(wdir); cvs_ent_add(ent, entry); - xfree(entry); + free(entry); (void)unlink(fpath); if ((fd = open(fpath, O_CREAT | O_WRONLY | O_TRUNC)) == -1) @@ -865,7 +860,7 @@ cvs_client_merged(char *data) (void)close(fd); - xfree(rpath); + free(rpath); } void @@ -888,7 +883,7 @@ cvs_client_removed(char *data) (void)xsnprintf(fpath, PATH_MAX, "%s/%s", data, filename); (void)unlink(fpath); - xfree(rpath); + free(rpath); } void @@ -908,7 +903,7 @@ cvs_client_remove_entry(char *data) entlist = cvs_ent_open(data); cvs_ent_remove(entlist, filename); - xfree(rpath); + free(rpath); } void @@ -923,7 +918,7 @@ cvs_client_set_static_directory(char *data) STRIP_SLASH(data); dir = cvs_remote_input(); - xfree(dir); + free(dir); if (cvs_cmdop == CVS_OP_EXPORT) return; @@ -949,7 +944,7 @@ cvs_client_clear_static_directory(char *data) STRIP_SLASH(data); dir = cvs_remote_input(); - xfree(dir); + free(dir); if (cvs_cmdop == CVS_OP_EXPORT) return; @@ -989,8 +984,8 @@ cvs_client_set_sticky(char *data) (void)fprintf(fp, "%s\n", tag); (void)fclose(fp); out: - xfree(tag); - xfree(dir); + free(tag); + free(dir); } void @@ -1006,7 +1001,7 @@ cvs_client_clear_sticky(char *data) dir = cvs_remote_input(); if (cvs_cmdop == CVS_OP_EXPORT) { - xfree(dir); + free(dir); return; } @@ -1015,7 +1010,7 @@ cvs_client_clear_sticky(char *data) (void)xsnprintf(tagpath, PATH_MAX, "%s/%s", data, CVS_PATH_TAG); (void)unlink(tagpath); - xfree(dir); + free(dir); } @@ -1054,7 +1049,7 @@ cvs_client_initlog(void) if (strlcpy(rpath, envdup, sizeof(rpath)) >= sizeof(rpath)) fatal("cvs_client_initlog: truncation"); - xfree(envdup); + free(envdup); s = buf; while ((s = strchr(s, '%')) != NULL) { diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c index fe8d554f6f8..60f06612da0 100644 --- a/usr.bin/cvs/commit.c +++ b/usr.bin/cvs/commit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commit.c,v 1.153 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: commit.c,v 1.154 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -21,6 +21,7 @@ #include <errno.h> #include <fcntl.h> #include <libgen.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -77,8 +78,7 @@ cvs_commit(int argc, char **argv) switch (ch) { case 'F': /* free previously assigned value */ - if (logmsg != NULL) - xfree(logmsg); + free(logmsg); logmsg = cvs_logmsg_read(optarg); Fflag = 1; break; @@ -89,8 +89,7 @@ cvs_commit(int argc, char **argv) break; case 'm': /* free previously assigned value */ - if (logmsg != NULL) - xfree(logmsg); + free(logmsg); logmsg = xstrdup(optarg); mflag = 1; break; @@ -210,7 +209,7 @@ cvs_commit(int argc, char **argv) cvs_trigger_handle(CVS_TRIGGER_LOGINFO, repo, loginfo, line_list, &files_info); - xfree(loginfo); + free(loginfo); cvs_trigger_freelist(line_list); cvs_trigger_freeinfo(&files_info); } @@ -223,8 +222,7 @@ cvs_commit(int argc, char **argv) end: cvs_trigger_freeinfo(&files_info); - if (logmsg != NULL) - xfree(logmsg); + free(logmsg); return (0); } @@ -568,7 +566,7 @@ cvs_commit_local(struct cvs_file *cf) "move %s outside the Attic: %s", cf->file_path, strerror(errno)); - xfree(cf->file_rpath); + free(cf->file_rpath); cf->file_rpath = xstrdup(rcsfile); isnew = 0; } @@ -761,8 +759,8 @@ commit_diff(struct cvs_file *cf, RCSNUM *rev, int reverse) close(fd1); close(fd2); - xfree(p1); - xfree(p2); + free(p1); + free(p2); return (b); } @@ -789,5 +787,5 @@ commit_desc_set(struct cvs_file *cf) (void)close(fd); (void)cvs_unlink(desc_path); - xfree(desc); + free(desc); } diff --git a/usr.bin/cvs/config.c b/usr.bin/cvs/config.c index 0d45f681ec0..142edfd839d 100644 --- a/usr.bin/cvs/config.c +++ b/usr.bin/cvs/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.16 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: config.c,v 1.17 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -48,8 +48,7 @@ config_parse_line(char *line, int lineno) *(val++) = '\0'; if (!strcmp(opt, "tag")) { - if (cvs_tagname != NULL) - xfree(cvs_tagname); + free(cvs_tagname); cvs_tagname = xstrdup(val); } else if (!strcmp(opt, "umask")) { cvs_umask = strtol(val, &ep, 8); @@ -115,8 +114,6 @@ cvs_read_config(char *name, int (*cb)(char *, int)) break; } - if (lbuf != NULL) - xfree(lbuf); - + free(lbuf); (void)fclose(fp); } diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c index 912be1af66d..7aab0cba1a9 100644 --- a/usr.bin/cvs/cvs.c +++ b/usr.bin/cvs/cvs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.c,v 1.155 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: cvs.c,v 1.156 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006, 2007 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -113,7 +113,7 @@ cvs_cleanup(void) cvs_log(LP_ERR, "warning: failed to remove server directory: %s", cvs_server_path); - xfree(cvs_server_path); + free(cvs_server_path); cvs_server_path = NULL; } @@ -257,7 +257,7 @@ main(int argc, char **argv) cvs_getopt(i, targv); cvs_freeargv(targv, i); - xfree(targv); + free(targv); } } @@ -513,8 +513,7 @@ cvs_read_rcfile(void) cmd_parsed = 1; } } - if (lbuf != NULL) - xfree(lbuf); + free(lbuf); if (ferror(fp)) { cvs_log(LP_NOTICE, "failed to read line from `%s'", rcpath); @@ -561,7 +560,7 @@ cvs_var_set(const char *var, const char *val) TAILQ_INSERT_TAIL(&cvs_variables, vp, cv_link); } else /* free the previous value */ - xfree(vp->cv_val); + free(vp->cv_val); vp->cv_val = xstrdup(val); @@ -582,9 +581,9 @@ cvs_var_unset(const char *var) TAILQ_FOREACH(vp, &cvs_variables, cv_link) if (strcmp(vp->cv_name, var) == 0) { TAILQ_REMOVE(&cvs_variables, vp, cv_link); - xfree(vp->cv_name); - xfree(vp->cv_val); - xfree(vp); + free(vp->cv_name); + free(vp->cv_val); + free(vp); return (0); } diff --git a/usr.bin/cvs/date.y b/usr.bin/cvs/date.y index 72beec8aa03..ecd346b92d8 100644 --- a/usr.bin/cvs/date.y +++ b/usr.bin/cvs/date.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: date.y,v 1.24 2013/12/03 00:23:45 deraadt Exp $ */ +/* $OpenBSD: date.y,v 1.25 2015/11/05 09:48:21 nicm Exp $ */ /* ** Originally written by Steven M. Bellovin <smb@research.att.com> while @@ -488,7 +488,7 @@ yyerror(const char *s) (void)xasprintf(&str, "parsing date string: %s", s); cvs_log(LP_ERR, "%s", str); - xfree(str); + free(str); #endif return (0); } diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c index 8f71ba52ce6..7f4f575385d 100644 --- a/usr.bin/cvs/diff.c +++ b/usr.bin/cvs/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.160 2011/04/20 18:33:13 nicm Exp $ */ +/* $OpenBSD: diff.c,v 1.161 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2008 Tobias Stoeckmann <tobias@openbsd.org> * Copyright (c) 2006 Joris Vink <joris@openbsd.org> @@ -605,20 +605,18 @@ cvs_diff_local(struct cvs_file *cf) worklist_run(&temp_files, worklist_unlink); - if (p1 != NULL) - xfree(p1); - if (p2 != NULL) - xfree(p2); + free(p1); + free(p2); cleanup: if (diff_rev1 != NULL && (cf->file_rcs == NULL || diff_rev1 != cf->file_rcs->rf_head) && (cf->file_ent == NULL || diff_rev1 != cf->file_ent->ce_rev)) - xfree(diff_rev1); + free(diff_rev1); diff_rev1 = NULL; if (diff_rev2 != NULL && (cf->file_rcs == NULL || diff_rev2 != cf->file_rcs->rf_head)) - xfree(diff_rev2); + free(diff_rev2); diff_rev2 = NULL; } diff --git a/usr.bin/cvs/diff3.c b/usr.bin/cvs/diff3.c index 3a601e430d0..d7842404b78 100644 --- a/usr.bin/cvs/diff3.c +++ b/usr.bin/cvs/diff3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff3.c,v 1.58 2015/09/05 09:47:08 jsg Exp $ */ +/* $OpenBSD: diff3.c,v 1.59 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -257,20 +257,19 @@ cvs_merge_file(struct cvs_file *cf, int verbose) cvs_freelines(dlines); - if (data != NULL) - xfree(data); - xfree(patch); + free(data); + free(patch); for (i = 0; i < 3; i++) fclose(fp[i]); worklist_run(&temp_files, worklist_unlink); - xfree(path1); - xfree(path2); - xfree(path3); - xfree(dp13); - xfree(dp23); + free(path1); + free(path2); + free(path3); + free(dp13); + free(dp23); } static int @@ -291,17 +290,12 @@ diff3_internal(int argc, char **argv, const char *fmark, const char *rmark) szchanges = 0; memset(last, 0, sizeof(last)); memset(cline, 0, sizeof(cline)); - if (d13 != NULL) - xfree(d13); - if (d23 != NULL) - xfree(d23); - if (overlap != NULL) - xfree(overlap); - if (de != NULL) - xfree(de); - - overlap = NULL; - de = d13 = d23 = NULL; + free(d13); + free(d23); + free(overlap); + free(de); + + de = d13 = d23 = overlap = NULL; increase(); diff --git a/usr.bin/cvs/diff_internals.c b/usr.bin/cvs/diff_internals.c index ff5a1e66c2a..07eb2f82b2f 100644 --- a/usr.bin/cvs/diff_internals.c +++ b/usr.bin/cvs/diff_internals.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff_internals.c,v 1.37 2015/02/05 12:59:57 millert Exp $ */ +/* $OpenBSD: diff_internals.c,v 1.38 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -73,6 +73,7 @@ #include <stddef.h> #include <stdint.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> @@ -392,13 +393,13 @@ diffreg(const char *file1, const char *file2, int _fd1, int _fd2, clistlen = 100; clist = xcalloc(clistlen, sizeof(*clist)); i = stone(class, slen[0], member, klist, flags); - xfree(member); - xfree(class); + free(member); + free(class); J = xreallocarray(J, len[0] + 2, sizeof(*J)); unravel(klist[i]); - xfree(clist); - xfree(klist); + free(clist); + free(klist); ixold = xreallocarray(ixold, len[0] + 2, sizeof(*ixold)); ixnew = xreallocarray(ixnew, len[1] + 2, sizeof(*ixnew)); @@ -787,7 +788,7 @@ unsort(struct line *f, int l, int *b) a[f[i].serial] = f[i].value; for (i = 1; i <= l; i++) b[i] = a[i]; - xfree(a); + free(a); } static int @@ -878,7 +879,7 @@ ignoreline(char *line) int ret; ret = regexec(&ignore_re, line, 0, NULL, 0); - xfree(line); + free(line); return (ret == 0); /* if it matched, it should be ignored. */ } @@ -1456,5 +1457,5 @@ diff_output(const char *fmt, ...) buf_puts(diffbuf, str); else cvs_printf("%s", str); - xfree(str); + free(str); } diff --git a/usr.bin/cvs/edit.c b/usr.bin/cvs/edit.c index 2e292b93a68..8d79e36d4a2 100644 --- a/usr.bin/cvs/edit.c +++ b/usr.bin/cvs/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.50 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: edit.c,v 1.51 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006, 2007 Xavier Santolaria <xsa@openbsd.org> * @@ -18,6 +18,7 @@ #include <sys/stat.h> #include <errno.h> +#include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> @@ -409,7 +410,7 @@ cvs_unedit_local(struct cvs_file *cf) cvs_ent_free(ent); - xfree(entry); + free(entry); } rcsnum_free(ba_rev); diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c index 64043d81410..c1a18d128ea 100644 --- a/usr.bin/cvs/entries.c +++ b/usr.bin/cvs/entries.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entries.c,v 1.105 2015/08/20 22:32:41 deraadt Exp $ */ +/* $OpenBSD: entries.c,v 1.106 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -16,6 +16,7 @@ */ #include <errno.h> +#include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> @@ -101,8 +102,8 @@ cvs_ent_open(const char *dir) if (line != NULL) { TAILQ_REMOVE(&(ep->cef_ent), line, entries_list); - xfree(line->buf); - xfree(line); + free(line->buf); + free(line); } cvs_ent_free(ent); } @@ -276,8 +277,8 @@ cvs_ent_close(CVSENTRIES *ep, int writefile) } TAILQ_REMOVE(&(ep->cef_ent), l, entries_list); - xfree(l->buf); - xfree(l); + free(l->buf); + free(l); } if (fp != NULL) { @@ -294,10 +295,10 @@ cvs_ent_close(CVSENTRIES *ep, int writefile) (void)unlink(ep->cef_lpath); } - xfree(ep->cef_path); - xfree(ep->cef_bpath); - xfree(ep->cef_lpath); - xfree(ep); + free(ep->cef_path); + free(ep->cef_bpath); + free(ep->cef_lpath); + free(ep); } void @@ -358,8 +359,8 @@ cvs_ent_remove(CVSENTRIES *ep, const char *name) (void)fclose(fp); TAILQ_REMOVE(&(ep->cef_ent), l, entries_list); - xfree(l->buf); - xfree(l); + free(l->buf); + free(l); } /* @@ -386,11 +387,9 @@ cvs_ent_free(struct cvs_ent *ent) { if (ent->ce_rev != NULL) rcsnum_free(ent->ce_rev); - if (ent->ce_time != NULL) - xfree(ent->ce_time); - - xfree(ent->ce_buf); - xfree(ent); + free(ent->ce_time); + free(ent->ce_buf); + free(ent); } static struct cvs_ent_line * diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 06879f2a932..602c0b2e236 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.266 2015/08/20 22:32:41 deraadt Exp $ */ +/* $OpenBSD: file.c,v 1.267 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -36,6 +36,7 @@ #include <fnmatch.h> #include <libgen.h> #include <stdint.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -375,10 +376,8 @@ cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr) if (l->flags & FILE_USER_SUPPLIED) { if (cmdp->cmd_flags & CVS_LOCK_REPO) cvs_repository_unlock(repo); - if (cvs_directory_tag != NULL) { - xfree(cvs_directory_tag); - cvs_directory_tag = NULL; - } + free(cvs_directory_tag); + cvs_directory_tag = NULL; } } @@ -562,11 +561,11 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) fatal("cvs_file_walkdir: %s %s", cf->file_path, strerror(errno)); - xfree(buf); + free(buf); while ((ip = TAILQ_FIRST(&dir_ign_pats)) != NULL) { TAILQ_REMOVE(&dir_ign_pats, ip, ip_list); - xfree(ip); + free(ip); } entlist = cvs_ent_open(cf->file_path); @@ -613,7 +612,7 @@ walkrepo: if (cvs_directory_tag != NULL && cmdp->cmd_flags & CVS_USE_WDIR) { cvs_write_tagfile(cf->file_path, cvs_directory_tag, NULL); - xfree(cvs_directory_tag); + free(cvs_directory_tag); cvs_directory_tag = NULL; } @@ -632,8 +631,8 @@ cvs_file_freelist(struct cvs_flisthead *fl) for (f = RB_MIN(cvs_flisthead, fl); f != NULL; f = nxt) { nxt = RB_NEXT(cvs_flisthead, fl, f); RB_REMOVE(cvs_flisthead, fl, f); - xfree(f->file_path); - xfree(f); + free(f->file_path); + free(f); } } @@ -754,7 +753,7 @@ cvs_file_classify(struct cvs_file *cf, const char *tag) cf->repo_fd = open(rcsfile, O_RDONLY); if (cf->repo_fd != -1) { - xfree(cf->file_rpath); + free(cf->file_rpath); cf->file_rpath = xstrdup(rcsfile); cf->file_rcs = rcs_open(cf->file_rpath, cf->repo_fd, rflags); @@ -975,14 +974,13 @@ cvs_file_classify(struct cvs_file *cf, const char *tag) void cvs_file_free(struct cvs_file *cf) { - xfree(cf->file_name); - xfree(cf->file_wd); - xfree(cf->file_path); + free(cf->file_name); + free(cf->file_wd); + free(cf->file_path); if (cf->file_rcsrev != NULL) rcsnum_free(cf->file_rcsrev); - if (cf->file_rpath != NULL) - xfree(cf->file_rpath); + free(cf->file_rpath); if (cf->file_ent != NULL) cvs_ent_free(cf->file_ent); if (cf->file_rcs != NULL) @@ -991,7 +989,7 @@ cvs_file_free(struct cvs_file *cf) (void)close(cf->fd); if (cf->repo_fd != -1) (void)close(cf->repo_fd); - xfree(cf); + free(cf); } int diff --git a/usr.bin/cvs/history.c b/usr.bin/cvs/history.c index c9241aeefc5..d9f445ee011 100644 --- a/usr.bin/cvs/history.c +++ b/usr.bin/cvs/history.c @@ -1,4 +1,4 @@ -/* $OpenBSD: history.c,v 1.42 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: history.c,v 1.43 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2007 Joris Vink <joris@openbsd.org> * @@ -181,9 +181,9 @@ cvs_history_add(int type, struct cvs_file *cf, const char *argument) } if (rev != revbuf) - xfree(rev); + free(rev); if (cvs_server_active != 1) - xfree(cwd); + free(cwd); } static void diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c index 20a6b6eaed6..445d8e23e46 100644 --- a/usr.bin/cvs/import.c +++ b/usr.bin/cvs/import.c @@ -1,4 +1,4 @@ -/* $OpenBSD: import.c,v 1.104 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: import.c,v 1.105 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -19,6 +19,7 @@ #include <errno.h> #include <fcntl.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -191,7 +192,7 @@ cvs_import(int argc, char **argv) cvs_trigger_freelist(line_list); } - xfree(loginfo); + free(loginfo); return (0); } @@ -209,7 +210,7 @@ import_printf(const char *fmt, ...) cvs_printf("%s", str); buf_puts(logbuf, str); - xfree(str); + free(str); } void @@ -482,8 +483,8 @@ import_get_rcsdiff(struct cvs_file *cf, RCSNUM *rev) (void)unlink(p1); (void)unlink(p2); - xfree(p1); - xfree(p2); + free(p1); + free(p2); return (b2); } diff --git a/usr.bin/cvs/log.c b/usr.bin/cvs/log.c index b2237be3fd3..05c24acb367 100644 --- a/usr.bin/cvs/log.c +++ b/usr.bin/cvs/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.46 2011/12/27 13:59:01 nicm Exp $ */ +/* $OpenBSD: log.c,v 1.47 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -26,6 +26,7 @@ */ #include <errno.h> +#include <stdlib.h> #include <string.h> #include "cvs.h" @@ -162,7 +163,7 @@ cvs_printf(const char *fmt, ...) dp = sp + 1; } - xfree(nstr); + free(nstr); va_end(vap); return (ret); diff --git a/usr.bin/cvs/logmsg.c b/usr.bin/cvs/logmsg.c index e2f7fff9066..281112c86a6 100644 --- a/usr.bin/cvs/logmsg.c +++ b/usr.bin/cvs/logmsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logmsg.c,v 1.56 2015/02/05 12:59:57 millert Exp $ */ +/* $OpenBSD: logmsg.c,v 1.57 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2007 Joris Vink <joris@openbsd.org> * @@ -83,8 +83,7 @@ cvs_logmsg_read(const char *path) buf_putc(bp, '\n'); } - if (lbuf != NULL) - xfree(lbuf); + free(lbuf); (void)fclose(fp); @@ -149,7 +148,7 @@ cvs_logmsg_create(char *dir, struct cvs_flisthead *added, logmsg = xmalloc(st.st_size); fread(logmsg, st.st_size, 1, rp); fwrite(logmsg, st.st_size, 1, fp); - xfree(logmsg); + free(logmsg); (void)fclose(rp); } cvs_trigger_freelist(line_list); @@ -215,8 +214,7 @@ cvs_logmsg_create(char *dir, struct cvs_flisthead *added, if (st1.st_mtime != st2.st_mtime) { logmsg = cvs_logmsg_read(fpath); - if (prevmsg != NULL) - xfree(prevmsg); + free(prevmsg); prevmsg = xstrdup(logmsg); break; } @@ -250,7 +248,7 @@ cvs_logmsg_create(char *dir, struct cvs_flisthead *added, (void)fclose(fp); (void)unlink(fpath); - xfree(fpath); + free(fpath); return (logmsg); } @@ -284,7 +282,7 @@ cvs_logmsg_edit(const char *pathname) while (waitpid(pid, &st, 0) == -1) if (errno != EINTR) goto fail; - xfree(p); + free(p); (void)signal(SIGHUP, sighup); (void)signal(SIGINT, sigint); (void)signal(SIGQUIT, sigquit); @@ -299,7 +297,7 @@ cvs_logmsg_edit(const char *pathname) (void)signal(SIGHUP, sighup); (void)signal(SIGINT, sigint); (void)signal(SIGQUIT, sigquit); - xfree(p); + free(p); errno = saved_errno; return (-1); } @@ -334,7 +332,7 @@ cvs_logmsg_verify(char *logmsg) cvs_trigger_freeinfo(&files_info); (void)close(fd); (void)unlink(fpath); - xfree(fpath); + free(fpath); cvs_trigger_freelist(line_list); } diff --git a/usr.bin/cvs/modules.c b/usr.bin/cvs/modules.c index 82c385340df..65b9ba3eb7d 100644 --- a/usr.bin/cvs/modules.c +++ b/usr.bin/cvs/modules.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modules.c,v 1.18 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: modules.c,v 1.19 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2008 Joris Vink <joris@openbsd.org> * @@ -207,9 +207,8 @@ modules_parse_line(char *line, int lineno) return (0); bad: - if (prog != NULL) - xfree(prog); - xfree(bline); + free(prog); + free(bline); cvs_log(LP_NOTICE, "malformed line in CVSROOT/modules: %d", lineno); return (0); } diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index 220fee8f2f4..4f2e04f90be 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.312 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: rcs.c,v 1.313 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -236,24 +236,24 @@ rcs_close(RCSFILE *rfp) while (!TAILQ_EMPTY(&(rfp->rf_access))) { rap = TAILQ_FIRST(&(rfp->rf_access)); TAILQ_REMOVE(&(rfp->rf_access), rap, ra_list); - xfree(rap->ra_name); - xfree(rap); + free(rap->ra_name); + free(rap); } while (!TAILQ_EMPTY(&(rfp->rf_symbols))) { rsp = TAILQ_FIRST(&(rfp->rf_symbols)); TAILQ_REMOVE(&(rfp->rf_symbols), rsp, rs_list); rcsnum_free(rsp->rs_num); - xfree(rsp->rs_name); - xfree(rsp); + free(rsp->rs_name); + free(rsp); } while (!TAILQ_EMPTY(&(rfp->rf_locks))) { rlp = TAILQ_FIRST(&(rfp->rf_locks)); TAILQ_REMOVE(&(rfp->rf_locks), rlp, rl_list); rcsnum_free(rlp->rl_num); - xfree(rlp->rl_name); - xfree(rlp); + free(rlp->rl_name); + free(rlp); } if (rfp->rf_head != NULL) @@ -263,17 +263,13 @@ rcs_close(RCSFILE *rfp) if (rfp->rf_file != NULL) fclose(rfp->rf_file); - if (rfp->rf_path != NULL) - xfree(rfp->rf_path); - if (rfp->rf_comment != NULL) - xfree(rfp->rf_comment); - if (rfp->rf_expand != NULL) - xfree(rfp->rf_expand); - if (rfp->rf_desc != NULL) - xfree(rfp->rf_desc); + free(rfp->rf_path); + free(rfp->rf_comment); + free(rfp->rf_expand); + free(rfp->rf_desc); if (rfp->rf_pdata != NULL) rcsparse_free(rfp); - xfree(rfp); + free(rfp); } /* @@ -438,9 +434,7 @@ rcs_write(RCSFILE *rfp) } rfp->rf_flags |= RCS_SYNCED; - - if (fn != NULL) - xfree(fn); + free(fn); } /* @@ -623,8 +617,8 @@ rcs_access_remove(RCSFILE *file, const char *login) return (-1); TAILQ_REMOVE(&(file->rf_access), ap, ra_list); - xfree(ap->ra_name); - xfree(ap); + free(ap->ra_name); + free(ap); /* not synced anymore */ file->rf_flags &= ~RCS_SYNCED; @@ -687,9 +681,9 @@ rcs_sym_remove(RCSFILE *file, const char *sym) return (-1); TAILQ_REMOVE(&(file->rf_symbols), symp, rs_list); - xfree(symp->rs_name); + free(symp->rs_name); rcsnum_free(symp->rs_num); - xfree(symp); + free(symp); /* not synced anymore */ file->rf_flags &= ~RCS_SYNCED; @@ -865,8 +859,8 @@ rcs_lock_remove(RCSFILE *file, const char *user, RCSNUM *rev) TAILQ_REMOVE(&(file->rf_locks), lkp, rl_list); rcsnum_free(lkp->rl_num); - xfree(lkp->rl_name); - xfree(lkp); + free(lkp->rl_name); + free(lkp); /* not synced anymore */ file->rf_flags &= ~RCS_SYNCED; @@ -895,8 +889,7 @@ rcs_desc_set(RCSFILE *file, const char *desc) char *tmp; tmp = xstrdup(desc); - if (file->rf_desc != NULL) - xfree(file->rf_desc); + free(file->rf_desc); file->rf_desc = tmp; file->rf_flags &= ~RCS_SYNCED; } @@ -945,8 +938,7 @@ rcs_comment_set(RCSFILE *file, const char *comment) char *tmp; tmp = xstrdup(comment); - if (file->rf_comment != NULL) - xfree(file->rf_comment); + free(file->rf_comment); file->rf_comment = tmp; file->rf_flags &= ~RCS_SYNCED; } @@ -1011,7 +1003,7 @@ rcs_patch_lines(struct rcs_lines *dlines, struct rcs_lines *plines, alines[dlp->l_lineno_orig - 1] = dlp; } else - xfree(dlp); + free(dlp); dlp = ndlp; /* last line is gone - reset dlp */ if (dlp == NULL) { @@ -1029,7 +1021,7 @@ rcs_patch_lines(struct rcs_lines *dlines, struct rcs_lines *plines, TAILQ_REMOVE(&(plines->l_lines), lp, l_list); if (alines != NULL) { if (lp->l_needsfree == 1) - xfree(lp->l_line); + free(lp->l_line); lp->l_line = NULL; lp->l_needsfree = 0; } @@ -1137,8 +1129,7 @@ rcs_rev_add(RCSFILE *rf, RCSNUM *rev, const char *msg, time_t date, if (rf->rf_flags & RCS_CREATE) { if ((rev = rcsnum_parse(RCS_HEAD_INIT)) == NULL) return (-1); - if (rf->rf_head != NULL) - xfree(rf->rf_head); + free(rf->rf_head); rf->rf_head = rev; } else if (rf->rf_head == NULL) { return (-1); @@ -1312,14 +1303,9 @@ rcs_rev_remove(RCSFILE *rf, RCSNUM *rev) rf->rf_flags &= ~RCS_SYNCED; rcs_freedelta(rdp); - - if (newdeltatext != NULL) - xfree(newdeltatext); - - if (path_tmp1 != NULL) - xfree(path_tmp1); - if (path_tmp2 != NULL) - xfree(path_tmp2); + free(newdeltatext); + free(path_tmp1); + free(path_tmp2); return (0); } @@ -1395,8 +1381,7 @@ rcs_kwexp_set(RCSFILE *file, int mode) } tmp = xstrdup(buf); - if (file->rf_expand != NULL) - xfree(file->rf_expand); + free(file->rf_expand); file->rf_expand = tmp; /* not synced anymore */ file->rf_flags &= ~RCS_SYNCED; @@ -1471,24 +1456,19 @@ rcs_freedelta(struct rcs_delta *rdp) if (rdp->rd_next != NULL) rcsnum_free(rdp->rd_next); - if (rdp->rd_author != NULL) - xfree(rdp->rd_author); - if (rdp->rd_locker != NULL) - xfree(rdp->rd_locker); - if (rdp->rd_state != NULL) - xfree(rdp->rd_state); - if (rdp->rd_log != NULL) - xfree(rdp->rd_log); - if (rdp->rd_text != NULL) - xfree(rdp->rd_text); + free(rdp->rd_author); + free(rdp->rd_locker); + free(rdp->rd_state); + free(rdp->rd_log); + free(rdp->rd_text); while ((rb = TAILQ_FIRST(&(rdp->rd_branches))) != NULL) { TAILQ_REMOVE(&(rdp->rd_branches), rb, rb_list); rcsnum_free(rb->rb_num); - xfree(rb); + free(rb); } - xfree(rdp); + free(rdp); } /* @@ -1540,8 +1520,7 @@ rcs_deltatext_set(RCSFILE *rfp, RCSNUM *rev, BUF *bp) if ((rdp = rcs_findrev(rfp, rev)) == NULL) return (-1); - if (rdp->rd_text != NULL) - xfree(rdp->rd_text); + free(rdp->rd_text); len = buf_len(bp); dtext = buf_release(bp); @@ -1556,9 +1535,7 @@ rcs_deltatext_set(RCSFILE *rfp, RCSNUM *rev, BUF *bp) rdp->rd_tlen = 0; } - if (dtext != NULL) - xfree(dtext); - + free(dtext); return (0); } @@ -1575,8 +1552,7 @@ rcs_rev_setlog(RCSFILE *rfp, RCSNUM *rev, const char *logtext) if ((rdp = rcs_findrev(rfp, rev)) == NULL) return (-1); - if (rdp->rd_log != NULL) - xfree(rdp->rd_log); + free(rdp->rd_log); rdp->rd_log = xstrdup(logtext); rfp->rf_flags &= ~RCS_SYNCED; @@ -1615,8 +1591,7 @@ rcs_state_set(RCSFILE *rfp, RCSNUM *rev, const char *state) if ((rdp = rcs_findrev(rfp, rev)) == NULL) return (-1); - if (rdp->rd_state != NULL) - xfree(rdp->rd_state); + free(rdp->rd_state); rdp->rd_state = xstrdup(state); @@ -1899,8 +1874,7 @@ next: if (brp == NULL) { if (annotate != ANNOTATE_NEVER) { - if (*alines != NULL) - xfree(*alines); + free(*alines); *alines = NULL; cvs_freelines(dlines); rcsnum_free(bnum); @@ -1922,7 +1896,7 @@ done: nline = TAILQ_NEXT(line, l_list); TAILQ_REMOVE(&(dlines->l_lines), line, l_list); if (line->l_line == NULL) { - xfree(line); + free(line); continue; } @@ -2039,7 +2013,7 @@ rcs_annotate_getlines(RCSFILE *rfp, RCSNUM *frev, struct rcs_line ***alines) * All lines have been parsed, now they must be copied over * into alines (array) again. */ - xfree(*alines); + free(*alines); i = 0; TAILQ_FOREACH(line, &(dlines->l_lines), l_list) { @@ -2486,7 +2460,7 @@ rcs_kwexp_line(char *rcsfile, struct rcs_delta *rdp, struct rcs_lines *lines, cur, lp, l_list); cur = lp; } - xfree(logp); + free(logp); /* * This is just another hairy mess, but it must @@ -2509,8 +2483,8 @@ rcs_kwexp_line(char *rcsfile, struct rcs_delta *rdp, struct rcs_lines *lines, end = line->l_line + line->l_len - 1; - xfree(prefix); - xfree(sprefix); + free(prefix); + free(sprefix); } @@ -2561,7 +2535,7 @@ rcs_kwexp_line(char *rcsfile, struct rcs_delta *rdp, struct rcs_lines *lines, /* tmpbuf is now ready, convert to string */ if (line->l_needsfree) - xfree(line->l_line); + free(line->l_line); line->l_len = len; line->l_line = buf_release(tmpbuf); line->l_needsfree = 1; diff --git a/usr.bin/cvs/rcsnum.c b/usr.bin/cvs/rcsnum.c index cd35a3b16da..b33fa0a5ba5 100644 --- a/usr.bin/cvs/rcsnum.c +++ b/usr.bin/cvs/rcsnum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsnum.c,v 1.56 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: rcsnum.c,v 1.57 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -25,6 +25,7 @@ */ #include <ctype.h> +#include <stdlib.h> #include <string.h> #include "cvs.h" @@ -96,7 +97,7 @@ rcsnum_parse(const char *str) void rcsnum_free(RCSNUM *rn) { - xfree(rn); + free(rn); } /* diff --git a/usr.bin/cvs/rcsparse.c b/usr.bin/cvs/rcsparse.c index 23f4d67a0ea..8e5a7340127 100644 --- a/usr.bin/cvs/rcsparse.c +++ b/usr.bin/cvs/rcsparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsparse.c,v 1.11 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: rcsparse.c,v 1.12 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2010 Tobias Stoeckmann <tobias@openbsd.org> * @@ -341,11 +341,10 @@ rcsparse_free(RCSFILE *rfp) pdp = rfp->rf_pdata; - if (pdp->rp_buf != NULL) - xfree(pdp->rp_buf); + free(pdp->rp_buf); if (pdp->rp_token == RCS_TYPE_REVISION) rcsnum_free(pdp->rp_value.rev); - xfree(pdp); + free(pdp); } /* @@ -610,7 +609,7 @@ rcsparse_text(RCSFILE *rfp, struct rcs_pdata *pdp) memcpy(pdp->rp_delta->rd_text, pdp->rp_buf, pdp->rp_delta->rd_tlen); } - xfree(pdp->rp_value.str); + free(pdp->rp_value.str); return (0); } @@ -708,7 +707,7 @@ rcsparse_symbols(RCSFILE *rfp, struct rcs_pdata *pdp) name = pdp->rp_value.str; if (rcsparse_token(rfp, RCS_TOK_COLON) != RCS_TOK_COLON || rcsparse_token(rfp, RCS_TYPE_NUMBER) != RCS_TYPE_NUMBER) { - xfree(name); + free(name); return (1); } symp = xmalloc(sizeof(*symp)); @@ -742,7 +741,7 @@ rcsparse_locks(RCSFILE *rfp, struct rcs_pdata *pdp) if (rcsparse_token(rfp, RCS_TOK_COLON) != RCS_TOK_COLON || rcsparse_token(rfp, RCS_TYPE_REVISION) != RCS_TYPE_REVISION) { - xfree(name); + free(name); return (1); } lkp = xmalloc(sizeof(*lkp)); diff --git a/usr.bin/cvs/remote.c b/usr.bin/cvs/remote.c index 4c122ad984f..78a647fc196 100644 --- a/usr.bin/cvs/remote.c +++ b/usr.bin/cvs/remote.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remote.c,v 1.30 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: remote.c,v 1.31 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -239,7 +239,7 @@ cvs_remote_send_file_buf(char *file, BUF *bp, mode_t mode) atomicio(vwrite, cvs_client_inlog_fd, data, len) != len) fatal("failed to write to log file"); - xfree(data); + free(data); } void @@ -309,5 +309,5 @@ cvs_validate_directory(const char *path) fatal("path validation failed!"); } - xfree(dir); + free(dir); } diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c index e2a143d460e..dc46064e214 100644 --- a/usr.bin/cvs/remove.c +++ b/usr.bin/cvs/remove.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remove.c,v 1.82 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: remove.c,v 1.83 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> * @@ -16,6 +16,7 @@ */ #include <errno.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -212,7 +213,7 @@ cvs_remove_local(struct cvs_file *cf) cvs_ent_add(entlist, entry); } - xfree(entry); + free(entry); if (verbosity > 0) { cvs_log(LP_NOTICE, diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c index e01a23db438..209a66458e6 100644 --- a/usr.bin/cvs/server.c +++ b/usr.bin/cvs/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.102 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: server.c,v 1.103 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -138,7 +138,7 @@ cvs_server(int argc, char **argv) "the `Directory` request first", cmd); (*req->hdlr)(data); - xfree(cmd); + free(cmd); } return (0); @@ -159,7 +159,7 @@ cvs_server_send_response(char *fmt, ...) cvs_log(LP_TRACE, "%s", data); cvs_remote_output(data); - xfree(data); + free(data); } void @@ -237,7 +237,7 @@ cvs_server_validreq(char *data) cvs_server_send_response("Valid-requests %s", d); cvs_server_send_response("ok"); - xfree(d); + free(d); } void @@ -363,14 +363,14 @@ cvs_server_directory(char *data) entlist = cvs_ent_open(parent); cvs_ent_add(entlist, entry); - xfree(entry); + free(entry); } if (server_currentdir != NULL) - xfree(server_currentdir); + free(server_currentdir); server_currentdir = p; - xfree(dir); + free(dir); } void @@ -404,12 +404,12 @@ cvs_server_modified(char *data) len = cvs_remote_input(); cvs_strtomode(mode, &fmode); - xfree(mode); + free(mode); flen = strtonum(len, 0, INT_MAX, &errstr); if (errstr != NULL) fatal("cvs_server_modified: %s", errstr); - xfree(len); + free(len); (void)xsnprintf(fpath, PATH_MAX, "%s/%s", server_currentdir, data); @@ -829,6 +829,6 @@ cvs_server_exp_modules(char *module) cvs_server_send_response("ok"); server_argc--; - xfree(server_argv[1]); + free(server_argv[1]); server_argv[1] = NULL; } diff --git a/usr.bin/cvs/tag.c b/usr.bin/cvs/tag.c index a7a5fe47e33..3871e568cc3 100644 --- a/usr.bin/cvs/tag.c +++ b/usr.bin/cvs/tag.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tag.c,v 1.81 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: tag.c,v 1.82 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> * @@ -16,6 +16,7 @@ */ #include <errno.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -308,19 +309,14 @@ cvs_tag_check_files(struct cvs_file *cf) return; bad: - if (fi->file_path != NULL) - xfree(fi->file_path); - if (fi->crevstr != NULL) - xfree(fi->crevstr); - if (fi->nrevstr != NULL) - xfree(fi->nrevstr); - if (fi->tag_new != NULL) - xfree(fi->tag_new); - if (fi->tag_old != NULL) - xfree(fi->tag_old); + free(fi->file_path); + free(fi->crevstr); + free(fi->nrevstr); + free(fi->tag_new); + free(fi->tag_old); if (rev != NULL) rcsnum_free(rev); - xfree(fi); + free(fi); } void diff --git a/usr.bin/cvs/trigger.c b/usr.bin/cvs/trigger.c index 20a5e4dd650..9f85ef1e902 100644 --- a/usr.bin/cvs/trigger.c +++ b/usr.bin/cvs/trigger.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trigger.c,v 1.22 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: trigger.c,v 1.23 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2008 Tobias Stoeckmann <tobias@openbsd.org> * Copyright (c) 2008 Jonathan Armani <dbd@asystant.net> @@ -322,8 +322,7 @@ again: expanded = 1; } - if (q != NULL) - xfree(q); + free(q); } if (!expanded && default_args != NULL) { @@ -336,8 +335,7 @@ again: return (buf_release(buf)); bad: - if (q != NULL) - xfree(q); + free(q); cvs_log(LP_NOTICE, "%s contains malformed command '%s'", file, cmd); buf_free(buf); return (NULL); @@ -359,7 +357,7 @@ cvs_trigger_handle(int type, char *repo, char *in, struct trigger_list *list, case CVS_TRIGGER_TAGINFO: case CVS_TRIGGER_VERIFYMSG: if ((r = cvs_exec(cmd, NULL, 1)) != 0) { - xfree(cmd); + free(cmd); return (r); } break; @@ -367,7 +365,7 @@ cvs_trigger_handle(int type, char *repo, char *in, struct trigger_list *list, (void)cvs_exec(cmd, in, 1); break; } - xfree(cmd); + free(cmd); } return (0); @@ -460,8 +458,7 @@ cvs_trigger_getlines(char * file, char * repo) } } - if (nline != NULL) - xfree(nline); + free(nline); if (defaultline != NULL) { if (!match) { @@ -469,13 +466,13 @@ cvs_trigger_getlines(char * file, char * repo) tline->line = defaultline; TAILQ_INSERT_HEAD(list, tline, flist); } else - xfree(defaultline); + free(defaultline); } (void)fclose(fp); if (TAILQ_EMPTY(list)) { - xfree(list); + free(list); list = NULL; } @@ -483,9 +480,7 @@ cvs_trigger_getlines(char * file, char * repo) bad: cvs_log(LP_NOTICE, "%s: malformed line %d", file, lineno); - - if (defaultline != NULL) - xfree(defaultline); + free(defaultline); cvs_trigger_freelist(list); (void)fclose(fp); @@ -500,11 +495,11 @@ cvs_trigger_freelist(struct trigger_list * list) while ((line = TAILQ_FIRST(list)) != NULL) { TAILQ_REMOVE(list, line, flist); - xfree(line->line); - xfree(line); + free(line->line); + free(line); } - xfree(list); + free(list); } void @@ -515,20 +510,13 @@ cvs_trigger_freeinfo(struct file_info_list * list) while ((fi = TAILQ_FIRST(list)) != NULL) { TAILQ_REMOVE(list, fi, flist); - if (fi->file_path != NULL) - xfree(fi->file_path); - if (fi->file_wd != NULL) - xfree(fi->file_wd); - if (fi->crevstr != NULL) - xfree(fi->crevstr); - if (fi->nrevstr != NULL) - xfree(fi->nrevstr); - if (fi->tag_new != NULL) - xfree(fi->tag_new); - if (fi->tag_old != NULL) - xfree(fi->tag_old); - - xfree(fi); + free(fi->file_path); + free(fi->file_wd); + free(fi->crevstr); + free(fi->nrevstr); + free(fi->tag_new); + free(fi->tag_old); + free(fi); } } diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c index c276e1da2eb..fbe12aab845 100644 --- a/usr.bin/cvs/update.c +++ b/usr.bin/cvs/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.170 2015/02/05 12:59:57 millert Exp $ */ +/* $OpenBSD: update.c,v 1.171 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -21,6 +21,7 @@ #include <errno.h> #include <fcntl.h> #include <stdint.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -203,8 +204,7 @@ cvs_update_enterdir(struct cvs_file *cf) cvs_parse_tagfile(cf->file_wd, &dirtag, NULL, NULL); cvs_mkpath(cf->file_path, cvs_specified_tag != NULL ? cvs_specified_tag : dirtag); - if (dirtag != NULL) - xfree(dirtag); + free(dirtag); if ((cf->fd = open(cf->file_path, O_RDONLY)) == -1) fatal("cvs_update_enterdir: `%s': %s", @@ -218,7 +218,7 @@ cvs_update_enterdir(struct cvs_file *cf) entlist = cvs_ent_open(cf->file_wd); cvs_ent_add(entlist, entry); - xfree(entry); + free(entry); } } else if ((cf->file_status == DIR_CREATE && build_dirs == 0) || cf->file_status == FILE_UNKNOWN) { @@ -299,7 +299,7 @@ cvs_update_leavedir(struct cvs_file *cf) if (nbytes == -1) fatal("cvs_update_leavedir: %s", strerror(errno)); - xfree(buf); + free(buf); prune_it: if ((isempty == 1 && prune_dirs == 1) || @@ -526,7 +526,7 @@ update_clear_conflict(struct cvs_file *cf) entlist = cvs_ent_open(cf->file_wd); cvs_ent_add(entlist, entry); - xfree(entry); + free(entry); } /* @@ -574,7 +574,7 @@ update_has_conflict_markers(struct cvs_file *cf) } cvs_freelines(lines); - xfree(content); + free(content); return (conflict); } @@ -717,10 +717,8 @@ out: if (rev2 != NULL) rcsnum_free(rev2); - if (jrev1 != NULL) - xfree(jrev1); - if (jrev2 != NULL) - xfree(jrev2); + free(jrev1); + free(jrev2); } void diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c index 747c28346fd..50ac25565db 100644 --- a/usr.bin/cvs/util.c +++ b/usr.bin/cvs/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.157 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.158 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org> @@ -239,11 +239,11 @@ cvs_getargv(const char *line, char **argv, int argvlen) if (error != 0) { /* ditch the argument vector */ for (i = 0; i < (u_int)argc; i++) - xfree(argv[i]); + free(argv[i]); argc = -1; } - xfree(linebuf); + free(linebuf); return (argc); } @@ -284,8 +284,7 @@ cvs_freeargv(char **argv, int argc) int i; for (i = 0; i < argc; i++) - if (argv[i] != NULL) - xfree(argv[i]); + free(argv[i]); } /* @@ -648,14 +647,14 @@ cvs_mkpath(const char *path, char *tag) ent = cvs_ent_open(rpath); cvs_ent_add(ent, entry); - xfree(entry); + free(entry); if (p != NULL) *p = '/'; } } - xfree(dir); + free(dir); } void @@ -696,7 +695,7 @@ cvs_mkdir(const char *path, mode_t mode) fatal("cvs_mkdir: %s: %s", rpath, strerror(errno)); } - xfree(dir); + free(dir); } /* @@ -741,11 +740,11 @@ cvs_freelines(struct rcs_lines *lines) while ((lp = TAILQ_FIRST(&(lines->l_lines))) != NULL) { TAILQ_REMOVE(&(lines->l_lines), lp, l_list); if (lp->l_needsfree == 1) - xfree(lp->l_line); - xfree(lp); + free(lp->l_line); + free(lp); } - xfree(lines); + free(lines); } /* @@ -784,9 +783,9 @@ cvs_strsplit(char *str, const char *sep) void cvs_argv_destroy(struct cvs_argvector *av) { - xfree(av->str); - xfree(av->argv); - xfree(av); + free(av->str); + free(av->argv); + free(av); } u_int diff --git a/usr.bin/cvs/worklist.c b/usr.bin/cvs/worklist.c index 492bea99a95..f8fe501e15d 100644 --- a/usr.bin/cvs/worklist.c +++ b/usr.bin/cvs/worklist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: worklist.c,v 1.7 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: worklist.c,v 1.8 2015/11/05 09:48:21 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -24,6 +24,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -68,7 +69,7 @@ worklist_run(struct wklhead *list, void (*cb)(struct worklist *)) while ((wkl = SLIST_FIRST(list)) != NULL) { SLIST_REMOVE_HEAD(list, wkl_list); - xfree(wkl); + free(wkl); } sigprocmask(SIG_SETMASK, &old, NULL); diff --git a/usr.bin/cvs/xmalloc.c b/usr.bin/cvs/xmalloc.c index ea6c696b95b..0f399643b62 100644 --- a/usr.bin/cvs/xmalloc.c +++ b/usr.bin/cvs/xmalloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xmalloc.c,v 1.11 2015/02/05 12:59:57 millert Exp $ */ +/* $OpenBSD: xmalloc.c,v 1.12 2015/11/05 09:48:21 nicm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -67,14 +67,6 @@ xreallocarray(void *ptr, size_t nmemb, size_t size) return new_ptr; } -void -xfree(void *ptr) -{ - if (ptr == NULL) - fatal("xfree: NULL pointer given as argument"); - free(ptr); -} - char * xstrdup(const char *str) { diff --git a/usr.bin/cvs/xmalloc.h b/usr.bin/cvs/xmalloc.h index e6c9950ea64..bf7f4a0027c 100644 --- a/usr.bin/cvs/xmalloc.h +++ b/usr.bin/cvs/xmalloc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xmalloc.h,v 1.4 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: xmalloc.h,v 1.5 2015/11/05 09:48:21 nicm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> @@ -22,7 +22,6 @@ void *xmalloc(size_t); void *xcalloc(size_t, size_t); void *xreallocarray(void *, size_t, size_t); -void xfree(void *); char *xstrdup(const char *); int xasprintf(char **, const char *, ...) __attribute__((__format__ (printf, 2, 3))) |