In wpa_supplicant/wpa_cli.c, wpa_cli_open_connection is expected to
set errno (at least in case of error), as it is used in
if (!global &&
wpa_cli_open_connection(ctrl_ifname, 0) < 0) {
fprintf(stderr, "Failed to connect to non-global "
"ctrl_ifname: %s error: %s\n",
ctrl_ifname ? ctrl_ifname : "(nil)",
strerror(errno));
return -1;
}
Thus wpa_cli_open_connection should start by setting errno to 0,
to make sure that one does not get an error message that comes
from a previous, unrelated error. Currently this is what would
happen when ifname == NULL.