[Nut-upsdev] Fwd: Megatec - modem control lines [impact to megatec_usb]

Carlos Rodrigues carlos.efr at mail.telepac.pt
Tue Jun 19 23:09:15 UTC 2007


On 6/19/07, Arjen de Korte <nut+devel at de-korte.org> wrote:
> Trying to religiously avoid using #ifdef's is just as silly as the blanket
> statement that goto's should be avoided (which is in our
> docs/developers.txt document and rightfully ignored by quite a few among
> us). If you intend to compile the same source file more than once with
> different defines, please be considerate with your fellow developers and
> let them at least know what your intentions are by placing the #ifdef's
> where they are used and don't hide them in a header file.

That's why I said "mostly".

I don't think there's a loss of readability there (nor gain), simply
because what matters is mostly seeing what's happening there and not
if the call is going to be ifdef'd out in the serial driver or just
implemented as an empty function. I (mostly) don't like ifdefs mixed
with code because I don't like to be distracted by compilation issues
when looking at functional issues.

But, like I said, I "mostly" don't like ifdefs. For the particular
case of those ioctl calls, I'm not seeing another way. I don't like it
much, but I guess that's pretty much the solution.

> Not surprisingly, all USB drivers have this same set of arguments which
> don't make sense for serial drivers. Likewise, there are arguments that
> are needed for serial drivers ('port' for instance), which are irrelevant
> for USB drivers. I'm very much in favor of defining variables that are
> interface specific and not driver specific by default. So the set of
> regular expressions that are used for USB connected drivers are put in
> there, while the 'port' parameter would be used for serial connected ones.
> By doing so, only the parameters that are really driver specific would be
> defined in the upsdrv_makevartable(). Would that be worthwile to
> investigate further?

I agree. However, megatec.c only defines driver specific variables,
and megatec_usb.c also has the need to specify at least one specific
variable besides the ones that could be considered USB-generic.

-- 
Carlos Rodrigues



More information about the Nut-upsdev mailing list