mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #2303 'Fix clang analysis warnings. (9)'
This commit is contained in:
commit
95db8df682
@ -5942,18 +5942,23 @@ dictitem_T *dict_find(dict_T *d, char_u *key, int len)
|
|||||||
return HI2DI(hi);
|
return HI2DI(hi);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a function from a dictionary
|
/// Get a function from a dictionary
|
||||||
static ufunc_T *get_dict_callback(dict_T *d, char *key)
|
/// @param[out] result The address where a pointer to the wanted callback
|
||||||
|
/// will be left.
|
||||||
|
/// @return true/false on success/failure.
|
||||||
|
static bool get_dict_callback(dict_T *d, char *key, ufunc_T **result)
|
||||||
{
|
{
|
||||||
dictitem_T *di = dict_find(d, (uint8_t *)key, -1);
|
dictitem_T *di = dict_find(d, (uint8_t *)key, -1);
|
||||||
|
|
||||||
if (di == NULL) {
|
if (di == NULL) {
|
||||||
return NULL;
|
*result = NULL;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (di->di_tv.v_type != VAR_FUNC && di->di_tv.v_type != VAR_STRING) {
|
if (di->di_tv.v_type != VAR_FUNC && di->di_tv.v_type != VAR_STRING) {
|
||||||
EMSG(_("Argument is not a function or function name"));
|
EMSG(_("Argument is not a function or function name"));
|
||||||
return NULL;
|
*result = NULL;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *name = di->di_tv.vval.v_string;
|
uint8_t *name = di->di_tv.vval.v_string;
|
||||||
@ -5970,11 +5975,13 @@ static ufunc_T *get_dict_callback(dict_T *d, char *key)
|
|||||||
|
|
||||||
if (!rv) {
|
if (!rv) {
|
||||||
EMSG2(_("Function %s doesn't exist"), name);
|
EMSG2(_("Function %s doesn't exist"), name);
|
||||||
return NULL;
|
*result = NULL;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
rv->uf_refcount++;
|
rv->uf_refcount++;
|
||||||
|
|
||||||
return rv;
|
*result = rv;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -10810,6 +10817,8 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(args->lv_first);
|
||||||
|
|
||||||
if (!os_can_exe(args->lv_first->li_tv.vval.v_string, NULL)) {
|
if (!os_can_exe(args->lv_first->li_tv.vval.v_string, NULL)) {
|
||||||
// String is not executable
|
// String is not executable
|
||||||
EMSG2(e_jobexe, args->lv_first->li_tv.vval.v_string);
|
EMSG2(e_jobexe, args->lv_first->li_tv.vval.v_string);
|
||||||
@ -10820,8 +10829,7 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv)
|
|||||||
ufunc_T *on_stdout = NULL, *on_stderr = NULL, *on_exit = NULL;
|
ufunc_T *on_stdout = NULL, *on_stderr = NULL, *on_exit = NULL;
|
||||||
if (argvars[1].v_type == VAR_DICT) {
|
if (argvars[1].v_type == VAR_DICT) {
|
||||||
job_opts = argvars[1].vval.v_dict;
|
job_opts = argvars[1].vval.v_dict;
|
||||||
common_job_callbacks(job_opts, &on_stdout, &on_stderr, &on_exit);
|
if (!common_job_callbacks(job_opts, &on_stdout, &on_stderr, &on_exit)) {
|
||||||
if (did_emsg) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15077,8 +15085,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv)
|
|||||||
dict_T *job_opts = NULL;
|
dict_T *job_opts = NULL;
|
||||||
if (argvars[1].v_type == VAR_DICT) {
|
if (argvars[1].v_type == VAR_DICT) {
|
||||||
job_opts = argvars[1].vval.v_dict;
|
job_opts = argvars[1].vval.v_dict;
|
||||||
common_job_callbacks(job_opts, &on_stdout, &on_stderr, &on_exit);
|
if (!common_job_callbacks(job_opts, &on_stdout, &on_stderr, &on_exit)) {
|
||||||
if (did_emsg) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20051,27 +20058,27 @@ static inline JobOptions common_job_options(char **argv, ufunc_T *on_stdout,
|
|||||||
return opts;
|
return opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void common_job_callbacks(dict_T *vopts, ufunc_T **on_stdout,
|
/// Return true/false on success/failure.
|
||||||
ufunc_T **on_stderr, ufunc_T **on_exit)
|
static inline bool common_job_callbacks(dict_T *vopts, ufunc_T **on_stdout,
|
||||||
|
ufunc_T **on_stderr, ufunc_T **on_exit)
|
||||||
{
|
{
|
||||||
*on_stdout = get_dict_callback(vopts, "on_stdout");
|
if (get_dict_callback(vopts, "on_stdout", on_stdout)
|
||||||
*on_stderr = get_dict_callback(vopts, "on_stderr");
|
&& get_dict_callback(vopts, "on_stderr", on_stderr)
|
||||||
*on_exit = get_dict_callback(vopts, "on_exit");
|
&& get_dict_callback(vopts, "on_exit", on_exit)) {
|
||||||
if (did_emsg) {
|
vopts->internal_refcount++;
|
||||||
if (*on_stdout) {
|
vopts->dv_refcount++;
|
||||||
user_func_unref(*on_stdout);
|
return true;
|
||||||
}
|
|
||||||
if (*on_stderr) {
|
|
||||||
user_func_unref(*on_stderr);
|
|
||||||
}
|
|
||||||
if (*on_exit) {
|
|
||||||
user_func_unref(*on_exit);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
if (*on_stdout) {
|
||||||
vopts->internal_refcount++;
|
user_func_unref(*on_stdout);
|
||||||
vopts->dv_refcount++;
|
}
|
||||||
|
if (*on_stderr) {
|
||||||
|
user_func_unref(*on_stderr);
|
||||||
|
}
|
||||||
|
if (*on_exit) {
|
||||||
|
user_func_unref(*on_exit);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Job *common_job_start(JobOptions opts, typval_T *rettv)
|
static inline Job *common_job_start(JobOptions opts, typval_T *rettv)
|
||||||
|
@ -1047,7 +1047,7 @@ static void redraw(bool restore_cursor)
|
|||||||
setcursor();
|
setcursor();
|
||||||
} else if (restore_cursor) {
|
} else if (restore_cursor) {
|
||||||
ui_cursor_goto(save_row, save_col);
|
ui_cursor_goto(save_row, save_col);
|
||||||
} else {
|
} else if (term) {
|
||||||
// exiting terminal focus, put the window cursor in a valid position
|
// exiting terminal focus, put the window cursor in a valid position
|
||||||
int height, width;
|
int height, width;
|
||||||
vterm_get_size(term->vt, &height, &width);
|
vterm_get_size(term->vt, &height, &width);
|
||||||
@ -1099,28 +1099,30 @@ static bool is_focused(Terminal *term)
|
|||||||
do { \
|
do { \
|
||||||
Error err; \
|
Error err; \
|
||||||
o = dict_get_value(t->buf->b_vars, cstr_as_string(k), &err); \
|
o = dict_get_value(t->buf->b_vars, cstr_as_string(k), &err); \
|
||||||
if (obj.type == kObjectTypeNil) { \
|
if (o.type == kObjectTypeNil) { \
|
||||||
o = dict_get_value(&globvardict, cstr_as_string(k), &err); \
|
o = dict_get_value(&globvardict, cstr_as_string(k), &err); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static char *get_config_string(Terminal *term, char *key)
|
static char *get_config_string(Terminal *term, char *key)
|
||||||
{
|
{
|
||||||
Object obj = OBJECT_INIT;
|
Object obj;
|
||||||
GET_CONFIG_VALUE(term, key, obj);
|
GET_CONFIG_VALUE(term, key, obj);
|
||||||
if (obj.type == kObjectTypeString) {
|
if (obj.type == kObjectTypeString) {
|
||||||
return obj.data.string.data;
|
return obj.data.string.data;
|
||||||
}
|
}
|
||||||
|
api_free_object(obj);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_config_int(Terminal *term, char *key)
|
static int get_config_int(Terminal *term, char *key)
|
||||||
{
|
{
|
||||||
Object obj = OBJECT_INIT;
|
Object obj;
|
||||||
GET_CONFIG_VALUE(term, key, obj);
|
GET_CONFIG_VALUE(term, key, obj);
|
||||||
if (obj.type == kObjectTypeInteger) {
|
if (obj.type == kObjectTypeInteger) {
|
||||||
return (int)obj.data.integer;
|
return (int)obj.data.integer;
|
||||||
}
|
}
|
||||||
|
api_free_object(obj);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1766,7 +1766,7 @@ static int close_last_window_tabpage(win_T *win, int free_buf, tabpage_T *prev_c
|
|||||||
}
|
}
|
||||||
buf_T *old_curbuf = curbuf;
|
buf_T *old_curbuf = curbuf;
|
||||||
|
|
||||||
Terminal *term = win->w_buffer->terminal;
|
Terminal *term = win->w_buffer ? win->w_buffer->terminal : NULL;
|
||||||
if (term) {
|
if (term) {
|
||||||
// Don't free terminal buffers
|
// Don't free terminal buffers
|
||||||
free_buf = false;
|
free_buf = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user