提交 a80ba808 编写于 作者: D Daniel P. Berrangé

examples: avoid goto jump over initialization of variable

Jumping over the declaration and initialization of a variable is bad as
it means the jump target sees a potentially non-initialized variable.
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 fb0d6049
...@@ -9,6 +9,7 @@ int main(int argc, char **argv) ...@@ -9,6 +9,7 @@ int main(int argc, char **argv)
virAdmServerPtr srv = NULL; /* which server to work with */ virAdmServerPtr srv = NULL; /* which server to work with */
virTypedParameterPtr params = NULL; virTypedParameterPtr params = NULL;
int nparams = 0; int nparams = 0;
int maxparams = 0;
ssize_t i; ssize_t i;
if (argc != 2) { if (argc != 2) {
...@@ -39,7 +40,6 @@ int main(int argc, char **argv) ...@@ -39,7 +40,6 @@ int main(int argc, char **argv)
nparams = 0; nparams = 0;
/* set nclients_max to 100 and nclients_unauth_max to 20 */ /* set nclients_max to 100 and nclients_unauth_max to 20 */
int maxparams = 0;
if (virTypedParamsAddUInt(&params, &nparams, &maxparams, if (virTypedParamsAddUInt(&params, &nparams, &maxparams,
VIR_SERVER_CLIENTS_MAX, 100) < 0 || VIR_SERVER_CLIENTS_MAX, 100) < 0 ||
virTypedParamsAddUInt(&params, &nparams, &maxparams, virTypedParamsAddUInt(&params, &nparams, &maxparams,
......
...@@ -9,6 +9,7 @@ int main(int argc, char **argv) ...@@ -9,6 +9,7 @@ int main(int argc, char **argv)
virAdmServerPtr srv = NULL; /* which server to work with */ virAdmServerPtr srv = NULL; /* which server to work with */
virTypedParameterPtr params = NULL; virTypedParameterPtr params = NULL;
int nparams = 0; int nparams = 0;
int maxparams = 0;
ssize_t i; ssize_t i;
if (argc != 2) { if (argc != 2) {
...@@ -39,7 +40,6 @@ int main(int argc, char **argv) ...@@ -39,7 +40,6 @@ int main(int argc, char **argv)
nparams = 0; nparams = 0;
/* let's set minWorkers to 10, maxWorkers to 15 and prioWorkers to 10 */ /* let's set minWorkers to 10, maxWorkers to 15 and prioWorkers to 10 */
int maxparams = 0;
if (virTypedParamsAddUInt(&params, &nparams, &maxparams, if (virTypedParamsAddUInt(&params, &nparams, &maxparams,
VIR_THREADPOOL_WORKERS_MIN, 10) < 0 || VIR_THREADPOOL_WORKERS_MIN, 10) < 0 ||
virTypedParamsAddUInt(&params, &nparams, &maxparams, virTypedParamsAddUInt(&params, &nparams, &maxparams,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册