[systemd-devel] [PATCH 1/2] When warning about unsupported options, be more detailed

Lennart Poettering lennart at poettering.net
Sun Nov 30 13:51:13 PST 2014


On Sun, 30.11.14 16:55, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:

> ---
> I think this would be useful. Comments?

Wouldn't that better be encoded in the "ltype" parameter, rather than
the data parameter?

Generally like the idea, but "abesence reason" sounds a bit doggerel?

          DISABLED_BUILD_TIME
          DISABLED_EXPERIMENTAL

Or so?

>                  const char *rvalue,
>                  void *data,
>                  void *userdata) {
> +        AbsenceReason reason = PTR_TO_INT(userdata);
> +
> +        switch(reason) {
> +        case ABSENCE_REASON_CONFIG:
> +                log_syntax(unit, LOG_DEBUG, filename, line, EINVAL,
> +                           "Support for option %s= has been disabled at compile time and it is ignored", lvalue);
> +                break;
> +        case ABSENCE_REASON_EXPERIMENTAL:
> +                log_syntax(unit, LOG_INFO, filename, line, EINVAL,
> +                           "Support for option %s= has not yet been enabled and it is ignored", lvalue);
> +                break;
> +        };
>  
> -        log_syntax(unit, LOG_DEBUG, filename, line, EINVAL,
> -                   "Support for option %s= has been disabled at compile time and is ignored",
> -                   lvalue);
>          return 0;
>  }
>  #endif

Mabye use a string array here, indexed by the ltype? 

static const msgs[_DISABLE_MAX] = {
       [DISABLED_BUILD_TIME] = "...",
       [DISABLED_EXPERIMENTAL] = "...",
};

assert_se(ltype < _DISABLED_MAX];
.... msgs[ltype] ...

You get the idea...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list