[rkward] rkward: Remove checks for "this != 0".

Thomas Friedrichsmeier null at kde.org
Sun Apr 15 09:29:34 UTC 2018


Git commit 7f3a0485a530ed18fe7d64d31c47ee6e2e0e4126 by Thomas Friedrichsmeier.
Committed on 15/04/2018 at 09:27.
Pushed by tfry into branch 'master'.

Remove checks for "this != 0".

They produce a _lot_ of warnings when compiling with clang, and probably would not actually help prevent crashes, indeed.

M  +2    -2    rkward/core/robject.h
M  +1    -5    rkward/rbackend/rdata.cpp
M  +4    -4    rkward/rbackend/rdata.h

https://commits.kde.org/rkward/7f3a0485a530ed18fe7d64d31c47ee6e2e0e4126

diff --git a/rkward/core/robject.h b/rkward/core/robject.h
index 90a8cca0..44ee3c0a 100644
--- a/rkward/core/robject.h
+++ b/rkward/core/robject.h
@@ -130,8 +130,8 @@ public:
 	bool isType (int type) const { return (RObject::type & type); };
 	bool isPseudoObject () const { return isType (PseudoObject); };
 	PseudoObjectType getPseudoObjectType () const { return pseudo_object_types.value (this, InvalidPseudoObject); };
-	bool isSlotsPseudoObject () const { return (this && isPseudoObject () && (getPseudoObjectType () == SlotsObject)); };
-	bool isPackageNamespace () const { return (this && isPseudoObject () && (getPseudoObjectType () == NamespaceObject)); };
+	bool isSlotsPseudoObject () const { return (isPseudoObject () && (getPseudoObjectType () == SlotsObject)); };
+	bool isPackageNamespace () const { return (isPseudoObject () && (getPseudoObjectType () == NamespaceObject)); };
 	bool hasPseudoObject (const PseudoObjectType type) const { return (contained_objects & type); };
 	bool hasMetaObject () const { return (meta_map); };
 	/** see RObjectType::Pending */
diff --git a/rkward/rbackend/rdata.cpp b/rkward/rbackend/rdata.cpp
index dd6bfc6c..08171193 100644
--- a/rkward/rbackend/rdata.cpp
+++ b/rkward/rbackend/rdata.cpp
@@ -34,11 +34,7 @@ RData::~RData () {
 }
 
 void RData::doAssert(RData::RDataType requested_type) const {
-	if (this == 0) {
-		RK_DEBUG (RBACKEND, DL_ERROR, "Requested data from a NULL RData");
-	} else { 
-		RK_DEBUG (RBACKEND, DL_ERROR, "Reqeusted data of type %d, while %p has type %d", requested_type, this, datatype);
-	}
+	RK_DEBUG (RBACKEND, DL_ERROR, "Reqeusted data of type %d, while %p has type %d", requested_type, this, datatype);
 }
 
 void RData::discardData () {
diff --git a/rkward/rbackend/rdata.h b/rkward/rbackend/rdata.h
index e180937e..28762b7d 100644
--- a/rkward/rbackend/rdata.h
+++ b/rkward/rbackend/rdata.h
@@ -44,7 +44,7 @@ public:
 	unsigned int getDataLength () const;
 /** returns a vector of double, if that is the type of data contained (else, an assert is raised, and an empty vector is returned). Can be used safely on a null RData pointer (but raises an assert in this case). @see RCommand::GetRealVector @see RData::getDataType () */
 	const RealStorage realVector () const {
-		if (this && (datatype == RealVector)) {
+		if (datatype == RealVector) {
 			return (*static_cast<RealStorage *> (data));
 		}
 		doAssert (RealVector);
@@ -52,7 +52,7 @@ public:
 	}
 /** returns a vector of int, if that is the type of data contained (else, an assert is raised, and an empty vector is returned). Can be used safely on a null RData pointer (but raises an assert in this case). @see RCommand::GetIntVector @see RData::getDataType () */
 	const IntStorage intVector () const {
-		if (this && (datatype == IntVector)) {
+		if (datatype == IntVector) {
 			return (*static_cast<IntStorage *> (data));
 		}
 		doAssert (IntVector);
@@ -60,7 +60,7 @@ public:
 	}
 /** returns a QStringList, if that is the type of data contained (else, an assert is raised, and an empty vector is returned). Can be used safely on a null RData pointer (but raises an assert in this case). @see RCommand::GetStringVector @see RData::getDataType () */
 	const StringStorage stringVector () const {
-		if (this && (datatype == StringVector)) {
+		if (datatype == StringVector) {
 			return (*static_cast<StringStorage *> (data));
 		}
 		doAssert (StringVector);
@@ -68,7 +68,7 @@ public:
 	}
 /** returns a vector of RData*, if that is the type of data contained (else, an assert is raised, and an empty vector is returned). Can be used safely on a null RData pointer (but raises an assert in this case). @see RCommand::GetStructureVector @see RData::getDataType () */
 	const RDataStorage structureVector () const {
-		if (this && (datatype == StructureVector)) {
+		if (datatype == StructureVector) {
 			return (*static_cast<RDataStorage *> (data));
 		}
 		doAssert (StructureVector);



More information about the rkward-tracker mailing list