isl_ctx.c: find_nested_options: properly handle argument "groups"
authorSven Verdoolaege <skimo@kotnet.org>
Thu, 1 Aug 2013 11:22:16 +0000 (1 13:22 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 5 Aug 2013 15:46:16 +0000 (5 17:46 +0200)
An argument group is encoded as a child with an offset of -1 and
we are obviously not allowed to use this -1 as an offset.
Instead, the structure holding the child options is the same as
that of the parent.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ctx.c

index 7720be4..5e8e38a 100644 (file)
--- a/isl_ctx.c
+++ b/isl_ctx.c
@@ -45,11 +45,19 @@ static struct isl_options *find_nested_options(struct isl_args *args,
                return opt;
 
        for (i = 0; args->args[i].type != isl_arg_end; ++i) {
-               if (args->args[i].type != isl_arg_child)
+               struct isl_arg *arg = &args->args[i];
+               void *child;
+
+               if (arg->type != isl_arg_child)
                        continue;
-               options = find_nested_options(args->args[i].u.child.child,
-                           *(void **)(((char *)opt) + args->args[i].offset),
-                           wanted);
+
+               if (arg->offset == (size_t) -1)
+                       child = opt;
+               else
+                       child = *(void **)(((char *)opt) + arg->offset);
+
+               options = find_nested_options(arg->u.child.child,
+                                               child, wanted);
                if (options)
                        return options;
        }