From 6f6f1ab20fa5d23966bd75af4f594a6ebd99416f Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Thu, 23 Apr 2020 14:02:15 +0200 Subject: [PATCH] Fix undefined behaviour. In C++ functions returning non-void must finish with a "return" statement. Otherwise this brings to undefined behaviour, which in my particular case (GCC 9.3.0 on Debian unstable) causes a segmentation fault. --- src/calamp.c | 4 ++-- src/selpsc_patch.c | 10 +++++----- src/selsbc_patch.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/calamp.c b/src/calamp.c index dcf9c65..2184453 100755 --- a/src/calamp.c +++ b/src/calamp.c @@ -37,7 +37,7 @@ using namespace std; // ======================================================================= // Start of program // ======================================================================= -int cshortswap( complex* f ) +void cshortswap( complex* f ) { char* b = reinterpret_cast(f); complex f2; @@ -49,7 +49,7 @@ int cshortswap( complex* f ) f[0]=f2; } -int cfloatswap( complex* f ) +void cfloatswap( complex* f ) { char* b = reinterpret_cast(f); complex f2; diff --git a/src/selpsc_patch.c b/src/selpsc_patch.c index b1caf7a..8927dd2 100755 --- a/src/selpsc_patch.c +++ b/src/selpsc_patch.c @@ -47,7 +47,7 @@ using namespace std; // ======================================================================= // Start of program // ======================================================================= -int cshortswap( complex* f ) +void cshortswap( complex* f ) { char* b = reinterpret_cast(f); complex f2; @@ -59,7 +59,7 @@ int cshortswap( complex* f ) f[0]=f2; } -int shortswap( short* f ) +void shortswap( short* f ) { char* b = reinterpret_cast(f); short f2; @@ -69,7 +69,7 @@ int shortswap( short* f ) f[0]=f2; } -int cfloatswap( complex* f ) +void cfloatswap( complex* f ) { char* b = reinterpret_cast(f); complex f2; @@ -85,7 +85,7 @@ int cfloatswap( complex* f ) f[0]=f2; } -int floatswap( float* f ) +void floatswap( float* f ) { char* b = reinterpret_cast(f); float f2; @@ -97,7 +97,7 @@ int floatswap( float* f ) f[0]=f2; } -int longswap( int32_t* f ) +void longswap( int32_t* f ) { char* b = reinterpret_cast(f); int32_t f2; diff --git a/src/selsbc_patch.c b/src/selsbc_patch.c index bc73674..cdce25b 100755 --- a/src/selsbc_patch.c +++ b/src/selsbc_patch.c @@ -48,7 +48,7 @@ using namespace std; // ======================================================================= // Start of program // ======================================================================= -int cshortswap( complex* f ) +void cshortswap( complex* f ) { char* b = reinterpret_cast(f); complex f2; @@ -60,7 +60,7 @@ int cshortswap( complex* f ) f[0]=f2; } -int cfloatswap( complex* f ) +void cfloatswap( complex* f ) { char* b = reinterpret_cast(f); complex f2; @@ -75,7 +75,7 @@ int cfloatswap( complex* f ) b2[7] = b[4]; f[0]=f2; } -int longswap( int32_t* f ) +void longswap( int32_t* f ) { char* b = reinterpret_cast(f); int32_t f2;