diff options
author | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-11-09 09:33:48 +0100 |
---|---|---|
committer | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-11-11 01:43:13 +0100 |
commit | 1002e3fe1ddb1d95c838197dc802c3b1ba094bd3 (patch) | |
tree | d1bc4bdb559c02148a858f29669e1ae79ec156e9 | |
parent | d6472f459bc531bf6e24c3bcc1916dba16ba1f10 (diff) | |
download | rneovim-1002e3fe1ddb1d95c838197dc802c3b1ba094bd3.tar.gz rneovim-1002e3fe1ddb1d95c838197dc802c3b1ba094bd3.tar.bz2 rneovim-1002e3fe1ddb1d95c838197dc802c3b1ba094bd3.zip |
Fix warnings: fold.c: get_foldtext(): Np dereference: FP.
Problem : Dereference of null pointer @ 1701.
Diagnostic : False positive.
Rationale : Comparison `last_wp != wp` just after initializing
`last_wp` to NULL makes the compiler think `wp` can be
null. Error appears then on codepath assuming comparison is
false (i.e. `wp` is null).
Resolution : Change order of OR clauses.
That seems not to give motives for the analyzer to check
the `wp` null path and removes the warning.
But potential null dereference is still there, so we add
the nonnull annotation to `wp` parameter.
-rw-r--r-- | src/nvim/fold.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 95f1e054b9..6014dbfd15 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -22,6 +22,7 @@ #include "nvim/diff.h" #include "nvim/eval.h" #include "nvim/ex_docmd.h" +#include "nvim/func_attr.h" #include "nvim/indent.h" #include "nvim/mark.h" #include "nvim/memline.h" @@ -1680,7 +1681,9 @@ static void foldDelMarker(linenr_T lnum, char_u *marker, int markerlen) * When 'foldtext' isn't set puts the result in "buf[51]". Otherwise the * result is in allocated memory. */ -char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T *foldinfo, char_u *buf) +char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, + foldinfo_T *foldinfo, char_u *buf) + FUNC_ATTR_NONNULL_ARG(1) { char_u *text = NULL; /* an error occurred when evaluating 'fdt' setting */ @@ -1689,8 +1692,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T *foldi static win_T *last_wp = NULL; static linenr_T last_lnum = 0; - if (last_wp != wp || last_wp == NULL - || last_lnum > lnum || last_lnum == 0) + if (last_wp == NULL || last_wp != wp || last_lnum > lnum || last_lnum == 0) /* window changed, try evaluating foldtext setting once again */ got_fdt_error = FALSE; |