In Unreal Engine source code, I noticed the following line:
cpp
const bool bHasRPCQueued = RemoteFunctions && RemoteFunctions->GetNumBits() >= 0;
GetNumBits() appears to represent the number of bits in the buffer, which should normally be non-negative. If that’s the case, the condition GetNumBits() >= 0 would always evaluate to true whenever RemoteFunctions is valid, making the check redundant.
Questions:
-
Are there any cases where
GetNumBits()can return a negative value (e.g., error/sentinel), making>= 0meaningful? -
If not, is this a bug/typo and the intended logic should be
GetNumBits() > 0to indicate there is actually queued RPC data? -
If it’s intentional, what is the rationale for using
>= 0here?
