]> xenbits.xensource.com Git - libvirt.git/commitdiff
src: Fix boolean assignment
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 5 May 2020 06:05:18 +0000 (08:05 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 5 May 2020 11:08:57 +0000 (13:08 +0200)
In a few places we use 0 and false, or 1 and true interchangeably
even though the variable or return type in question is boolean.
Fix those places.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
14 files changed:
src/conf/nwfilter_conf.c
src/conf/virstorageobj.c
src/lxc/lxc_driver.c
src/nwfilter/nwfilter_dhcpsnoop.c
src/qemu/qemu_agent.c
src/qemu/qemu_monitor.c
src/remote/remote_daemon.c
src/remote/remote_daemon_config.c
src/remote/remote_driver.c
src/rpc/virnetserver.c
src/util/virnetlink.c
src/util/virtime.c
src/util/viruri.c
src/vmx/vmx.c

index 680f4184c348e4ae574f849239e1cb5917f75e7a..732c05ac89b089c8e755a9804c5c7258aee0c5bc 100644 (file)
@@ -1848,7 +1848,7 @@ virNWFilterRuleDetailsParse(xmlNodePtr node,
 
             att_datatypes = att[idx].datatype;
 
-            while (datatype <= DATATYPE_LAST && found == 0 && rc == 0) {
+            while (datatype <= DATATYPE_LAST && !found && rc == 0) {
                 if ((att_datatypes & datatype)) {
 
                     att_datatypes ^= datatype;
@@ -2881,14 +2881,14 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf,
                     matchShown = MATCH_NO;
                 } else if (matchShown == MATCH_YES) {
                     virBufferAddLit(buf, "/>\n");
-                    typeShown = 0;
+                    typeShown = false;
                     matchShown = MATCH_NONE;
                     continue;
                 }
             } else {
                 if (matchShown == MATCH_NO) {
                     virBufferAddLit(buf, "/>\n");
-                    typeShown = 0;
+                    typeShown = false;
                     matchShown = MATCH_NONE;
                     continue;
                 }
index 5cbd30f93c17db201f52ede08405e8a8000f5cd8..13b75b648d24b80d2bc5ba75d978c9c83ab905a1 100644 (file)
@@ -332,7 +332,7 @@ bool
 virStoragePoolObjIsAutostart(virStoragePoolObjPtr obj)
 {
     if (!obj->configFile)
-        return 0;
+        return false;
 
     return obj->autostart;
 }
index 61dd35360a8c04e5cbe675ee29496fb672cc723f..311156256898e048da5d2bfb0378b7c78629a008 100644 (file)
@@ -1512,7 +1512,7 @@ static int lxcStateInitialize(bool privileged,
     if (!(lxc_driver->config = cfg = virLXCDriverConfigNew()))
         goto cleanup;
 
-    cfg->log_libvirtd = 0; /* by default log to container logfile */
+    cfg->log_libvirtd = false; /* by default log to container logfile */
     cfg->have_netns = lxcCheckNetNsSupport();
 
     /* Call function to load lxc driver configuration information */
index 953d8936a49e87799095a7f47544a7d84871b040..f530341872353aecaa390085abcade5f184a88f4 100644 (file)
@@ -326,7 +326,7 @@ virNWFilterSnoopIsActive(char *threadKey)
     void *entry;
 
     if (threadKey == NULL)
-        return 0;
+        return false;
 
     virNWFilterSnoopActiveLock();
 
index d7fcc869c6f2ed0ea9ea4cdcc94aed151cc0279b..6fa48c06e3da4cb3a274b75e4f536d8953c6a08a 100644 (file)
@@ -267,7 +267,7 @@ qemuAgentIOProcessLine(qemuAgentPtr agent,
         /* receiving garbage on first sync is regular situation */
         if (msg && msg->sync && msg->first) {
             VIR_DEBUG("Received garbage on sync");
-            msg->finished = 1;
+            msg->finished = true;
             return 0;
         }
 
@@ -306,7 +306,7 @@ qemuAgentIOProcessLine(qemuAgentPtr agent,
                 }
             }
             msg->rxObject = obj;
-            msg->finished = 1;
+            msg->finished = true;
             obj = NULL;
         } else {
             /* we are out of sync */
@@ -627,7 +627,7 @@ qemuAgentIO(GSocket *socket G_GNUC_UNUSED,
         /* If IO process resulted in an error & we have a message,
          * then wakeup that waiter */
         if (agent->msg && !agent->msg->finished) {
-            agent->msg->finished = 1;
+            agent->msg->finished = true;
             virCondSignal(&agent->notify);
         }
     }
@@ -751,7 +751,7 @@ qemuAgentNotifyCloseLocked(qemuAgentPtr agent)
         /* If there is somebody waiting for a message
          * wake him up. No message will arrive anyway. */
         if (agent->msg && !agent->msg->finished) {
-            agent->msg->finished = 1;
+            agent->msg->finished = true;
             virCondSignal(&agent->notify);
         }
     }
@@ -1209,7 +1209,7 @@ void qemuAgentNotifyEvent(qemuAgentPtr agent,
         agent->await_event = QEMU_AGENT_EVENT_NONE;
         /* somebody waiting for this event, wake him up. */
         if (agent->msg && !agent->msg->finished) {
-            agent->msg->finished = 1;
+            agent->msg->finished = true;
             virCondSignal(&agent->notify);
         }
     }
index a62fed845e57fb7aed17ada0f928c4b259e293b4..339facfad32c05260d4f53354c8ed239ce246351 100644 (file)
@@ -617,7 +617,7 @@ qemuMonitorIO(GSocket *socket G_GNUC_UNUSED,
         /* If IO process resulted in an error & we have a message,
          * then wakeup that waiter */
         if (mon->msg && !mon->msg->finished) {
-            mon->msg->finished = 1;
+            mon->msg->finished = true;
             virCondSignal(&mon->notify);
         }
     }
@@ -880,7 +880,7 @@ qemuMonitorClose(qemuMonitorPtr mon)
             else
                 virResetLastError();
         }
-        mon->msg->finished = 1;
+        mon->msg->finished = true;
         virCondSignal(&mon->notify);
     }
 
index 7eec5991774ff2ccaca8fc0691a9924b2acc1e46..1aa9bfc0d2f61e43a1825caffb98f8151e8a6bb0 100644 (file)
@@ -781,7 +781,7 @@ int main(int argc, char **argv) {
 # endif /* ! LIBVIRTD */
 #endif /* ! WITH_IP */
     struct daemonConfig *config;
-    bool privileged = geteuid() == 0 ? true : false;
+    bool privileged = geteuid() == 0;
     bool implicit_conf = false;
     char *run_dir = NULL;
     mode_t old_umask;
index 0ecc49f179fd50b25d02de330db160dff816431a..a09f287656b0594c73836ec6cd9b5833432d228e 100644 (file)
@@ -99,11 +99,11 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED)
 
 #ifdef WITH_IP
 # ifdef LIBVIRTD
-    data->listen_tls = 1; /* Only honoured if --listen is set */
+    data->listen_tls = true; /* Only honoured if --listen is set */
 # else /* ! LIBVIRTD */
-    data->listen_tls = 0; /* Always honoured, --listen doesn't exist. */
+    data->listen_tls = false; /* Always honoured, --listen doesn't exist. */
 # endif /* ! LIBVIRTD */
-    data->listen_tcp = 0;
+    data->listen_tcp = false;
 
     data->tls_port = g_strdup(LIBVIRTD_TLS_PORT);
     data->tcp_port = g_strdup(LIBVIRTD_TCP_PORT);
@@ -146,7 +146,7 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED)
     data->max_client_requests = 5;
 
     data->audit_level = 1;
-    data->audit_logging = 0;
+    data->audit_logging = false;
 
     data->keepalive_interval = 5;
     data->keepalive_count = 5;
index 7bae0c2514c78dc8c54b157b1218e0865332d58f..0aeab9db279c6b9cd6616491ec9784cf9efe05cd 100644 (file)
@@ -1133,7 +1133,7 @@ doRemoteOpen(virConnectPtr conn,
             goto failed;
 
         priv->tls = virNetTLSContextNewClientPath(pkipath,
-                                                  geteuid() != 0 ? true : false,
+                                                  geteuid() != 0,
                                                   tls_priority,
                                                   sanity, verify);
         if (!priv->tls)
index 07c8b85b76cbef303a558b778c548635231d7356..e0a23867f62edb68cfd03aef92fb93f2498a5e10 100644 (file)
@@ -1231,7 +1231,7 @@ virNetServerUpdateTlsFiles(virNetServerPtr srv)
 {
     int ret = -1;
     virNetTLSContextPtr ctxt = NULL;
-    bool privileged = geteuid() == 0 ? true : false;
+    bool privileged = geteuid() == 0;
 
     ctxt = virNetServerGetTLSContext(srv);
     if (!ctxt) {
index 3117dcbe6536c4fd03c46957183bcba9a5f28fcc..d23ed95b781b074a4964b57b6f7741e0956f711a 100644 (file)
@@ -1340,7 +1340,7 @@ int virNetlinkEventServiceStart(unsigned int protocol G_GNUC_UNUSED,
 bool virNetlinkEventServiceIsRunning(unsigned int protocol G_GNUC_UNUSED)
 {
     virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
-    return 0;
+    return false;
 }
 
 int virNetlinkEventServiceLocalPid(unsigned int protocol G_GNUC_UNUSED)
index bc8f06cd48738642a4eaaf0e094765cf192b226d..88f6f0a551932d34e7744e5c71cb487220ad3931 100644 (file)
@@ -386,7 +386,7 @@ virTimeBackOffWait(virTimeBackOffVar *var)
     VIR_DEBUG("t=%llu, limit=%llu", t, var->limit_t);
 
     if (t > var->limit_t)
-        return 0;               /* ends the while loop */
+        return false;               /* ends the while loop */
 
     /* Compute next wait time. Cap at VIR_TIME_BACKOFF_CAP
      * to avoid long useless sleeps. */
@@ -406,5 +406,5 @@ virTimeBackOffWait(virTimeBackOffVar *var)
     VIR_DEBUG("sleeping for %llu ms", next);
 
     g_usleep(next * 1000);
-    return 1;
+    return true;
 }
index 58d9016a61123473ed43ef4cd196ff09e9deb24d..5fa0a6f0c853c34527c0ab0bb9ccd8ad8206eb35 100644 (file)
@@ -48,7 +48,7 @@ virURIParamAppend(virURIPtr uri,
 
     uri->params[uri->paramsCount].name = pname;
     uri->params[uri->paramsCount].value = pvalue;
-    uri->params[uri->paramsCount].ignore = 0;
+    uri->params[uri->paramsCount].ignore = false;
     uri->paramsCount++;
 
     return 0;
index b1fd1181eb8970dc82c4ef236e176702056748b6..f2248cef53a1c1a05d3de18b240743c1dc71b4b2 100644 (file)
@@ -840,9 +840,9 @@ virVMXGetConfigBoolean(virConfPtr conf, const char *name, bool *boolean_,
         return rc;
 
     if (STRCASEEQ(string, "true")) {
-        *boolean_ = 1;
+        *boolean_ = true;
     } else if (STRCASEEQ(string, "false")) {
-        *boolean_ = 0;
+        *boolean_ = false;
     } else {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Config entry '%s' must represent a boolean value "