V591. Non-void function must return value.
V591 [CWE-393] Non-void function should return a value. lua_ptr.hpp 34
template<typename T>
class enable_lua_ptr
{
public:
....
enable_lua_ptr& operator=(enable_lua_ptr&& o)
{
self_ = std::move(o.self_);
*self_ = static_cast<T*>(this);
} // <=
....
}
V591 Non-void function should return a value. typed_flag.h 145
template <typename T>
requires(std::is_enum_v<T>)
class TypedFlag
{
public:
using EnumType = T;
using ValueType = std::underlying_type_t<T>;
....
private:
ValueType m_value = 0;
....
friend TypedFlag<T> operator|(TypedFlag<T> value, TypedFlag<T> flags)
{
}
....
};
Similar errors can be found in some other places:
V591 Non-void function should return a value. chrono.h 110
enum class Domain
{
// boring host clock:
Host,
// adheres to guest scaling
// (differrent speed, changing clock drift etc):
Guest
};
template <Domain domain_>
struct NtSystemClock
{
....
[[nodiscard]] static time_point now() noexcept
{
if constexpr (domain_ == Domain::Host)
{
// QueryHostSystemTime() returns
// windows epoch times even on POSIX
return from_file_time(Clock::QueryHostSystemTime());
}
else if constexpr (domain_ == Domain::Guest)
{
return from_file_time(Clock::QueryGuestSystemTime());
}
}
....
};
Inside the function, the domain_ data member is checked against the enum elements. While there are only two values, just like in the check, we can't be sure that there won't be extra elements in the future. Therefore, we should make the function always return a value for all execution branches, or the code should not compile.
V591 [CERT-MSC52-CPP] Non-void function should return a value. registers_pool.hpp 229
template <typename TReg>
int getFree(int requestedIdx)
{
if (std::is_base_of<Xbyak::Mmx, TReg>::value)
{
....
return idx;
}
else if (....)
{
....
return idx;
}
else if (std::is_same<TReg, Xbyak::Opmask>::value)
{
return getFreeOpmask(requestedIdx);
}
}
V591 [CERT-MSC52-CPP] Non-void function should return a value. graph_iterator_flatbuffer.hpp 29
template <typename T>
std::basic_string<T> get_model_extension() {}
Similar errors can be found in some other places:
V591 Non-void function should return a value. tools.cpp:1278
static bool StopAtComponentPre(const Symbol &component) {
if constexpr (componentKind == ComponentKind::Ordered) {
// Parent components need to be iterated upon after their
// sub-components in structure constructor analysis.
return !component.test(Symbol::Flag::ParentComp);
} else if constexpr (componentKind == ComponentKind::Direct) {
return true;
} else if constexpr (componentKind == ComponentKind::Ultimate) {
return component.has<ProcEntityDetails>() ||
IsAllocatableOrObjectPointer(&component) ||
(component.has<ObjectEntityDetails>() &&
component.get<ObjectEntityDetails>().type() &&
component.get<ObjectEntityDetails>().type()->AsIntrinsic());
} else if constexpr (componentKind == ComponentKind::Potential) {
return !IsPointer(component);
} else if constexpr (componentKind == ComponentKind::PotentialAndPointer) {
return true;
}
}
V591 [CWE-393, CERT-MSC52-CPP] Non-void function should return a value. qd_sound.h 70
class qdSound : public qdNamedObject, public qdResource
{
....
float length() const {
#ifndef __QD_SYSLIB__
return sound_.length();
#endif
}
....
}
V591 Non-void function should return a value. lie_group_base.h 347
template <typename _Derived>
typename LieGroupBase<_Derived>::Scalar*
LieGroupBase<_Derived>::data()
{
return derived().coeffs().data(); // OK
}
template <typename _Derived>
const typename LieGroupBase<_Derived>::Scalar*
LieGroupBase<_Derived>::data() const
{
derived().coeffs().data(); // ERROR
}
V591 Non-void function should return a value. matrix.hpp 109
template<typename Scalar>
class matrix {
....
matrix& diagonal() {
}
....
};
V591 Non-void function should return a value. px_render.h 398
struct DisplayList {
DisplayList& operator=(DisplayList &&d) {
data_ = d.data_;
d.data_ = nullptr;
}
....
}
V591 Non-void function should return a value. vector_view.hpp 184
template <typename UAlloc>
vector_view& operator=(const std::vector<U, UAlloc>& other)
{
size_type n = other.size();
resize(n);
for (size_type i = 0; i < n; ++i)
{
this->at(i) = other[i];
}
}
V591 Non-void function should return a value. vector_view.hpp 163
template <typename T, typename U, typename Alloc = std::allocator<T>>
class vector_view
{
....
vector_view& operator=(vector_view&& other)
{
m_vector = std::move(other.m_vector);
}
....
}
V591 Non-void function should return a value. numpunct.hpp 528
template <int Base>
class no_grouping final
{
constexpr STRF_HD no_grouping& operator=(const no_grouping& other) noexcept
{
decimal_point_ = other.decimal_point_;
}
....
}
V591 Non-void function should return a value. numpunct.hpp 402
template <int Base>
class numpunct: private strf::digits_grouping
{
....
constexpr STRF_HD numpunct& operator=(const numpunct& other) noexcept
{
strf::digits_grouping::operator=(other);
decimal_point_ = other.decimal_point_;
thousands_sep_ = other.thousands_sep_;
}
....
};
V591 Non-void function should return a value. HEAP.H 123
int FixedHeapClass::Free(void * pointer);
template<class T>
class TFixedHeapClass : public FixedHeapClass
{
....
virtual int Free(T * pointer) {FixedHeapClass::Free(pointer);};
};
V591 Non-void function should return a value. LogLikelihoodFCN.h 108
LogLikelihoodFCN & operator = (const LogLikelihoodFCN & rhs) {
SetData(rhs.DataPtr() );
SetModelFunction(rhs.ModelFunctionPtr() );
fNEffPoints = rhs.fNEffPoints;
fGrad = rhs.fGrad;
fIsExtended = rhs.fIsExtended;
fWeight = rhs.fWeight;
fExecutionPolicy = rhs.fExecutionPolicy;
}
V591 Non-void function should return a value. main.c 1010
void errx(int, const char *, ...) ;
char *
getoptionvalue(const char *name)
{
struct option *c;
if (name == NULL)
errx(1, "getoptionvalue() invoked with NULL name");
c = getoption(name);
if (c != NULL)
return (c->value);
errx(1, "getoptionvalue() invoked with unknown option `%s'", name);
/* NOTREACHED */
}
'errx' doesn't contain noreturn attribute.
V591 Non-void function should return a value. Referenceable.h 228
BReference& operator=(const BReference<const Type>& other)
{
fReference = other.fReference;
}
Similar errors can be found in some other places:
V591 Non-void function should return a value. bio_tree.hpp 266
/// Recursive assignment
CBioNode& operator=(const CBioNode& tree)
{
TParent::operator=(tree);
TBioTree* pt = (TBioTree*)tree.GetParentTree();
SetParentTree(pt);
}
V591 CWE-393 Non-void function should return a value. linux_close.cpp 139
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, int *fromlen) {
socklen_t socklen = *fromlen;
BLOCKING_IO_RETURN_INT(
s, recvfrom(s, buf, len, flags, from, &socklen) );
*fromlen = socklen;
}
Similar errors can be found in some other places:
V591 Non-void function should return a value. eina_accessor.hh 330
_self_type& operator=(_self_type const& other)
{
_base_type::operator=(other);
}
V591 Non-void function should return a value. ecore_evas_extn.c 1526
static Eina_Bool
_ipc_server_data(void *data, int type EINA_UNUSED, void *event)
{
....
//TIZEN_ONLY(170317): add skipping indicator buffer logic
if (indicator_buffer_skip)
return;
//END
....
//TIZEN_ONLY(170317): add skipping indicator buffer logic
if (_ecore_evas_indicator_size_check(ee, &(extn->b[n].w)))
{
indicator_buffer_skip = EINA_TRUE;
return; // <=
}
else
indicator_buffer_skip = EINA_FALSE;
//END
....
}
Similar errors can be found in some other places:
V591 Non-void function should return a value. lsort.hpp 159
template <class N>
static inline N * fix_links(N * cur)
{
N * prev = 0;
while (cur) {
cur->prev = prev;
prev = cur;
cur = cur->next;
}
}
V591 Non-void function should return a value. RPCUtils.h 719
SequenceNumberManager &operator=(SequenceNumberManager &&Other) {
NextSequenceNumber = std::move(Other.NextSequenceNumber);
FreeSequenceNumbers = std::move(Other.FreeSequenceNumbers);
}
V591 Non-void function should return a value. memory_allocator.h 39
CheckReturnValue& operator=(const CheckReturnValue& other) {
if (this != &other) {
DCHECK(checked_);
value_ = other.value_;
checked_ = other.checked_;
other.checked_ = true;
}
}
Missing return *this.
V591 Non-void function should return a value. _matrix33.h 435
template <class T>
struct _matrix33
{
public:
typedef _matrix33<T>Self;
typedef Self& SelfRef;
....
IC SelfRef sMTxV(Tvector& R, float s1, const Tvector& V1) const
{
R.x = s1*(m[0][0] * V1.x + m[1][0] * V1.y + m[2][0] * V1.z);
R.y = s1*(m[0][1] * V1.x + m[1][1] * V1.y + m[2][1] * V1.z);
R.z = s1*(m[0][2] * V1.x + m[1][2] * V1.y + m[2][2] * V1.z);
}
....
}
V591 Non-void function should return a value. slistview.h 53
class FColumnHeaderSlot
{
public:
FColumnHeaderSlot& operator[](
const TSharedRef< SHeaderRow >& InColumnHeaders )
{
HeaderRow = InColumnHeaders;
}
....
}
Missing return *this.
V591 Non-void function should return a value. x86_float4.h 237
struct float4
{
....
inline float4 rsqrt() const {
}
inline float4 sqrt() const {
}
inline float4 recip() const {
}
....
};
Similar errors can be found in some other places:
V591 Non-void function should return a value. pc.c 1031
ULONG
set_var(char *name, ULONG val)
{
variable *v;
v = lookup_var(name);
if (v != NULL)
v->value = val;
else
add_var(name, val);
}
V591 Non-void function should return a value. botlib q_shared.h 155
static ID_INLINE int BigLong(int l)
{ LongSwap(l); }
Need: { return LongSwap(l); }
Similar errors can be found in some other places: