@@ -403,7 +403,7 @@ float Q_rsqrt( float n )
403403The relative error bound is: 6.50196699×10⁻⁴ */
404404
405405// Compute approximate inverse square root.
406- inline float Q_rsqrt_fast ( const float n )
406+ WARN_UNUSED_RESULT inline float Q_rsqrt_fast ( const float n )
407407{
408408#if defined(DAEMON_USE_ARCH_INTRINSICS_i686_sse)
409409 float o;
@@ -422,7 +422,7 @@ inline float Q_rsqrt_fast( const float n )
422422 return o;
423423}
424424
425- inline float Q_rsqrt ( const float n )
425+ WARN_UNUSED_RESULT inline float Q_rsqrt ( const float n )
426426{
427427 /* When using the magic constants, the relative error bound after the
428428 iteration is expected to be at most 5×10⁻⁶. It was achieved with the
@@ -440,19 +440,19 @@ inline float Q_rsqrt( const float n )
440440 return o;
441441}
442442
443- inline float Q_fabs ( float x )
443+ WARN_UNUSED_RESULT inline float Q_fabs ( float x )
444444{
445445 return fabsf ( x );
446446}
447447
448- byte ClampByte ( int i );
449- signed char ClampChar ( int i );
448+ WARN_UNUSED_RESULT byte ClampByte ( int i );
449+ WARN_UNUSED_RESULT signed char ClampChar ( int i );
450450
451451// this isn't a real cheap function to call!
452- int DirToByte ( vec3_t const dir );
452+ WARN_UNUSED_RESULT int DirToByte ( vec3_t const dir );
453453void ByteToDir ( int b, vec3_t dir );
454454
455- inline vec_t DotProduct ( const vec3_t x, const vec3_t y )
455+ WARN_UNUSED_RESULT inline vec_t DotProduct ( const vec3_t x, const vec3_t y )
456456{
457457 return x[ 0 ] * y[ 0 ] + x[ 1 ] * y[ 1 ] + x[ 2 ] * y[ 2 ];
458458}
@@ -465,7 +465,7 @@ inline void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross )
465465}
466466
467467template <typename A>
468- decltype (std::declval<A>() * std::declval<A>()) Square( const A &a )
468+ WARN_UNUSED_RESULT decltype (std::declval<A>() * std::declval<A>()) Square( const A &a )
469469{
470470 return a * a;
471471}
@@ -587,16 +587,16 @@ void SnapVector( V &&v )
587587 ( r )[ 1 ] = ( s )[ 1 ] + ( f ) * (( e )[ 1 ] - ( s )[ 1 ] ), \
588588 ( r )[ 2 ] = ( s )[ 2 ] + ( f ) * (( e )[ 2 ] - ( s )[ 2 ] ))
589589
590- float RadiusFromBounds ( const vec3_t mins, const vec3_t maxs );
590+ WARN_UNUSED_RESULT float RadiusFromBounds ( const vec3_t mins, const vec3_t maxs );
591591 void ZeroBounds ( vec3_t mins, vec3_t maxs );
592592 void ClearBounds ( vec3_t mins, vec3_t maxs );
593593 void AddPointToBounds ( const vec3_t v, vec3_t mins, vec3_t maxs );
594594
595595 void BoundsAdd ( vec3_t mins, vec3_t maxs, const vec3_t mins2, const vec3_t maxs2 );
596- bool BoundsIntersect ( const vec3_t mins, const vec3_t maxs, const vec3_t mins2, const vec3_t maxs2 );
597- bool BoundsIntersectSphere ( const vec3_t mins, const vec3_t maxs, const vec3_t origin, vec_t radius );
598- bool BoundsIntersectPoint ( const vec3_t mins, const vec3_t maxs, const vec3_t origin );
599- float BoundsMaxExtent ( const vec3_t mins, const vec3_t maxs );
596+ WARN_UNUSED_RESULT bool BoundsIntersect ( const vec3_t mins, const vec3_t maxs, const vec3_t mins2, const vec3_t maxs2 );
597+ WARN_UNUSED_RESULT bool BoundsIntersectSphere ( const vec3_t mins, const vec3_t maxs, const vec3_t origin, vec_t radius );
598+ WARN_UNUSED_RESULT bool BoundsIntersectPoint ( const vec3_t mins, const vec3_t maxs, const vec3_t origin );
599+ WARN_UNUSED_RESULT float BoundsMaxExtent ( const vec3_t mins, const vec3_t maxs );
600600
601601 inline void BoundsToCorners ( const vec3_t mins, const vec3_t maxs, vec3_t corners[ 8 ] )
602602 {
@@ -617,7 +617,7 @@ void SnapVector( V &&v )
617617 out[ 2 ] = from[ 2 ] + ( ( to[ 2 ] - from[ 2 ] ) * frac );
618618 }
619619
620- inline int VectorCompareEpsilon ( const vec3_t v1, const vec3_t v2, float epsilon )
620+ WARN_UNUSED_RESULT inline int VectorCompareEpsilon ( const vec3_t v1, const vec3_t v2, float epsilon )
621621 {
622622 vec3_t d;
623623
@@ -648,29 +648,29 @@ void SnapVector( V &&v )
648648 out[2 ] = a[2 ] > b[2 ] ? a[2 ] : b[2 ];
649649 }
650650
651- inline int VectorCompare ( const vec3_t v1, const vec3_t v2 )
651+ WARN_UNUSED_RESULT inline bool VectorCompare ( const vec3_t v1, const vec3_t v2 )
652652{
653653 return !( v1[ 0 ] != v2[ 0 ] || v1[ 1 ] != v2[ 1 ] || v1[ 2 ] != v2[ 2 ] );
654654}
655655
656- inline vec_t VectorLengthSquared ( const vec3_t v )
656+ WARN_UNUSED_RESULT inline vec_t VectorLengthSquared ( const vec3_t v )
657657{
658658 return v[ 0 ] * v[ 0 ] + v[ 1 ] * v[ 1 ] + v[ 2 ] * v[ 2 ];
659659}
660660
661- inline vec_t VectorLength ( const vec3_t v )
661+ WARN_UNUSED_RESULT inline vec_t VectorLength ( const vec3_t v )
662662{
663663 return sqrtf ( VectorLengthSquared ( v ) );
664664}
665665
666- inline vec_t Distance ( const vec3_t p1, const vec3_t p2 )
666+ WARN_UNUSED_RESULT inline vec_t Distance ( const vec3_t p1, const vec3_t p2 )
667667{
668668 vec3_t v;
669669 VectorSubtract ( p2, p1, v );
670670 return VectorLength ( v );
671671}
672672
673- inline vec_t DistanceSquared ( const vec3_t p1, const vec3_t p2 )
673+ WARN_UNUSED_RESULT inline vec_t DistanceSquared ( const vec3_t p1, const vec3_t p2 )
674674{
675675 vec3_t v;
676676 VectorSubtract ( p2, p1, v );
@@ -735,7 +735,7 @@ inline vec_t VectorNormalize2( const vec3_t v, vec3_t out )
735735 return length;
736736}
737737
738- int NearestPowerOfTwo ( int val );
738+ WARN_UNUSED_RESULT int NearestPowerOfTwo ( int val );
739739
740740 int Q_rand ( int *seed );
741741 float Q_random ( int *seed );
@@ -757,17 +757,17 @@ inline vec_t VectorNormalize2( const vec3_t v, vec3_t out )
757757 void AxisCopy ( const vec3_t in[ 3 ], vec3_t out[ 3 ] );
758758
759759 void SetPlaneSignbits ( struct cplane_t *out );
760- int BoxOnPlaneSide ( const vec3_t emins, const vec3_t emaxs, const struct cplane_t *plane );
760+ WARN_UNUSED_RESULT int BoxOnPlaneSide ( const vec3_t emins, const vec3_t emaxs, const struct cplane_t *plane );
761761
762- float AngleMod ( float a );
763- float LerpAngle ( float from, float to, float frac );
764- float AngleSubtract ( float a1, float a2 );
765- void AnglesSubtract ( vec3_t v1, vec3_t v2, vec3_t v3 );
762+ WARN_UNUSED_RESULT DEPRECATED float AngleMod ( float a );
763+ WARN_UNUSED_RESULT float LerpAngle ( float from, float to, float frac );
764+ WARN_UNUSED_RESULT float AngleSubtract ( float a1, float a2 );
765+ void AnglesSubtract ( const vec3_t v1, const vec3_t v2, vec3_t v3 );
766766
767- float AngleNormalize360 ( float angle );
768- float AngleNormalize180 ( float angle );
769- float AngleDelta ( float angle1, float angle2 );
770- float AngleBetweenVectors ( const vec3_t a, const vec3_t b );
767+ WARN_UNUSED_RESULT float AngleNormalize360 ( float angle );
768+ WARN_UNUSED_RESULT float AngleNormalize180 ( float angle );
769+ WARN_UNUSED_RESULT float AngleDelta ( float angle1, float angle2 );
770+ WARN_UNUSED_RESULT float AngleBetweenVectors ( const vec3_t a, const vec3_t b );
771771 void AngleVectors ( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up );
772772
773773 void PlaneSet ( plane_t &out, const vec_t x, const vec_t y, const vec_t z, const vec_t dist );
@@ -804,13 +804,10 @@ inline vec_t VectorNormalize2( const vec3_t v, vec3_t out )
804804 void AxisMultiply ( const float in1[ 3 ][ 3 ], const float in2[ 3 ][ 3 ], float out[ 3 ][ 3 ] );
805805 void PerpendicularVector ( vec3_t dst, const vec3_t src );
806806
807- // Ridah
808807 void GetPerpendicularViewVector ( const vec3_t point, const vec3_t p1, const vec3_t p2, vec3_t up );
809808 void ProjectPointOntoVector ( const vec3_t point, const vec3_t vStart, const vec3_t vEnd, vec3_t vProj );
810809 void ProjectPointOntoVectorBounded ( const vec3_t point, const vec3_t vStart, const vec3_t vEnd, vec3_t vProj );
811- float DistanceFromLineSquared ( const vec3_t p, const vec3_t lp1, const vec3_t lp2 );
812-
813- // done.
810+ WARN_UNUSED_RESULT float DistanceFromLineSquared ( const vec3_t p, const vec3_t lp1, const vec3_t lp2 );
814811
815812 vec_t DistanceBetweenLineSegmentsSquared ( const vec3_t sP0 , const vec3_t sP1 ,
816813 const vec3_t tP0, const vec3_t tP1, float *s, float *t );
@@ -822,7 +819,7 @@ inline vec_t VectorNormalize2( const vec3_t v, vec3_t out )
822819 void MatrixIdentity ( matrix_t m );
823820 void MatrixClear ( matrix_t m );
824821 void MatrixCopy ( const matrix_t in, matrix_t out );
825- bool MatrixCompare ( const matrix_t a, const matrix_t b );
822+ WARN_UNUSED_RESULT bool MatrixCompare ( const matrix_t a, const matrix_t b );
826823 void MatrixTransposeIntoXMM ( const matrix_t m );
827824 void MatrixTranspose ( const matrix_t in, matrix_t out );
828825
@@ -961,7 +958,7 @@ inline vec_t VectorNormalize2( const vec3_t v, vec3_t out )
961958 q[ 3 ] = -q[ 3 ];
962959 }
963960
964- inline vec_t QuatLength ( const quat_t q )
961+ WARN_UNUSED_RESULT inline vec_t QuatLength ( const quat_t q )
965962 {
966963 return ( vec_t ) sqrt ( q[ 0 ] * q[ 0 ] + q[ 1 ] * q[ 1 ] + q[ 2 ] * q[ 2 ] + q[ 3 ] * q[ 3 ] );
967964 }
0 commit comments