From bb978fa69ccab4b5b764ac025274145291cea3ca Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Wed, 28 May 2014 23:02:04 -0300 Subject: No OOM in save_cmdline_alloc() --- src/nvim/ex_getln.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 994b2f510f..96731f6a1a 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2307,10 +2307,8 @@ char_u *save_cmdline_alloc(void) */ void restore_cmdline_alloc(char_u *p) { - if (p != NULL) { - restore_cmdline((struct cmdline_info *)p); - free(p); - } + restore_cmdline((struct cmdline_info *)p); + free(p); } /* -- cgit From ab016d3dbd97bfba0493f1ee083fe4690cb21b81 Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Wed, 28 May 2014 23:10:01 -0300 Subject: No OOM in expand_shellcmd() --- src/nvim/ex_getln.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 96731f6a1a..78f466f497 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3655,8 +3655,10 @@ ExpandFromContext ( return FAIL; } - if (xp->xp_context == EXPAND_SHELLCMD) - return expand_shellcmd(pat, num_file, file, flags); + if (xp->xp_context == EXPAND_SHELLCMD) { + expand_shellcmd(pat, num_file, file, flags); + return OK; + } if (xp->xp_context == EXPAND_OLD_SETTING) return ExpandOldSetting(num_file, file); if (xp->xp_context == EXPAND_BUFFERS) @@ -3836,9 +3838,8 @@ int ExpandGeneric( /* * Complete a shell command. - * Returns FAIL or OK; */ -static int +static void expand_shellcmd ( char_u *filepat, /* pattern to match with command names */ int *num_file, /* return: number of matches */ @@ -3926,7 +3927,6 @@ expand_shellcmd ( free(pat); if (mustfree) free(path); - return OK; } /* -- cgit From 0b849e775cd0a2be8e34109d265f21cd78138bc7 Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Wed, 28 May 2014 23:13:38 -0300 Subject: No OOM in ExpandGeneric() --- src/nvim/ex_getln.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 78f466f497..f2f00d3bd0 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3743,10 +3743,12 @@ ExpandFromContext ( ret = FAIL; for (i = 0; i < (int)(sizeof(tab) / sizeof(struct expgen)); ++i) if (xp->xp_context == tab[i].context) { - if (tab[i].ic) + if (tab[i].ic) { regmatch.rm_ic = TRUE; - ret = ExpandGeneric(xp, ®match, num_file, file, - tab[i].func, tab[i].escaped); + } + ExpandGeneric(xp, ®match, num_file, file, tab[i].func, + tab[i].escaped); + ret = OK; break; } } @@ -3762,10 +3764,8 @@ ExpandFromContext ( * Generic function for command line completion. It calls a function to * obtain strings, one by one. The strings are matched against a regexp * program. Matching strings are copied into an array, which is returned. - * - * Returns OK when no problems encountered, FAIL for error. */ -int ExpandGeneric( +void ExpandGeneric( expand_T *xp, regmatch_T *regmatch, int *num_file, @@ -3790,7 +3790,7 @@ int ExpandGeneric( } } if (count == 0) - return OK; + return; *num_file = count; *file = (char_u **)xmalloc(count * sizeof(char_u *)); @@ -3832,8 +3832,6 @@ int ExpandGeneric( /* Reset the variables used for special highlight names expansion, so that * they don't show up when getting normal highlight names by ID. */ reset_expand_highlight(); - - return OK; } /* -- cgit From 8234f2839f78009442b4ed7bc0599e6b581d5cf8 Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Fri, 30 May 2014 22:46:26 -0300 Subject: No OOM in vim_strsave_escaped[_ext]() --- src/nvim/ex_getln.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index f2f00d3bd0..10702775d4 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2947,17 +2947,13 @@ void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char_u **files, int o /* for ":set path=" we need to escape spaces twice */ if (xp->xp_backslash == XP_BS_THREE) { p = vim_strsave_escaped(files[i], (char_u *)" "); - if (p != NULL) { - free(files[i]); - files[i] = p; + free(files[i]); + files[i] = p; #if defined(BACKSLASH_IN_FILENAME) - p = vim_strsave_escaped(files[i], (char_u *)" "); - if (p != NULL) { - free(files[i]); - files[i] = p; - } + p = vim_strsave_escaped(files[i], (char_u *)" "); + free(files[i]); + files[i] = p; #endif - } } #ifdef BACKSLASH_IN_FILENAME p = vim_strsave_fnameescape(files[i], FALSE); @@ -2987,10 +2983,8 @@ void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char_u **files, int o */ for (i = 0; i < numfiles; ++i) { p = vim_strsave_escaped(files[i], (char_u *)"\\|\""); - if (p != NULL) { - free(files[i]); - files[i] = p; - } + free(files[i]); + files[i] = p; } } } @@ -3016,7 +3010,7 @@ char_u *vim_strsave_fnameescape(char_u *fname, int shell) p = vim_strsave_escaped(fname, buf); #else p = vim_strsave_escaped(fname, shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS); - if (shell && csh_like_shell() && p != NULL) { + if (shell && csh_like_shell()) { char_u *s; /* For csh and similar shells need to put two backslashes before '!'. -- cgit From cca66742ebbc13a88b809173b2362245c2ba6a55 Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Fri, 30 May 2014 23:51:39 -0300 Subject: No OOM in vim_strsave_fnameescape() --- src/nvim/ex_getln.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/nvim/ex_getln.c') 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; } -- cgit From f4002c97dc36e817a59b5e18c852d1a17e775c1c Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Sat, 31 May 2014 00:48:14 -0300 Subject: No OOM in ExpandOldSetting() --- src/nvim/ex_getln.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 959dfd1584..02c82eaf21 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3651,8 +3651,10 @@ ExpandFromContext ( expand_shellcmd(pat, num_file, file, flags); return OK; } - if (xp->xp_context == EXPAND_OLD_SETTING) - return ExpandOldSetting(num_file, file); + if (xp->xp_context == EXPAND_OLD_SETTING) { + ExpandOldSetting(num_file, file); + return OK; + } if (xp->xp_context == EXPAND_BUFFERS) return ExpandBufnames(pat, num_file, file, options); if (xp->xp_context == EXPAND_TAGS -- cgit