[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] virsh: nuke use of TRUE and FALSE



2011/4/19 Eric Blake <eblake redhat com>:
> Gnulib already guarantees <stdbool.h>, so it is easier to just
> use the standardized spellings.
>
> * tools/virsh.c (vshCmdDef): Change callback to return real bool.
> (__vshControl): Change several fields to bool.
> (vshCommandOptBool): Change return type.
> All callers updated.
> * tools/Makefile.am (virsh-net-edit.c, virsh-pool-edit.c):
> Likewise.
> ---
>
> Mostly mechanical.
>
>  tools/Makefile.am |    4 +-
>  tools/virsh.c     | 1674 ++++++++++++++++++++++++++---------------------------
>  2 files changed, 835 insertions(+), 843 deletions(-)
>

Looks good in general, but you missed some places for s/int/bool/.
Instead of pointing them out in the diff, here's a patch to be merged
into yours.

ACK with the attached patch merged in.

Matthias
diff --git a/tools/virsh.c b/tools/virsh.c
index 21560d8..9ac27b3 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -235,21 +235,21 @@ static const vshCmdGrp cmdGroups[];
 
 static void vshError(vshControl *ctl, const char *format, ...)
     ATTRIBUTE_FMT_PRINTF(2, 3);
-static int vshInit(vshControl *ctl);
-static int vshDeinit(vshControl *ctl);
+static bool vshInit(vshControl *ctl);
+static bool vshDeinit(vshControl *ctl);
 static void vshUsage(void);
 static void vshOpenLogFile(vshControl *ctl);
 static void vshOutputLogFile(vshControl *ctl, int log_level, const char *format, va_list ap)
     ATTRIBUTE_FMT_PRINTF(3, 0);
 static void vshCloseLogFile(vshControl *ctl);
 
-static int vshParseArgv(vshControl *ctl, int argc, char **argv);
+static bool vshParseArgv(vshControl *ctl, int argc, char **argv);
 
 static const char *vshCmddefGetInfo(const vshCmdDef *cmd, const char *info);
 static const vshCmdDef *vshCmddefSearch(const char *cmdname);
-static int vshCmddefHelp(vshControl *ctl, const char *name);
+static bool vshCmddefHelp(vshControl *ctl, const char *name);
 static const vshCmdGrp *vshCmdGrpSearch(const char *grpname);
-static int vshCmdGrpHelp(vshControl *ctl, const char *name);
+static bool vshCmdGrpHelp(vshControl *ctl, const char *name);
 
 static vshCmdOpt *vshCommandOpt(const vshCmd *cmd, const char *name);
 static int vshCommandOptInt(const vshCmd *cmd, const char *name, int *value)
@@ -336,7 +336,7 @@ static void vshDebug(vshControl *ctl, int level, const char *format, ...)
 
 static const char *vshDomainStateToString(int state);
 static const char *vshDomainVcpuStateToString(int state);
-static int vshConnectionUsability(vshControl *ctl, virConnectPtr conn);
+static bool vshConnectionUsability(vshControl *ctl, virConnectPtr conn);
 
 static char *editWriteToTempFile (vshControl *ctl, const char *doc);
 static int   editFile (vshControl *ctl, const char *filename);
@@ -8048,7 +8048,8 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
     size_t value_size;
     const char *base64 = NULL;
     char *value;
-    int res, ret = false;
+    int res;
+    bool ret = false;
 
     if (!vshConnectionUsability(ctl, ctl->conn))
         return false;
@@ -9108,7 +9109,8 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
     virDomainPtr dom = NULL;
     const char *mac = NULL, *target = NULL, *script = NULL,
                 *type = NULL, *source = NULL, *model = NULL;
-    int typ, ret = false;
+    int typ;
+    bool ret = false;
     unsigned int flags;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     char *xml;
@@ -9223,7 +9225,8 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
     const char *mac =NULL, *type = NULL;
     char *doc;
     char buf[64];
-    int i = 0, diff_mac, ret = false;
+    int i = 0, diff_mac;
+    bool ret = false;
     unsigned int flags;
 
     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -9365,7 +9368,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
     virDomainPtr dom = NULL;
     const char *source = NULL, *target = NULL, *driver = NULL,
                 *subdriver = NULL, *type = NULL, *mode = NULL;
-    int isFile = 0, ret = false;
+    bool isFile = false, ret = false;
     unsigned int flags;
     const char *stype = NULL;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -9394,9 +9397,9 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
 
     if (!stype) {
         if (driver && (STREQ(driver, "file") || STREQ(driver, "tap")))
-            isFile = 1;
+            isFile = true;
     } else if (STREQ(stype, "file")) {
-        isFile = 1;
+        isFile = true;
     } else if (STRNEQ(stype, "block")) {
         vshError(ctl, _("Unknown source type: '%s'"), stype);
         goto cleanup;
@@ -9497,7 +9500,8 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
     virDomainPtr dom = NULL;
     const char *target = NULL;
     char *doc;
-    int i = 0, diff_tgt, ret = false;
+    int i = 0, diff_tgt;
+    bool ret = false;
     unsigned int flags;
 
     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -9946,7 +9950,7 @@ cmdPwd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
 {
     char *cwd;
     size_t path_max;
-    int err = true;
+    bool err = true;
 
     path_max = (size_t) PATH_MAX + 2;
     cwd = vshMalloc (ctl, path_max);
@@ -11055,7 +11059,7 @@ vshCmdGrpSearch(const char *grpname)
     return NULL;
 }
 
-static int
+static bool
 vshCmdGrpHelp(vshControl *ctl, const char *grpname)
 {
     const vshCmdGrp *grp = vshCmdGrpSearch(grpname);
@@ -11077,7 +11081,7 @@ vshCmdGrpHelp(vshControl *ctl, const char *grpname)
     return true;
 }
 
-static int
+static bool
 vshCmddefHelp(vshControl *ctl, const char *cmdname)
 {
     const vshCmdDef *def = vshCmddefSearch(cmdname);
@@ -11687,7 +11691,7 @@ vshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, const char **name)
 /*
  * Executes command(s) and returns return code from last command
  */
-static int
+static bool
 vshCommandRun(vshControl *ctl, const vshCmd *cmd)
 {
     bool ret = true;
@@ -11756,7 +11760,7 @@ typedef struct __vshCommandParser {
     char **arg_end;
 } vshCommandParser;
 
-static int
+static bool
 vshCommandParse(vshControl *ctl, vshCommandParser *parser)
 {
     char *tkdata = NULL;
@@ -11938,7 +11942,8 @@ vshCommandArgvGetArg(vshControl *ctl, vshCommandParser *parser, char **res)
     return VSH_TK_ARG;
 }
 
-static int vshCommandArgvParse(vshControl *ctl, int nargs, char **argv)
+static bool
+vshCommandArgvParse(vshControl *ctl, int nargs, char **argv)
 {
     vshCommandParser parser;
 
@@ -12016,7 +12021,8 @@ vshCommandStringGetArg(vshControl *ctl, vshCommandParser *parser, char **res)
     return VSH_TK_ARG;
 }
 
-static int vshCommandStringParse(vshControl *ctl, char *cmdstr)
+static bool
+vshCommandStringParse(vshControl *ctl, char *cmdstr)
 {
     vshCommandParser parser;
 
@@ -12070,7 +12076,7 @@ vshDomainVcpuStateToString(int state)
     return N_("no state");
 }
 
-static int
+static bool
 vshConnectionUsability(vshControl *ctl, virConnectPtr conn)
 {
     /* TODO: use something like virConnectionState() to
@@ -12148,7 +12154,7 @@ vshError(vshControl *ctl, const char *format, ...)
 /*
  * Initialize connection.
  */
-static int
+static bool
 vshInit(vshControl *ctl)
 {
     if (ctl->conn)
@@ -12535,7 +12541,7 @@ vshReadline (vshControl *ctl, const char *prompt)
 /*
  * Deinitialize virsh
  */
-static int
+static bool
 vshDeinit(vshControl *ctl)
 {
     vshReadlineDeinit(ctl);
@@ -12719,7 +12725,7 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
  * argv[]:  virsh [options] [command]
  *
  */
-static int
+static bool
 vshParseArgv(vshControl *ctl, int argc, char **argv)
 {
     bool help = false;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]