rpi-rgb-led-matrix icon indicating copy to clipboard operation
rpi-rgb-led-matrix copied to clipboard

Add RT_OPT_COPY_IF_NOT_SET

Open greatballoflazers opened this issue 3 years ago • 0 comments

There is possible issue for C where you cannot control realtime options. Currently logic assumes default of disabled and changes enable. However some parameters are enabled by default and would need to be disabled.

Example:

  if (rt_opts) {
    // Same story as RGBMatrix::Options
#define RT_OPT_COPY_IF_SET(o) if (rt_opts->o) default_rt.o = rt_opts->o
    RT_OPT_COPY_IF_SET(gpio_slowdown);
    RT_OPT_COPY_IF_SET(daemon);
    RT_OPT_COPY_IF_SET(drop_privileges);
    RT_OPT_COPY_IF_SET(do_gpio_init);
#undef RT_OPT_COPY_IF_SET
  }

Proposed change:

  if (rt_opts) {
    // Same story as RGBMatrix::Options
#define RT_OPT_COPY_IF_SET(o) if (rt_opts->o) default_rt.o = rt_opts->o
#define RT_OPT_COPY_IF_NOT_SET(o) if (!rt_opts->o) default_rt.o = rt_opts->o
    RT_OPT_COPY_IF_SET(gpio_slowdown);
    RT_OPT_COPY_IF_SET(daemon);
    RT_OPT_COPY_IF_NOT_SET(drop_privileges);
    RT_OPT_COPY_IF_NOT_SET(do_gpio_init);
#undef RT_OPT_COPY_IF_SET
#undef RT_OPT_COPY_IF_NOT_SET
  }

Multiple convention breaks are seen. Some signals invert polarity with using disable prefix. Mixing of bool with integer.

greatballoflazers avatar Nov 06 '21 03:11 greatballoflazers