Hardcoded values in ipmiAsynPortDriver::writeInt32()
In the constructor of ipmiAsynPortDriver
there are 3 interval parameters defined:
CREATE_AND_SET_INTERVALS(SensorInterval-SP, 60, SENSOR_INTERVAL) ;
CREATE_AND_SET_INTERVALS(ThreshInterval-SP, 15, THRESH_INTERVAL) ;
CREATE_AND_SET_INTERVALS(EventInterval-SP, 10, EVENT_INTERVAL) ;
SENSOR_INTERVAL
, etc are macros and are used only in ipmiMonitor::setIntervals()
and are defined in ipmiMonitor.h
as follows:
#define SENSOR_INTERVAL 0
#define THRESH_INTERVAL 1
#define EVENT_INTERVAL 2
In writeInt32()
these macros are not used at all; the parameter names and their order (and therefore the indices) are hardcoded and they just happen to match the corresponding macro values:
const char * intervals[3] = { "SensorInterval-SP", "ThreshInterval-SP", "EventInterval-SP" } ;
for ( unsigned int i = 0 ; i < sizeof(intervals)/sizeof(intervals[0]) ; i++ )
{
int ind ;
findParam(intervals[i], &ind) ;
if ( function == ind )
{
int val ;
getIntegerParam( ind, &val ) ;
monitor.setIntervals( i, val ) ;
This seems really fragile to me