[PATCH phosphor-host-ipmid 3/4] Suport examining sensor records and calling dbus

Patrick Williams patrick at stwcx.xyz
Fri Oct 16 09:13:27 AEDT 2015


On Thu, Oct 15, 2015 at 10:43:22AM -0500, OpenBMC Patches wrote:
> From: Chris Austen <austenc at us.ibm.com>
> 
> diff --git a/ipmisensor.C b/ipmisensor.C
> new file mode 100644
> index 0000000..c2370b8
> --- /dev/null
> +++ b/ipmisensor.C
> @@ -0,0 +1,119 @@
> +#include <stdio.h>
> +#include <string.h>
> +#include <stdint.h>
> +
> +
> +extern unsigned char findSensor(char);

I couldn't figure out where this came from.  If you are intending this
to be a function used between multiple parts, it should probably be in a
header file and extern "C" (to avoid C++ name mangling).  Forward
declaring a function defined elsewhere like this can lead to code that 
compiles but doesn't dlopen.

> +#define ISBITSET(x,y) ((x>>y)&0x01)

(((x)>>(y))&0x01) for macro safety.  Inline function instead?

> +
> +extern int updateDbusInterface(uint8_t , const char *, const char *) ;
> +extern int set_sensor_dbus_state(uint8_t ,const char *, const char *);
> +

Same extern statement here.

> +int findindex(const uint8_t sensor_type, int offset, int *index) {
> +	
> +	int i=0, rc=0;
> +	lookup_t *pTable = ipmidbuslookup;
> +
> +	do {
> +
> +		if ( ((pTable+i)->sensor_type == sensor_type) && 
> +			 ((pTable+i)->offset  == offset)  ) {
> +			rc = 1;
> +			*index = i;
> +			break;
> +		}
> +		i++;
> +	} while ((pTable+i)->sensor_type  != 0xFF);

Prefer std::find for this.  With C++11 you can make a lambda function
for the ->sensor_type and ->offset comparisons.

> +	return rc;

Should this return a pointer to the pTable entry instead?

> diff --git a/sensorhandler.C b/sensorhandler.C
> index 9f0c975..0b16d10 100644
> --- a/sensorhandler.C
> +++ b/sensorhandler.C
> @@ -4,6 +4,7 @@
>  #include <string.h>
>  #include <stdint.h>
>  
> +extern int updateSensorRecordFromSSRAESC(const void *);

Another extern.  Lots of cross-file calling.
-- 
Patrick Williams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20151015/53ce6a81/attachment.sig>


More information about the openbmc mailing list