[nagiosplug] check_snmp: Close potential for using ...

Nagios Plugin Development nagios-plugins at users.sourceforge.net
Tue Aug 27 18:51:10 CEST 2013


 Module: nagiosplug
 Branch: master
 Commit: a20611d4357c3c3ebe0a62776a1642e7904c1410
 Author: Robin Sonefors <robin.sonefors at op5.com>
   Date: Tue Jan 29 15:08:44 2013 +0100
    URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=a20611d

check_snmp: Close potential for using uninitialized memory

This was reported by clang, and in order for it to understand attributes
properly, I had to modify the macro that checks for non-gcc compilers.

Signed-off-by: Robin Sonefors <robin.sonefors at op5.com>

---

 plugins/check_snmp.c |    3 ++-
 plugins/common.h     |    6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 28354b0..c73562b 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -229,13 +229,14 @@ main (int argc, char **argv)
 
 	np_set_args(argc, argv);
 
+	time(&current_time);
+
 	if (process_arguments (argc, argv) == ERROR)
 		usage4 (_("Could not parse arguments"));
 
 	if(calculate_rate) {
 		if (!strcmp(label, "SNMP"))
 			label = strdup("SNMP RATE");
-		time(&current_time);
 		i=0;
 		previous_state = np_state_read();
 		if(previous_state!=NULL) {
diff --git a/plugins/common.h b/plugins/common.h
index c0dc2f4..f024b2a 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -208,9 +208,9 @@ enum {
 # define bindtextdomain(Domainname, Dirname) /* empty */
 #endif
 
-/* For non-GNU compilers to ignore __attribute__ */
-#ifndef __GNUC__
-# define __attribute__(x) /* do nothing */
+/* For non-GNU/non-clang compilers to ignore __attribute__ */
+#if !defined(__GNUC__) && !defined(__CLANG__)
+# define __attribute__(noreturn) /* do nothing */
 #endif
 
 #endif /* _COMMON_H_ */





More information about the Commits mailing list