[Drbd-dev] Confused by drbd_cmd structure definition in
drbdsetup.c...
Graham, Simon
Simon.Graham at stratus.com
Fri Sep 1 19:52:13 CEST 2006
I've been noticing some crashes in drbdsetup when it is printing out the
list of commands and I find myself confused by the new drbd_cmd struct -
embedded in this, you have a union of a cp and a gp struct BUT the code
that prints command usage always just uses the cp element of the union -
I think this leads to segfaults because of this in
print_command_usage():
if ((args = commands[i].cp.args)) {
while (args->name) {
col += snprintf(line+col, maxcol-col, " %s",
args->name);
args++;
}
}
Some elements (such as the "state" command entry) use the gp element of
the command to hold a function pointer which means that cp.args.name is
non-NULL and we try to dereference the function pointer as an argument
definition (and also attempt to move on to further argument definitions
which don't exist).
I'm a bit confused as to why this is defined as a union - is the fix to
remove the union wrapper?
Simon
More information about the drbd-dev
mailing list