qemuMonitorRemoveFdset: Convert @fdset to unsigned int to avoid error

'qemuMonitorRemoveFdset' validates that the 'fdset' argument isn't less
than 0. We can turn it to unsigned and thus avoid the error message
completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-01-24 15:58:37 +01:00
parent 6e433cc8df
commit b25f2a2192
4 changed files with 8 additions and 14 deletions

View File

@ -2553,24 +2553,18 @@ qemuMonitorAddFileHandleToSet(qemuMonitor *mon,
/** /**
* qemuMonitorRemoveFdset: * qemuMonitorRemoveFdset:
* @mon: monitor object * @mon: monitor object
* @fdset: the fdset to remove * @fdset: id of the fdset to remove
* *
* Attempts to remove a fdset from qemu and close associated file descriptors * Attempts to remove @fdset from qemu and close associated file descriptors
* Returns 0 if ok, and -1 on failure */ * Returns 0 if ok, and -1 on failure */
int int
qemuMonitorRemoveFdset(qemuMonitor *mon, qemuMonitorRemoveFdset(qemuMonitor *mon,
int fdset) unsigned int fdset)
{ {
VIR_DEBUG("fdset=%d", fdset); VIR_DEBUG("fdset=%u", fdset);
QEMU_CHECK_MONITOR(mon); QEMU_CHECK_MONITOR(mon);
if (fdset < 0) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("fdset must be valid"));
return -1;
}
return qemuMonitorJSONRemoveFdset(mon, fdset); return qemuMonitorJSONRemoveFdset(mon, fdset);
} }

View File

@ -974,7 +974,7 @@ qemuMonitorAddFileHandleToSet(qemuMonitor *mon,
int int
qemuMonitorRemoveFdset(qemuMonitor *mon, qemuMonitorRemoveFdset(qemuMonitor *mon,
int fdset); unsigned int fdset);
typedef struct _qemuMonitorFdsetFdInfo qemuMonitorFdsetFdInfo; typedef struct _qemuMonitorFdsetFdInfo qemuMonitorFdsetFdInfo;
struct _qemuMonitorFdsetFdInfo { struct _qemuMonitorFdsetFdInfo {

View File

@ -3766,11 +3766,11 @@ int qemuMonitorJSONQueryFdsets(qemuMonitor *mon,
int qemuMonitorJSONRemoveFdset(qemuMonitor *mon, int qemuMonitorJSONRemoveFdset(qemuMonitor *mon,
int fdset) unsigned int fdset)
{ {
g_autoptr(virJSONValue) reply = NULL; g_autoptr(virJSONValue) reply = NULL;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("remove-fd", g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("remove-fd",
"i:fdset-id", fdset, "u:fdset-id", fdset,
NULL); NULL);
if (!cmd) if (!cmd)

View File

@ -257,7 +257,7 @@ qemuMonitorJSONAddFileHandleToSet(qemuMonitor *mon,
int int
qemuMonitorJSONRemoveFdset(qemuMonitor *mon, qemuMonitorJSONRemoveFdset(qemuMonitor *mon,
int fdset); unsigned int fdset);
int int
qemuMonitorJSONQueryFdsets(qemuMonitor *mon, qemuMonitorJSONQueryFdsets(qemuMonitor *mon,