diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-06-16 20:27:25 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-06-16 20:27:25 -0400 |
commit | d199d18159c624844c9c8052d1a98b91084fb803 (patch) | |
tree | 827dd9c4f8f1f6ef73ff1f20a609d08e36640986 /src/nvim/ex_docmd.c | |
parent | 8bbeb4b480a72d0099a18c4d8200313600045231 (diff) | |
parent | e85598e5a91c714c10034b6b3986a666065d1078 (diff) | |
download | rneovim-d199d18159c624844c9c8052d1a98b91084fb803.tar.gz rneovim-d199d18159c624844c9c8052d1a98b91084fb803.tar.bz2 rneovim-d199d18159c624844c9c8052d1a98b91084fb803.zip |
Merge #787 'removal of redundant OOM error handling'
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index e39eac993c..701a51799f 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3545,10 +3545,8 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp) for (l = repl; *l; ++l) if (vim_strchr(ESCAPE_CHARS, *l) != NULL) { l = vim_strsave_escaped(repl, ESCAPE_CHARS); - if (l != NULL) { - free(repl); - repl = l; - } + free(repl); + repl = l; break; } } @@ -3559,10 +3557,8 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp) char_u *l; l = vim_strsave_escaped(repl, (char_u *)"!"); - if (l != NULL) { - free(repl); - repl = l; - } + free(repl); + repl = l; } p = repl_cmdline(eap, p, srclen, repl, cmdlinep); @@ -7913,8 +7909,7 @@ makeopens ( return FAIL; } else if (ssop_flags & SSOP_CURDIR) { sname = home_replace_save(NULL, globaldir != NULL ? globaldir : dirnow); - if (sname == NULL - || fputs("cd ", fd) < 0 + if (fputs("cd ", fd) < 0 || ses_put_fname(fd, sname, &ssop_flags) == FAIL || put_eol(fd) == FAIL) { free(sname); @@ -8539,17 +8534,13 @@ static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp) * Write a file name to the session file. * Takes care of the "slash" option in 'sessionoptions' and escapes special * characters. - * Returns FAIL if writing fails or out of memory. + * Returns FAIL if writing fails. */ static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp) { - char_u *sname; char_u *p; - int retval = OK; - sname = home_replace_save(NULL, name); - if (sname == NULL) - return FAIL; + char_u *sname = home_replace_save(NULL, name); if (*flagp & SSOP_SLASH) { /* change all backslashes to forward slashes */ @@ -8561,13 +8552,9 @@ static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp) /* escape special characters */ p = vim_strsave_fnameescape(sname, FALSE); free(sname); - if (p == NULL) - return FAIL; /* write the result */ - if (fputs((char *)p, fd) < 0) - retval = FAIL; - + bool retval = fputs((char *)p, fd) < 0 ? FAIL : OK; free(p); return retval; } |