[libvirt] [PATCH] admin: Add a check to reject negative argument for number of typed params

Since nparams can be technically negative, it is a good practice throughout our code to check if nparams actually has a non-negative value. The same effect would be achieved by converting our internal typed params serializer argument to 'unsigned' type, but it definitely would not be the path of least resistance. Signed-off-by: Erik Skultety <eskultet@redhat.com> --- src/libvirt-admin.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c index a94f5dd..4ad816b 100644 --- a/src/libvirt-admin.c +++ b/src/libvirt-admin.c @@ -838,6 +838,7 @@ virAdmServerSetThreadPoolParameters(virAdmServerPtr srv, virCheckAdmServerReturn(srv, -1); virCheckNonNullArgGoto(params, error); + virCheckNonNegativeArgGoto(nparams, error); if (remoteAdminServerSetThreadPoolParameters(srv, params, nparams, flags) < 0) -- 2.4.11

On 03.05.2016 17:04, Erik Skultety wrote:
Since nparams can be technically negative, it is a good practice throughout our code to check if nparams actually has a non-negative value. The same effect would be achieved by converting our internal typed params serializer argument to 'unsigned' type, but it definitely would not be the path of least resistance.
Signed-off-by: Erik Skultety <eskultet@redhat.com> --- src/libvirt-admin.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c index a94f5dd..4ad816b 100644 --- a/src/libvirt-admin.c +++ b/src/libvirt-admin.c @@ -838,6 +838,7 @@ virAdmServerSetThreadPoolParameters(virAdmServerPtr srv,
virCheckAdmServerReturn(srv, -1); virCheckNonNullArgGoto(params, error); + virCheckNonNegativeArgGoto(nparams, error);
if (remoteAdminServerSetThreadPoolParameters(srv, params, nparams, flags) < 0)
ACK Michal

On 04/05/16 15:19, Michal Privoznik wrote:
On 03.05.2016 17:04, Erik Skultety wrote:
Since nparams can be technically negative, it is a good practice throughout our code to check if nparams actually has a non-negative value. The same effect would be achieved by converting our internal typed params serializer argument to 'unsigned' type, but it definitely would not be the path of least resistance.
Signed-off-by: Erik Skultety <eskultet@redhat.com> --- src/libvirt-admin.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c index a94f5dd..4ad816b 100644 --- a/src/libvirt-admin.c +++ b/src/libvirt-admin.c @@ -838,6 +838,7 @@ virAdmServerSetThreadPoolParameters(virAdmServerPtr srv,
virCheckAdmServerReturn(srv, -1); virCheckNonNullArgGoto(params, error); + virCheckNonNegativeArgGoto(nparams, error);
if (remoteAdminServerSetThreadPoolParameters(srv, params, nparams, flags) < 0)
ACK
Michal
Pushed, thank you. Erik
participants (2)
-
Erik Skultety
-
Michal Privoznik