Send Linux-ha-cvs mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."


Today's Topics:

   1. Linux-HA CVS: lib by lars from  ([email protected])
   2. Linux-HA CVS: lib by andrew from 
      ([email protected])
   3. Linux-HA CVS: lib by andrew from 
      ([email protected])


----------------------------------------------------------------------

Message: 1
Date: Fri,  7 Apr 2006 07:44:43 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by lars from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : lars
Host    : 
Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/mgmt


Modified Files:
        mgmt_common_lib.c 


Log Message:
CID 20: Free'd the wrong pointer.

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/mgmt/mgmt_common_lib.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- mgmt_common_lib.c   14 Dec 2005 09:39:24 -0000      1.2
+++ mgmt_common_lib.c   7 Apr 2006 13:44:43 -0000       1.3
@@ -161,7 +161,7 @@
        /* malloc the array for args */
        ret = (char**)mgmt_malloc(sizeof(char*)*n);
        if (ret == NULL) {
-               mgmt_free(p);
+               mgmt_free(buf);
                return NULL;
        }
 




------------------------------

Message: 2
Date: Fri,  7 Apr 2006 08:05:35 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/crm/common


Modified Files:
        xml.c 


Log Message:
Cleanup write_xml_file() a little

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/xml.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -3 -r1.68 -r1.69
--- xml.c       4 Apr 2006 13:20:54 -0000       1.68
+++ xml.c       7 Apr 2006 14:05:30 -0000       1.69
@@ -1,4 +1,4 @@
-/* $Id: xml.c,v 1.68 2006/04/04 13:20:54 andrew Exp $ */
+/* $Id: xml.c,v 1.69 2006/04/07 14:05:30 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -587,8 +587,11 @@
 write_xml_file(crm_data_t *xml_node, const char *filename, gboolean compress) 
 {
        int res = 0;
-       char *now_str = NULL;
        time_t now;
+       char *buffer = NULL;
+       char *now_str = NULL;
+       gboolean is_done = FALSE;
+       FILE *file_output_strm = NULL;
 
        CRM_CHECK(filename != NULL, return -1);
 
@@ -609,69 +612,64 @@
        crm_xml_add(xml_node, XML_CIB_ATTR_WRITTEN, now_str);
        crm_validate_data(xml_node);
        
-       {
-               FILE *file_output_strm = fopen(filename, "w");
-               if(file_output_strm == NULL) {
-                       res = -1;
-                       cl_perror("Cannot write to %s", filename);
-                       
-               } else {
-                       gboolean is_done = FALSE;
-                       char *buffer = dump_xml_formatted(xml_node);
-                       CRM_CHECK(buffer != NULL && strlen(buffer) > 0, return 
-1);
-                       if(buffer == NULL || strlen(buffer) <= 0) {
-                               is_done = TRUE;
-                       }
+       file_output_strm = fopen(filename, "w");
+       if(file_output_strm == NULL) {
+               cl_perror("Cannot write to %s", filename);
+               return -1;
+               
+       } 
+
+       buffer = dump_xml_formatted(xml_node);
+       CRM_CHECK(buffer != NULL && strlen(buffer) > 0, return -1);
+       if(buffer == NULL || strlen(buffer) <= 0) {
+               is_done = TRUE;
+       }
+
 #if HAVE_BZLIB_H
-                       if(compress && is_done == FALSE) {
-                               int rc = BZ_OK;
-                               BZFILE *bz_file = NULL;
-                               unsigned int in = 0, out = 0;
-                               is_done = TRUE;
-                               bz_file = BZ2_bzWriteOpen(
-                                       &rc, file_output_strm, 5, 0, 0);
-                               if(rc != BZ_OK) {
-                                       is_done = FALSE;
-                                       crm_err("bzWriteOpen failed: %d", rc);
-                               }
-                               if(is_done) {
-                                       BZ2_bzWrite(&rc, bz_file,
-                                                   buffer, strlen(buffer));
-                                       if(rc != BZ_OK) {
-                                               crm_err("bzWrite() failed: %d", 
rc);
-                                               is_done = FALSE;
-                                       }
-                               }
-                               if(is_done) {
-                                       BZ2_bzWriteClose(&rc, bz_file, 0, &in, 
&out);
-                                       if(rc != BZ_OK) {
-                                               crm_err("bzWriteClose() failed: 
%d",rc);
-                                               is_done = FALSE;
-                                       } else {
-                                               crm_debug("%s: In: %d, out: %d",
-                                                         filename, in, out);
-                                       }
-                               }
+       if(compress && is_done == FALSE) {
+               int rc = BZ_OK;
+               BZFILE *bz_file = NULL;
+               unsigned int in = 0, out = 0;
+               is_done = TRUE;
+               bz_file = BZ2_bzWriteOpen(&rc, file_output_strm, 5,0,0);
+               if(rc != BZ_OK) {
+                       is_done = FALSE;
+                       crm_err("bzWriteOpen failed: %d", rc);
+               }
+               if(is_done) {
+                       BZ2_bzWrite(&rc,bz_file,buffer,strlen(buffer));
+                       if(rc != BZ_OK) {
+                               crm_err("bzWrite() failed: %d", rc);
+                               is_done = FALSE;
                        }
-#endif
-                       if(compress && is_done == FALSE) {
-                               compress = FALSE;
-                               crm_warn("bzlib failed or not installed."
-                                        "  Writing uncompressed data to: %s",
-                                        filename);
-                       }
-                       if(is_done == FALSE) {
-                               res = fprintf(file_output_strm, "%s", buffer);
-                               if(res < 0) {
-                                       cl_perror("Cannot write output to %s",
-                                                 filename);
-                               }
-                               fflush(file_output_strm);
+               }
+               if(is_done) {
+                       BZ2_bzWriteClose(&rc, bz_file, 0, &in, &out);
+                       if(rc != BZ_OK) {
+                               crm_err("bzWriteClose() failed: %d",rc);
+                               is_done = FALSE;
+                       } else {
+                               crm_debug("%s: In: %d, out: %d",
+                                         filename, in, out);
                        }
-                       fclose(file_output_strm);
-                       crm_free(buffer);
                }
        }
+#endif
+       if(compress && is_done == FALSE) {
+               compress = FALSE;
+               crm_warn("bzlib failed or not installed."
+                        "  Writing uncompressed data to: %s",filename);
+       }
+       if(is_done == FALSE) {
+               res = fprintf(file_output_strm, "%s", buffer);
+               if(res < 0) {
+                       cl_perror("Cannot write output to %s",filename);
+               }
+               fflush(file_output_strm);
+       }
+       fclose(file_output_strm);
+       crm_free(buffer);
+
        crm_debug_3("Saved %d bytes to the Cib as XML", res);
 
        return res;




------------------------------

Message: 3
Date: Fri,  7 Apr 2006 08:06:37 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/crm/common


Modified Files:
        utils.c 


Log Message:
Some simplifications brought on by Coverity complaining about dead code

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/utils.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -3 -r1.41 -r1.42
--- utils.c     4 Apr 2006 17:18:06 -0000       1.41
+++ utils.c     7 Apr 2006 14:06:36 -0000       1.42
@@ -1,4 +1,4 @@
-/* $Id: utils.c,v 1.41 2006/04/04 17:18:06 andrew Exp $ */
+/* $Id: utils.c,v 1.42 2006/04/07 14:06:36 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -197,29 +197,31 @@
        char *char_value = (char*)value;
        int value_len = strlen(char_value);
 
+       CRM_CHECK(value != NULL,  return FALSE);
+       CRM_CHECK(node != NULL,   return FALSE);
+       CRM_CHECK(subsys != NULL, return FALSE);
+       
+       *node = NULL;
+       *subsys = NULL;
+
        crm_info("Decoding hash value: (%s:%d)", char_value, value_len);
        
        if (strcmp(CRM_SYSTEM_DC, (char*)value) == 0) {
                *node = NULL;
                *subsys = (char*)crm_strdup(char_value);
-               if (*subsys == NULL) {
-                       crm_err("memory allocation failed in "
-                              "decode_hash_value()");
-                       return FALSE;
-               }
+               CRM_CHECK(*subsys != NULL, return FALSE);
                crm_info("Decoded value: (%s:%d)", *subsys,
                         (int)strlen(*subsys));
                return TRUE;
                
-       } else if (char_value != NULL) {
-               if (decodeNVpair(char_value, '_', node, subsys)) {
-                       return TRUE;
-               } else {
-                       *node = NULL;
-                       *subsys = NULL;
-                       return FALSE;
-               }
+       } else if (decodeNVpair(char_value, '_', node, subsys)) {
+               return TRUE;
        }
+
+       crm_free(*node);
+       crm_free(*subsys);
+       *node = NULL;
+       *subsys = NULL;
        return FALSE;
 }
 
@@ -374,16 +376,8 @@
                return 1;
        }
        
-       if(version1 != NULL) {
-               rest1 = crm_strdup(version1);
-       } else {
-               version1 = "<null>";
-       }
-       if(version2 != NULL) {
-               rest2 = crm_strdup(version2);
-       } else {
-               version2 = "<null>";
-       }
+       rest1 = crm_strdup(version1);
+       rest2 = crm_strdup(version2);
        
        while(1) {
                int cmp = 0;




------------------------------

_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs


End of Linux-ha-cvs Digest, Vol 29, Issue 35
********************************************

Reply via email to