From ff2a403bd2fcd1c816444d9181fb1977d1923d2e Mon Sep 17 00:00:00 2001 From: Karsten Graul Date: Fri, 19 Oct 2018 13:17:06 +0200 Subject: [PATCH] osasnmpd: remove unused code, improve readability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove unused code because query_OSA_EXP does actually never return -1. So make its return value unsigned and remove all checks for negative return values. Signed-off-by: Karsten Graul Signed-off-by: Jan Höppner --- osasnmpd/ibmOSAMib.c | 10 +--------- osasnmpd/ibmOSAMibUtil.c | 16 ++-------------- osasnmpd/ibmOSAMibUtil.h | 2 +- 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/osasnmpd/ibmOSAMib.c b/osasnmpd/ibmOSAMib.c index 39c7cd0d..a9e5178d 100644 --- a/osasnmpd/ibmOSAMib.c +++ b/osasnmpd/ibmOSAMib.c @@ -85,15 +85,7 @@ void init_ibmOSAMib(void) { /* query OSA-E device driver for OSA-E devices and mark them in IF-MIB interface list */ osaexp_num = query_OSA_EXP ( &if_list, ifNumber ); - if ( osaexp_num < 0 ) - { - fprintf( stderr, "init_ibmOSAMib(): " - "OSA-E device driver query interface ioctl() failed\n" - "check agent log file for more details\n" - "Cannot start subagent...exiting...\n"); - exit(1); - } - else if ( osaexp_num == 0 ) + if ( osaexp_num == 0 ) { get_time( time_buf ); snmp_log( LOG_ERR, "%s init_ibmOSAMib(): none of the %d interfaces is a real " diff --git a/osasnmpd/ibmOSAMibUtil.c b/osasnmpd/ibmOSAMibUtil.c index 73ab793d..efc0b1e4 100644 --- a/osasnmpd/ibmOSAMibUtil.c +++ b/osasnmpd/ibmOSAMibUtil.c @@ -1204,18 +1204,7 @@ void update_mib_info () * and mark them in IF-MIB interface list * */ osaexp_num = query_OSA_EXP( &tmp_list, if_num ); - if ( osaexp_num < 0 ) - { - get_time( time_buf ); - fprintf( stderr, "%s update_mib_info(): " - "OSA-E device driver query interface ioctl() " - "failed\nupdate_mib_info(): going to stop osasnmpd daemon\n" - "update_mib_info(): check subagent logfile for more details\n" - "update_mib_info(): sending termination signal to osasnmpd...\n", - time_buf ); - exit(-1); - } - else if ( osaexp_num == 0 ) + if ( osaexp_num == 0 ) { get_time( time_buf ); snmp_log( LOG_ERR, "%s update_mib_info(): " @@ -1698,9 +1687,8 @@ int query_IF_MIB ( IF_LIST** ifList ) * IN int if_Number: number of network interfaces * returns: int num - number of OSA Express devices found on this * system (>=0) - * -1 -an error occurred , no valid info avail *********************************************************************/ -int query_OSA_EXP ( IF_LIST** ifList, int if_Number ) +unsigned int query_OSA_EXP ( IF_LIST** ifList, int if_Number ) { int j, num = 0; char time_buf[TIME_BUF_SIZE]; /* date/time buffer */ diff --git a/osasnmpd/ibmOSAMibUtil.h b/osasnmpd/ibmOSAMibUtil.h index 2824737a..18feee6a 100644 --- a/osasnmpd/ibmOSAMibUtil.h +++ b/osasnmpd/ibmOSAMibUtil.h @@ -91,7 +91,7 @@ void update_mib_info ( ); int query_IF_MIB( IF_LIST** ); /* retrieves OSA Express interface information from kernel */ -int query_OSA_EXP ( IF_LIST** ,int ); +unsigned int query_OSA_EXP ( IF_LIST** ,int ); /* get time of day */ int get_time( char* );