From patchwork Sat Sep 27 18:27:59 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 5326 Received: from john.hrz.tu-chemnitz.de (john.hrz.tu-chemnitz.de [134.109.132.2]) by open-mesh.net (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id m8RIWdfi031842 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sat, 27 Sep 2008 20:32:41 +0200 Received: from galba.hrz.tu-chemnitz.de ([134.109.133.156] helo=mailbox.hrz.tu-chemnitz.de) by john.hrz.tu-chemnitz.de with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1KjeWL-0007RS-Qw for b.a.t.m.a.n@open-mesh.net; Sat, 27 Sep 2008 20:27:57 +0200 Received: from vpnclient-009.hrz.tu-chemnitz.de ([134.109.232.9] helo=sven-desktop) by mailbox.hrz.tu-chemnitz.de with smtp (Exim 4.69) (envelope-from ) id 1KjeWL-0008Un-IC for b.a.t.m.a.n@open-mesh.net; Sat, 27 Sep 2008 20:27:57 +0200 Received: by sven-desktop (nbSMTP-1.00) for uid 1000 sven.eckelmann@gmx.de; Sat, 27 Sep 2008 20:28:00 +0200 (CEST) Date: Sat, 27 Sep 2008 20:27:59 +0200 From: Sven Eckelmann To: b.a.t.m.a.n@open-mesh.net Message-ID: <20080927182759.GA14446@sven-desktop.lazhur.ath.cx> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Scan-Signature: b98711477dbcb0e35ed98064edb35ed3 Subject: [B.A.T.M.A.N.] [PATCH] Mark not returning functions with __noreturn__ X-BeenThere: b.a.t.m.a.n@open-mesh.net X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Sep 2008 18:32:41 -0000 The gcc feature for functions that will definitely not return should help the static analyzer and the optimizer slightly. See http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#Function-Attributes for more informations. --- batman/os.h | 8 +++++++- batman/posix/posix.c | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/batman/os.h b/batman/os.h index b1e9423..d29ebf1 100644 --- a/batman/os.h +++ b/batman/os.h @@ -22,6 +22,12 @@ #include "batman.h" +#ifdef __GNUC_MINOR__ +#define NO_RETURN __attribute__ ((__noreturn__)) +#else +#define NO_RETURN +#endif + uint32_t get_time_msec(void); uint64_t get_time_msec64(void); int32_t rand_num( int32_t limit ); @@ -34,7 +40,7 @@ void add_del_hna( struct orig_node *orig_node, int8_t del ); int8_t is_aborted(); void handler( int32_t sig ); void segmentation_fault( int32_t sig ); -void restore_and_exit( uint8_t is_sigsegv ); +void restore_and_exit( uint8_t is_sigsegv ) NO_RETURN; /* route.c */ void add_del_route( uint32_t dest, uint8_t netmask, uint32_t router, uint32_t src_ip, int32_t ifi, char *dev, uint8_t rt_table, int8_t route_type, int8_t del ); diff --git a/batman/posix/posix.c b/batman/posix/posix.c index b94ceae..432b45f 100644 --- a/batman/posix/posix.c +++ b/batman/posix/posix.c @@ -499,6 +499,8 @@ void restore_and_exit( uint8_t is_sigsegv ) { if ( !is_sigsegv ) exit(EXIT_FAILURE); + else + raise( SIGSEGV ); } @@ -515,8 +517,6 @@ void segmentation_fault( int32_t sig ) { restore_and_exit(1); - raise( SIGSEGV ); - }