[Nut-upsdev] upsdrv_info structure

Arjen de Korte nut+devel at de-korte.org
Mon Feb 15 22:22:29 UTC 2010


Arnaud,

If memory serves, you're the one that 'invented' the upsdrv_info_t  
subdriver description structure. We seem to have an issue with this on  
Solaris. I suspect that we're introducing GCC specific behavior here.

Technically the typedef here isn't possible in C89, since this  
suggests that sizeof(upsdrv_info_t) can be determined. This obvious is  
not the case, since we can (and will) have variable number of  
subdrv_info elements and therefor the size is variable.

Can you elaborate on what your intended use for this was at the time  
you added this? It looks like currently this is only used for printing  
some info in the upsdrv_banner() call. For the time being, I think we  
could fix this by hardcoding the number of elements (we never use more  
than 2, but could always increase this number if needed):

/* subdriver description structure */
struct upsdrv_info_s {
	const char	*name;		/* driver full name, for banner printing, ... */
	const char	*version;	/* driver version */
	const char	*authors;	/* authors name */
	const int	status;		/* driver development status */
	struct upsdrv_info_s	*subdrv_info[2];	/* sub driver information */
};

typedef struct upsdrv_info_s	upsdrv_info_t;

Can't we just use something like

static upsdrv_info_t	driver_info = {
	DRIVER_NAME,
	DRIVER_VERSION,
	"Ex Ample <nobody op example.com>",
	DRV_EXPERIMENTAL
};

upsdrv_info_t	*upsdrv_info[] = {
	&driver_info,
	&subdriver_info,
	NULL
};

In this example, subdriver_info is exported by an external module and  
that is linked in the main driver.

Best regards, Arjen
-- 
Please keep list traffic on the list




More information about the Nut-upsdev mailing list