[Nut-upsdev] upsdrv_info structure

Arnaud Quette aquette.dev at gmail.com
Tue Feb 16 16:20:41 UTC 2010


2010/2/15 Arjen de Korte:
> 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?

the base idea was to simplify, while completing, the drivers information by:
- removing the upsdrv_banner() function, which only printed driver and
subdriver(s) info. This is currently limited to communication
subdrivers (shut or usb for the hidcore),
- adding the authors (and possibly maintainers) information,
- (for future extension) allowing driver's extension, with other
things like callbacks pointers (as done in subdrivers) to serve
various purposes...

> 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 at 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.

that suits me fine.
as you told, if we need more, we will still be able to extend things.

cheers,
Arnaud
-- 
Linux / Unix Expert R&D - Eaton - http://www.eaton.com/mgeops
Network UPS Tools (NUT) Project Leader - http://www.networkupstools.org/
Debian Developer - http://www.debian.org
Free Software Developer - http://arnaud.quette.free.fr/



More information about the Nut-upsdev mailing list