From: Jean-Marc Lasgouttes Date: Mon, 27 Mar 2017 14:18:14 +0000 (+0200) Subject: Annotate destructors to please coverity X-Git-Tag: 2.3.0alpha1~152 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e10db6c7dd971f060d1bdeaa16f20f5450e74a9b;p=features.git Annotate destructors to please coverity Coverity flags this code as not handling exception that may happen in buffer(). My own analysis is that this can never happen because isBufferValid() does check whether buffer_ is null. Any insght appreciated. The commit should be expeanded to more cases, actually. --- diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 5d7f27f89f..3d93904fdb 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -112,8 +112,8 @@ public: /// reset associated Buffer to null value virtual void resetBuffer(); /// retrieve associated Buffer - virtual Buffer & buffer(); - virtual Buffer const & buffer() const; + Buffer & buffer(); + Buffer const & buffer() const; /// Returns true if buffer_ actually points to a Buffer that has /// been loaded into LyX and is still open. Note that this will /// always return false for cloned Buffers. If you want to allow diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index 18a261a3e0..1c8bc786db 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -68,6 +68,9 @@ InsetBibitem::InsetBibitem(Buffer * buf, InsetCommandParams const & p) InsetBibitem::~InsetBibitem() { if (isBufferLoaded()) + /* Coverity believs that this may throw an exception, but + * actually this code path is not taken when buffer_ == 0 */ + // coverity[exn_spec_violation] buffer().invalidateBibinfoCache(); } diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index ef794814ae..63ae8657f0 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -68,7 +68,11 @@ InsetBibtex::InsetBibtex(Buffer * buf, InsetCommandParams const & p) InsetBibtex::~InsetBibtex() { if (isBufferLoaded()) { + /* Coverity believs that this may throw an exception, but + * actually this code path is not taken when buffer_ == 0 */ + // coverity[exn_spec_violation] buffer().invalidateBibfileCache(); + // coverity[exn_spec_violation] buffer().removeBiblioTempFiles(); } } diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index b2eca71505..1c80afffd7 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -198,6 +198,9 @@ InsetInclude::InsetInclude(InsetInclude const & other) InsetInclude::~InsetInclude() { if (isBufferLoaded()) + /* Coverity believs that this may throw an exception, but + * actually this code path is not taken when buffer_ == 0 */ + // coverity[exn_spec_violation] buffer().invalidateBibfileCache(); delete label_; }