提交 694323bb 编写于 作者: P Peter Krempa

remote: dispatch: Remove return value from make_nonnull_* helpers

After conversion to g_strdup, the helpers now always return success.
Remove the return value to simplify the callers.

Note that many occurrences of these is in the code generated by
gendispatch.pl. Since gendispatch aggregates many cases together an
incremental conversion would require more invasive changes to
gendispatch for the time of conversion which doesn't make sense.

Also in many cases the helper was the last place where the 'error:'
label was used and thus also those conversions must be included in this
patch.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
ACKed-by: NEric Blake <eblake@redhat.com>
上级 509c6e51
......@@ -135,12 +135,11 @@ get_nonnull_server(virNetDaemonPtr dmn, admin_nonnull_server srv)
return virNetDaemonGetServer(dmn, srv.name);
}
static int G_GNUC_WARN_UNUSED_RESULT
static void
make_nonnull_server(admin_nonnull_server *srv_dst,
virNetServerPtr srv_src)
{
srv_dst->name = g_strdup(virNetServerGetName(srv_src));
return 0;
}
static virNetServerClientPtr
......@@ -149,14 +148,13 @@ get_nonnull_client(virNetServerPtr srv, admin_nonnull_client clnt)
return virNetServerGetClient(srv, clnt.id);
}
static int
static void
make_nonnull_client(admin_nonnull_client *clt_dst,
virNetServerClientPtr clt_src)
{
clt_dst->id = virNetServerClientGetID(clt_src);
clt_dst->timestamp = virNetServerClientGetTimestamp(clt_src);
clt_dst->transport = virNetServerClientGetTransport(clt_src);
return 0;
}
/* Functions */
......
此差异已折叠。
......@@ -805,12 +805,12 @@ elsif ($mode eq "server") {
if ($call->{ProcName} eq "DomainCreateWithFlags") {
# SPECIAL: virDomainCreateWithFlags updates the given
# domain object instead of returning a new one
push(@ret_list, "if (make_nonnull_$1(&ret->$2, $2) < 0)\n goto cleanup;\n");
push(@ret_list, "make_nonnull_$1(&ret->$2, $2);\n");
$single_ret_var = undef;
$single_ret_by_ref = 1;
} else {
push(@vars_list, "vir${type_name}Ptr $2 = NULL");
push(@ret_list, "if (make_nonnull_$1(&ret->$2, $2) < 0)\n goto cleanup;\n");
push(@ret_list, "make_nonnull_$1(&ret->$2, $2);\n");
push(@free_list,
" virObjectUnref($2);");
$single_ret_var = $2;
......@@ -926,11 +926,11 @@ elsif ($mode eq "server") {
if ($1 eq "client") {
push(@vars_list, "virNetServer${type_name}Ptr $2 = NULL");
push(@ret_list, "if (make_nonnull_$1(&ret->$2, $2) < 0)\n goto cleanup;\n");
push(@ret_list, "if (make_nonnull_server(&ret->$2.srv, srv) < 0)\n goto cleanup;\n");
push(@ret_list, "make_nonnull_$1(&ret->$2, $2);\n");
push(@ret_list, "make_nonnull_server(&ret->$2.srv, srv);\n");
} else {
push(@vars_list, "virNet${type_name}Ptr $2 = NULL");
push(@ret_list, "if (make_nonnull_$1(&ret->$2, $2) < 0)\n goto cleanup;\n");
push(@ret_list, "make_nonnull_$1(&ret->$2, $2);");
}
push(@free_list,
......@@ -1187,15 +1187,12 @@ elsif ($mode eq "server") {
print " ret->$single_ret_list_name.${single_ret_list_name}_len = nresults;\n";
if ($modern_ret_is_nested) {
print " for (i = 0; i < nresults; i++) {\n";
print " if (make_nonnull_$modern_ret_struct_name(ret->$single_ret_list_name.${single_ret_list_name}_val + i, result[i]) < 0)\n";
print " goto cleanup;\n";
print " if (make_nonnull_$modern_ret_nested_struct_name(&ret->$single_ret_list_name.${single_ret_list_name}_val[i].srv, srv) < 0)\n";
print " goto cleanup;\n";
print " make_nonnull_$modern_ret_struct_name(ret->$single_ret_list_name.${single_ret_list_name}_val + i, result[i]);\n";
print " make_nonnull_$modern_ret_nested_struct_name(&ret->$single_ret_list_name.${single_ret_list_name}_val[i].srv, srv);\n";
print " }\n";
} else {
print " for (i = 0; i < nresults; i++)\n";
print " if (make_nonnull_$modern_ret_struct_name(ret->$single_ret_list_name.${single_ret_list_name}_val + i, result[i]) < 0)\n";
print " goto cleanup;\n";
print " make_nonnull_$modern_ret_struct_name(ret->$single_ret_list_name.${single_ret_list_name}_val + i, result[i]);\n";
}
print " } else {\n";
print " ret->$single_ret_list_name.${single_ret_list_name}_len = 0;\n";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册