aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/ex_docmd.c2
-rw-r--r--src/nvim/ex_getln.c16
2 files changed, 7 insertions, 11 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index d6ad71275b..66a4ac71c3 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -8557,8 +8557,6 @@ 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)
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 10702775d4..959dfd1584 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -28,6 +28,7 @@
#include "nvim/ex_eval.h"
#include "nvim/farsi.h"
#include "nvim/fileio.h"
+#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/if_cscope.h"
#include "nvim/indent.h"
@@ -2960,10 +2961,8 @@ void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char_u **files, int o
#else
p = vim_strsave_fnameescape(files[i], xp->xp_shell);
#endif
- if (p != NULL) {
- free(files[i]);
- files[i] = p;
- }
+ free(files[i]);
+ files[i] = p;
/* If 'str' starts with "\~", replace "~" at start of
* files[i] with "\~". */
@@ -2995,7 +2994,7 @@ void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char_u **files, int o
* after a Vim command, or, when "shell" is non-zero, a shell command.
* Returns the result in allocated memory.
*/
-char_u *vim_strsave_fnameescape(char_u *fname, int shell)
+char_u *vim_strsave_fnameescape(char_u *fname, int shell) FUNC_ATTR_NONNULL_RET
{
char_u *p;
#ifdef BACKSLASH_IN_FILENAME
@@ -3011,11 +3010,9 @@ char_u *vim_strsave_fnameescape(char_u *fname, int shell)
#else
p = vim_strsave_escaped(fname, shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS);
if (shell && csh_like_shell()) {
- char_u *s;
-
/* For csh and similar shells need to put two backslashes before '!'.
* One is taken by Vim, one by the shell. */
- s = vim_strsave_escaped(p, (char_u *)"!");
+ char_u *s = vim_strsave_escaped(p, (char_u *)"!");
free(p);
p = s;
}
@@ -3023,8 +3020,9 @@ char_u *vim_strsave_fnameescape(char_u *fname, int shell)
/* '>' and '+' are special at the start of some commands, e.g. ":edit" and
* ":write". "cd -" has a special meaning. */
- if (p != NULL && (*p == '>' || *p == '+' || (*p == '-' && p[1] == NUL)))
+ if (*p == '>' || *p == '+' || (*p == '-' && p[1] == NUL)) {
escape_fname(&p);
+ }
return p;
}