[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-cvs
Subject:    [LyX/master] Annotate destructors to please coverity
From:       Jean-Marc Lasgouttes <lasgouttes () lyx ! org>
Date:       2017-03-31 9:17:21
Message-ID: 20170331091721.92727280259 () lyx ! lyx ! org
[Download RAW message or body]

commit e10db6c7dd971f060d1bdeaa16f20f5450e74a9b
Author: Jean-Marc Lasgouttes <lasgouttes@lyx.org>
Date:   Mon Mar 27 16:18:14 2017 +0200

    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.
---
 src/insets/Inset.h          |    4 ++--
 src/insets/InsetBibitem.cpp |    3 +++
 src/insets/InsetBibtex.cpp  |    4 ++++
 src/insets/InsetInclude.cpp |    3 +++
 4 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index 5d7f27f..3d93904 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 18a261a..1c8bc78 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 ef79481..63ae865 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 b2eca71..1c80aff 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_;
 }

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic