Citeren Michal Soltys <sol...@ziu.info>:

I think I found one bug with flag handling though:

dstate_setflags() uses = when setting new flags. This has a side effect, that any later setflags() call will override earlier flags (as expected), but that also includes the immutable flag (and that we don't want, as it will enable the ups to e.g. poll and update the variable at will afterwards). It could be fixed in a few ways:

1) make sure each driver reads the variable first and preserves
   immutable flag (probably lots of fixing all over the place)
2) dstate_setflags() could use an extra argument to specify if to
   preserve or not
3) make that an immutable flag once set, cannot be unset (simple,
   probably good solution, as immutable flags come from override.*)
4) something else

I'd choose #3, but ...

The ST_FLAG_IMMUTABLE is only supposed to be used for read-only values from the UPS. For those variables, dstate_setflags() must not be used (it is intended to set ST_FLAG_RW and sometimes in addition, ST_FLAG_STRING).

If a writeable value is wrong, you should not override it in ups.conf, but rather change it. It doesn't make much sense to allow writing variables if you don't allow the value to be changed. So in this respect, the ST_FLAG_IMMUTABLE is working as intended.

Best regards, Arjen
--
Please keep list traffic on the list (off-list replies will be rejected)


_______________________________________________
Nut-upsdev mailing list
Nut-upsdev@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev

Reply via email to