[augeas-devel] [PATCH] Fix enable span not working

Raphaël Pinson raphink at gmail.com
Thu Oct 6 12:57:45 UTC 2011


On Thu, Oct 6, 2011 at 2:52 PM, Francis Giraldeau <
francis.giraldeau at gmail.com> wrote:

> Span information was collected when the option is set, but the command
> would
> fail. The test to determine if span is enable was not working properly. It
> was
> testing against a NULL string. Instead, use the option flag from the aug
> tree,
> since this value really reflects the state of span information in the tree
> after an effective load.
>
>

You beat me to it Francis, I'm just finishing my own patch to fix it.
However, I do not agree with the patch, see below.



> Fix ticket #220
> ---
>  src/augrun.c |    8 +-------
>  1 files changed, 1 insertions(+), 7 deletions(-)
>
> diff --git a/src/augrun.c b/src/augrun.c
> index 636b6fe..f4a4e03 100644
> --- a/src/augrun.c
> +++ b/src/augrun.c
> @@ -619,19 +619,13 @@ static void cmd_span(struct command *cmd) {
>     int r;
>     uint label_start, label_end, value_start, value_end, span_start,
> span_end;
>     char *filename = NULL;
> -    const char *option = NULL;
>
> -    if (! streqv(AUG_DISABLE, option)) {
> +    if (!(cmd->aug->flags & AUG_ENABLE_SPAN)) {
>


This will only work if AUG_ENABLE_SPAN was passed as a flag. However, users
can set /augeas/span manually, and it won't work here. Instead, we should
use the way it was done in 0.8.0:

    if (aug_get(cmd->aug, AUGEAS_SPAN_OPTION, &option) != 1) {
        printf("Error: option " AUGEAS_SPAN_OPTION " not found\n");
        return;
    }




>         ERR_REPORT(cmd, AUG_ECMDRUN,
>                    "Span is not enabled. To enable, run the commands:\n"
>                    "    set %s %s\n    rm %s\n    load\n",
>                    AUGEAS_SPAN_OPTION, AUG_ENABLE, AUGEAS_FILES_TREE);
>         return;
> -    } else if (streqv(AUG_ENABLE, option)) {
> -        ERR_REPORT(cmd, AUG_ECMDRUN,
> -                   "option %s must be %s or %s\n", AUGEAS_SPAN_OPTION,
> -                   AUG_ENABLE, AUG_DISABLE);
> -        return;
>


This check is still useful, it just has to be reversed.
I'll send my patch along in a minute.


Raphaël
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20111006/b2cf4af6/attachment.htm>


More information about the augeas-devel mailing list