]> xenbits.xensource.com Git - libvirt.git/commitdiff
Remove more useless if tests before "free"-like functions.
authorJim Meyering <meyering@redhat.com>
Thu, 7 Feb 2008 16:49:29 +0000 (16:49 +0000)
committerJim Meyering <meyering@redhat.com>
Thu, 7 Feb 2008 16:49:29 +0000 (16:49 +0000)
* build-aux/useless-if-before-free: Rename from ...
* build-aux/find-unnecessary-if-before-free: ... this.  Remove file.
Also changed it so that new names are no longer hard-coded in the
script.  Instead, they're supplied via options:
* Makefile.cfg (useless_free_options): Define.
Add xmlXPathFreeObject to the list of free-like functions it detects.
* Makefile.maint (sc_avoid_if_before_free): Reflect script renaming.
* .x-sc_avoid_if_before_free: Likewise.
* src/openvz_conf.c (openvzParseXML): Remove useless "if"-before-free.
* src/qemu_conf.c (qemudParseXML, qemudParseNetworkXML): Likewise.
* src/virsh.c (cmdVNCDisplay, cmdTTYConsole, cmdDetachInterface):
(cmdDetachDisk): Likewise.
* src/xm_internal.c (xenXMConfigSetIntFromXPath): Likewise.
(xenXMConfigSetStringFromXPath, xenXMParseXMLToConfig): Likewise.
(xenXMDomainAttachDevice, xenXMAttachDisk, xenXMAttachInterface):
(xenXMDomainDetachDevice): Likewise.
* src/xml.c (virXPathString): Likewise.
* tests/xmlrpctest.c (checkRequestValue): Likewise.

12 files changed:
.x-sc_avoid_if_before_free
ChangeLog
Makefile.cfg
Makefile.maint
build-aux/find-unnecessary-if-before-free [deleted file]
build-aux/useless-if-before-free [new file with mode: 0755]
src/openvz_conf.c
src/qemu_conf.c
src/virsh.c
src/xm_internal.c
src/xml.c
tests/xmlrpctest.c

index f83ae7b225f77b4d257e8ad079f04826e133bd52..5093ef61e0d4e9af0ce5ab116d9e35fb8631a9fc 100644 (file)
@@ -1,5 +1,5 @@
 ^gnulib/lib/getaddrinfo\.c$
 ^gnulib/lib/printf-parse\.c$
 ^gnulib/lib/vasnprintf\.c$
-^build-aux/find-unnecessary-if-before-free$
+^build-aux/useless-if-before-free$
 ^ChangeLog$
index 7570114da62004ffea243f4861bf975c5adb59ab..1bbc0ccaa8d27b6efe2e985b8d3ee98b688eacbd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,24 @@
-2008-02-07  Jim Meyering  <meyering@redhat.com>
+Thu Feb  7 17:48:30 CET 2008 Jim Meyering  <meyering@redhat.com>
+
+       Remove more useless if tests before "free"-like functions.
+       * build-aux/useless-if-before-free: Rename from ...
+       * build-aux/find-unnecessary-if-before-free: ... this.  Remove file.
+       Also changed it so that new names are no longer hard-coded in the
+       script.  Instead, they're supplied via options:
+       * Makefile.cfg (useless_free_options): Define.
+       Add xmlXPathFreeObject to the list of free-like functions it detects.
+       * Makefile.maint (sc_avoid_if_before_free): Reflect script renaming.
+       * .x-sc_avoid_if_before_free: Likewise.
+       * src/openvz_conf.c (openvzParseXML): Remove useless "if"-before-free.
+       * src/qemu_conf.c (qemudParseXML, qemudParseNetworkXML): Likewise.
+       * src/virsh.c (cmdVNCDisplay, cmdTTYConsole, cmdDetachInterface):
+       (cmdDetachDisk): Likewise.
+       * src/xm_internal.c (xenXMConfigSetIntFromXPath): Likewise.
+       (xenXMConfigSetStringFromXPath, xenXMParseXMLToConfig): Likewise.
+       (xenXMDomainAttachDevice, xenXMAttachDisk, xenXMAttachInterface):
+       (xenXMDomainDetachDevice): Likewise.
+       * src/xml.c (virXPathString): Likewise.
+       * tests/xmlrpctest.c (checkRequestValue): Likewise.
 
        * src/xm_internal.c: Remove trailing blanks
        * NEWS, ChangeLog: Likewise.
index a9578abe9d71ecd3b9611e336d2029d699736150..4543ebd8556089b499d4889eb83ebf09e58c873d 100644 (file)
@@ -52,3 +52,8 @@ local-checks-to-skip =                        \
   patch-check                          \
   check-AUTHORS                                \
   changelog-check
+
+useless_free_options =         \
+  --name=sexpr_free            \
+  --name=xmlXPathFreeContext   \
+  --name=xmlXPathFreeObject
index 923c422d64cbb99f60f9ab143227eb49bea63c68..9d41bd20689af0ae93f2229896345af86c26f29e 100644 (file)
@@ -40,7 +40,8 @@ syntax-check: $(local-check)
 ## --------------- ##
 
 sc_avoid_if_before_free:
-       @$(srcdir)/build-aux/find-unnecessary-if-before-free            \
+       @$(srcdir)/build-aux/useless-if-before-free                     \
+               $(useless_free_options)                                 \
            $$($(CVS_LIST_EXCEPT)) &&                                   \
          { echo '$(ME): found useless "if" before "free" above' 1>&2;  \
            exit 1; } || :
diff --git a/build-aux/find-unnecessary-if-before-free b/build-aux/find-unnecessary-if-before-free
deleted file mode 100755 (executable)
index 0cd38eb..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/perl
-# Detect instances of "if (p) free (p);".
-# Likewise for "if (p != NULL) free (p);".
-# Exit status is like grep: 0 for no match. 1 for any number.
-
-# Note: giving line numbers isn't practical, since I've reset the
-# input record separator.
-use strict;
-use warnings;
-(my $ME = $0) =~ s|.*/||;
-
-{
-  # Use ';' as the input record separator.
-  $/ = ';';
-
-  my $found_match = 0;
-  foreach my $file (@ARGV)
-    {
-      open FH, '<', $file
-       or die "$ME: can't open `$file' for reading: $!\n";
-      while (defined (my $line = <FH>))
-       {
-         if ($line =~
-             /\b(if\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)
-              \s+(?:xmlXPathFreeContext|(?:sexpr_)?free)\s*\(\s*\2\s*\))/sx)
-           {
-             print "$file: $1\n";
-             $found_match = 1;
-           }
-       }
-      close FH;
-    }
-  exit !$found_match;
-}
-
-my $foo = <<'EOF';
-# The above is to *find* them.
-# This adjusts them, removing the unnecessary "if (p)" part.
-
-git ls-files -z --exclude=find-unnecessary-if-before-free |xargs -0 \
-perl -0x3b -pi -e 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)\s+((?:xmlXPathFreeContext|(?:sexpr_)?free)\s*\(\s*\1\s*\))/$2/s'
-EOF
diff --git a/build-aux/useless-if-before-free b/build-aux/useless-if-before-free
new file mode 100755 (executable)
index 0000000..57040a3
--- /dev/null
@@ -0,0 +1,118 @@
+#!/usr/bin/perl -T
+# Detect instances of "if (p) free (p);".
+# Likewise for "if (p != NULL) free (p);".
+
+my $VERSION = '2008-02-04 22:25'; # UTC
+# The definition above must lie within the first 8 lines in order
+# for the Emacs time-stamp write hook (at end) to update it.
+# If you change this file with Emacs, please let the write hook
+# do its job.  Otherwise, update this string manually.
+
+# Exit status is like grep: 0 for no match. 1 for any number.
+# Note: giving line numbers isn't practical, since I've reset the
+# input record separator.
+use strict;
+use warnings;
+use Getopt::Long;
+
+(my $ME = $0) =~ s|.*/||;
+
+my $debug = 0;
+my $verbose = 0;
+
+sub usage ($)
+{
+  my ($exit_code) = @_;
+  my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
+  if ($exit_code != 0)
+    {
+      print $STREAM "Try `$ME --help' for more information.\n";
+    }
+  else
+    {
+      print $STREAM <<EOF;
+Usage: $ME [OPTIONS] FILE...
+
+OPTIONS:
+
+   --name=N     add name N to the list of `free'-like functions to detect;
+                  may be repeated
+
+   --help       display this help and exit
+   --version    output version information and exit
+   --verbose    generate verbose output
+
+EXAMPLE:
+
+    git ls-files -z |xargs -0 $ME
+
+EOF
+    }
+  exit $exit_code;
+}
+
+{
+  my @name = qw(free);
+  GetOptions
+    (
+     debug => \$debug,
+     verbose => \$verbose,
+     help => sub { usage 0 },
+     version => sub { print "$ME version $VERSION\n"; exit },
+     'name=s@' => \@name,
+    ) or usage 1;
+
+  # Make sure we have the right number of non-option arguments.
+  # Always tell the user why we fail.
+  @ARGV < 1
+    and (warn "$ME: missing FILE argument\n"), usage 1;
+
+  my $or = join '|', @name;
+  my $regexp = qr/(?:$or)/;
+
+  # Set the input record separator.
+  $/ = '"';
+
+  my $found_match = 0;
+  foreach my $file (@ARGV)
+    {
+      open FH, '<', $file
+        or die "$ME: can't open `$file' for reading: $!\n";
+      while (defined (my $line = <FH>))
+        {
+          if ($line =~
+              /\b(if\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)
+               (?:   \s*$regexp\s*\(\s*\2\s*\)|
+                \s*\{\s*$regexp\s*\(\s*\2\s*\)\s*;\s*\}))/sx)
+            {
+              print "$file: $1\n";
+              $found_match = 1;
+            }
+        }
+      close FH;
+    }
+  exit !$found_match;
+}
+
+my $foo = <<'EOF';
+# The above is to *find* them.
+# This adjusts them, removing the unnecessary "if (p)" part.
+
+# FIXME: do something like this as an option.
+git ls-files -z --exclude=$ME |xargs -0 \
+perl -0x3b -pi -e 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)\s+((?:sexpr_)?free\s*\(\s*\1\s*\))/$2/s'
+
+When modifying files, refuse to process anything other than a regular file.
+
+# Or this one-liner to detect them:
+git ls-files -z |xargs -0 perl -00 -ne '/\b(if\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)(?:\s*(?:sexpr_)?free\s*\(\s*\2\s*\)|\s*\{\s*(?:sexpr_)?free\s*\(\s*\2\s*\)\s*;\s*\}))/sx and print "$1\n"'
+EOF
+
+## Local Variables:
+## indent-tabs-mode: nil
+## eval: (add-hook 'write-file-hooks 'time-stamp)
+## time-stamp-start: "my $VERSION = '"
+## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
+## time-stamp-time-zone: "UTC"
+## time-stamp-end: "'; # UTC"
+## End:
index ebed9b21255e49bf231bbfc112176b977f6d21c1..482de823a1e901e7e5b52adbe4442ae5e439e6f2 100644 (file)
@@ -495,8 +495,7 @@ static struct openvz_vm_def
 
  bail_out:
     free(prop);
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
     xmlXPathFreeContext(ctxt);
     openvzFreeVMDef(def);
 
index 39cfdc1ebc19f271a9c88b6903bc1212d6eb3bca..aba889041d273326ea3f432358e80ae182903caa 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * config.c: VM configuration management
  *
- * Copyright (C) 2006, 2007 Red Hat, Inc.
+ * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -1004,8 +1004,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
             goto error;
         }
     }
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
 
     /* Extract domain memory */
@@ -1023,8 +1022,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
             goto error;
         }
     }
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
     /* Extract domain vcpu info */
     obj = xmlXPathEval(BAD_CAST "string(/domain/vcpu[1])", ctxt);
@@ -1039,8 +1037,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
             goto error;
         }
     }
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
     /* See if ACPI feature is requested */
     obj = xmlXPathEval(BAD_CAST "/domain/features/acpi", ctxt);
@@ -1062,8 +1059,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
         else
             def->noReboot = 0;
     }
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
     /* See if we set clock to localtime */
     obj = xmlXPathEval(BAD_CAST "string(/domain/clock/@offset)", ctxt);
@@ -1076,8 +1072,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
         else
             def->localtime = 0;
     }
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
 
     /* Extract OS type info */
@@ -1111,8 +1106,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
         }
         strcpy(def->os.arch, (const char *)obj->stringval);
     }
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
     obj = xmlXPathEval(BAD_CAST "string(/domain/os/type[1]/@machine)", ctxt);
     if ((obj == NULL) || (obj->type != XPATH_STRING) ||
@@ -1134,8 +1128,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
         }
         strcpy(def->os.machine, (const char *)obj->stringval);
     }
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
 
     obj = xmlXPathEval(BAD_CAST "string(/domain/os/kernel[1])", ctxt);
@@ -1147,8 +1140,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
         }
         strcpy(def->os.kernel, (const char *)obj->stringval);
     }
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
 
     obj = xmlXPathEval(BAD_CAST "string(/domain/os/initrd[1])", ctxt);
@@ -1160,8 +1152,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
         }
         strcpy(def->os.initrd, (const char *)obj->stringval);
     }
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
 
     obj = xmlXPathEval(BAD_CAST "string(/domain/os/cmdline[1])", ctxt);
@@ -1173,8 +1164,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
         }
         strcpy(def->os.cmdline, (const char *)obj->stringval);
     }
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
 
     /* analysis of the disk devices */
@@ -1224,8 +1214,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
         }
         strcpy(def->os.binary, (const char *)obj->stringval);
     }
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
     obj = xmlXPathEval(BAD_CAST "/domain/devices/graphics", ctxt);
     if ((obj == NULL) || (obj->type != XPATH_NODESET) ||
@@ -1382,8 +1371,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
 
  error:
     free(prop);
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
     xmlXPathFreeContext(ctxt);
     qemudFreeVMDef(def);
     return NULL;
@@ -2389,10 +2377,8 @@ static struct qemud_network_def *qemudParseNetworkXML(virConnectPtr conn,
  error:
     /* XXX free all the stuff in the qemud_network struct, or leave it upto
        the caller ? */
-    if (obj)
-        xmlXPathFreeObject(obj);
-    if (tmp)
-        xmlXPathFreeObject(tmp);
+    xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(tmp);
     xmlXPathFreeContext(ctxt);
     qemudFreeNetworkDef(def);
     return NULL;
index 36808ed37589afadc27c47620f9bd3f4de3e6773..9521eff6cc0e1aed65bb81b4f6793fec5106ccf3 100644 (file)
@@ -2931,8 +2931,7 @@ cmdVNCDisplay(vshControl * ctl, vshCmd * cmd)
     ret = TRUE;
 
  cleanup:
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
     xmlXPathFreeContext(ctxt);
     if (xml)
         xmlFreeDoc(xml);
@@ -2993,8 +2992,7 @@ cmdTTYConsole(vshControl * ctl, vshCmd * cmd)
     vshPrint(ctl, "%s\n", (const char *)obj->stringval);
 
  cleanup:
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
     xmlXPathFreeContext(ctxt);
     if (xml)
         xmlFreeDoc(xml);
@@ -3338,8 +3336,7 @@ cmdDetachInterface(vshControl * ctl, vshCmd * cmd)
  cleanup:
     if (dom)
         virDomainFree(dom);
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
     xmlXPathFreeContext(ctxt);
     if (xml)
         xmlFreeDoc(xml);
@@ -3611,8 +3608,7 @@ cmdDetachDisk(vshControl * ctl, vshCmd * cmd)
         ret = TRUE;
 
  cleanup:
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
     xmlXPathFreeContext(ctxt);
     if (xml)
         xmlFreeDoc(xml);
index 2bca799c72f0aa27508313002468ec28475af13c..ec2e7919f048df6c11842f1d11eeb42f89277183 100644 (file)
@@ -1558,8 +1558,7 @@ int xenXMConfigSetIntFromXPath(virConnectPtr conn,
     ret = 0;
 
  error:
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
     return ret;
 }
@@ -1593,8 +1592,7 @@ int xenXMConfigSetStringFromXPath(virConnectPtr conn,
     ret = 0;
 
  error:
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
 
     return ret;
 }
@@ -2280,8 +2278,7 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
         virConfFree(conf);
     if (prop != NULL)
         xmlFree(prop);
-    if (obj != NULL)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
     xmlXPathFreeContext(ctxt);
     if (doc != NULL)
         xmlFreeDoc(doc);
@@ -2580,8 +2577,7 @@ xenXMDomainAttachDevice(virDomainPtr domain, const char *xml) {
         (obj->stringval) && (STREQ((char *)obj->stringval, "hvm")))
         hvm = 1;
 
-    if (ctxt)
-        xmlXPathFreeContext(ctxt);
+    xmlXPathFreeContext(ctxt);
     ctxt = NULL;
     if (doc)
         xmlFreeDoc(doc);
@@ -2619,12 +2615,9 @@ xenXMDomainAttachDevice(virDomainPtr domain, const char *xml) {
     ret = 0;
 
  cleanup:
-    if (domxml)
-        free(domxml);
-    if (obj)
-        xmlXPathFreeObject(obj);
-    if (ctxt)
-        xmlXPathFreeContext(ctxt);
+    free(domxml);
+    xmlXPathFreeObject(obj);
+    xmlXPathFreeContext(ctxt);
     if (doc)
         xmlFreeDoc(doc);
 
@@ -2738,8 +2731,7 @@ xenXMAttachDisk(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
             prev->next = list_val;
     } else {
         /* configure */
-        if (list_val->str)
-            free(list_val->str);
+        free(list_val->str);
         list_val->str = dev;
     }
 
@@ -2747,12 +2739,9 @@ xenXMAttachDisk(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
     goto cleanup;
 
  cleanup:
-    if (type)
-        free(type);
-    if (source)
-        free(source);
-    if (target)
-        free(target);
+    free(type);
+    free(source);
+    free(target);
 
     return (ret);
 }
@@ -2825,8 +2814,7 @@ xenXMAttachInterface(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
 
             if (!(strcmp(dommac, (const char *) mac))) {
                 if (autoassign) {
-                    if (mac)
-                        free(mac);
+                    free(mac);
                     mac = NULL;
                     if (!(mac = (xmlChar *)xenXMAutoAssignMac()))
                         goto cleanup;
@@ -2914,8 +2902,7 @@ xenXMAttachInterface(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
             prev->next = list_val;
     } else {
         /* configure */
-        if (list_val->str)
-            free(list_val->str);
+        free(list_val->str);
         list_val->str = dev;
     }
 
@@ -2930,12 +2917,9 @@ xenXMAttachInterface(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
     if (text_node)
         xmlFree(text_node);
  cleanup:
-    if (type)
-        free(type);
-    if (source)
-        free(source);
-    if (mac)
-        free(mac);
+    free(type);
+    free(source);
+    free(mac);
 
     return (ret);
 }
@@ -3139,16 +3123,12 @@ xenXMDomainDetachDevice(virDomainPtr domain, const char *xml) {
     ret = 0;
 
  cleanup:
-    if (ctxt)
-        xmlXPathFreeContext(ctxt);
+    xmlXPathFreeContext(ctxt);
     if (doc)
         xmlFreeDoc(doc);
-    if (domdevice)
-        free(domdevice);
-    if (key)
-        free(key);
-    if (list_val)
-        free(list_val);
+    free(domdevice);
+    free(key);
+    free(list_val);
 
     return (ret);
 }
index 614deb0e6d1ab8dd005152677821e935769ee91c..4ac1765f3c420d28741e798471daf7b07332f654 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -479,8 +479,7 @@ virXPathString(const char *xpath, xmlXPathContextPtr ctxt)
     obj = xmlXPathEval(BAD_CAST xpath, ctxt);
     if ((obj == NULL) || (obj->type != XPATH_STRING) ||
         (obj->stringval == NULL) || (obj->stringval[0] == 0)) {
-        if (obj)
-            xmlXPathFreeObject(obj);
+        xmlXPathFreeObject(obj);
         return (NULL);
     }
     ret = strdup((char *) obj->stringval);
index 9297004a874716264288ffb96e2a07f14f953ce7..5c16b0b9a3caf628d85b4ac2d75d8089279dcd47 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * xmlrpctest.c: simple client for XML-RPC tests
  *
- * Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2005, 2008 Red Hat, Inc.
  *
  * See COPYING.LIB for the License of this software
  *
@@ -119,8 +119,7 @@ checkRequestValue(const char *xmlstr, const char *xpath, int type, void *expecte
     ret = 0;
 
 error:
-    if (obj)
-        xmlXPathFreeObject(obj);
+    xmlXPathFreeObject(obj);
     xmlXPathFreeContext(ctxt);
     if (xml)
         xmlFreeDoc(xml);