[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH][merge-tracking]Fix compile warnings in subversion/libsvn_ra_dav/mergeinfo.c

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2006-09-19 13:29:58 CEST

Hi All,
Find the attached patch and log.

With regards
Kamesh Jayachandran

[[[
Patch by: Kamesh Jayachandran <kamesh@collab.net>

Compile warning was there while passing incompatible pointers for
'svn_ra_dav__startelm_cb_t', 'svn_ra_dav__cdata_cb_t' and
'svn_ra_dav__endelm_cb_t' to 'svn_ra_dav__parsed_request'.

* subversion/libsvn_ra_dav/mergeinfo.c
  (start_element):
   return 'svn_error_t *' adhering to 'svn_ra_dav__startelm_cb_t'.
   Added 'elem' which is used by 'neon' to decide whether to proceed
   with parsing.
   Ignore the element if it is unknown by setting '*elem' to NE_XML_DECLINE,
   and proceed with parsing by returning SVN_NO_ERROR.
   For invalid xml use 'UNEXPECTED_ELEMENT' to signal the error.
   To abort the xml parsing return the 'svn_error_t *', wrapper takes care
   of aborting it.
   Set *elem with the element id as it is generally expected.

  (end_element):
   return 'svn_error_t *' adhering to 'svn_ra_dav__endelm_cb_t'.
   For invalid xml use 'UNEXPECTED_ELEMENT' to signal the error.
   If 'svn_mergeinfo_parse' fails with error return the same so that
   calling wrapper would abort xml parsing.
   Remove the unguarded fail block.

  (cdata_handler):
   return 'svn_error_t *' adhering to 'svn_ra_dav__cdata_cb_t'.
   To abort the xml parsing return the 'svn_error_t *', wrapper takes care
   of aborting it.
]]]

Index: subversion/libsvn_ra_dav/mergeinfo.c
===================================================================
--- subversion/libsvn_ra_dav/mergeinfo.c (revision 21550)
+++ subversion/libsvn_ra_dav/mergeinfo.c (working copy)
@@ -62,8 +62,8 @@
     { NULL }
   };
 
-static int
-start_element(void *baton, int parent_state, const char *nspace,
+static svn_error_t *
+start_element(int *elem, void *baton, int parent_state, const char *nspace,
               const char *elt_name, const char **atts)
 {
   struct mergeinfo_baton *mb = baton;
@@ -72,14 +72,17 @@
     = svn_ra_dav__lookup_xml_elem(mergeinfo_report_elements, nspace,
                                   elt_name);
   if (! elm)
- return NE_XML_DECLINE;
+ {
+ *elem = NE_XML_DECLINE;
+ return SVN_NO_ERROR;
+ }
 
   if (parent_state == ELEM_root)
     {
       /* If we're at the root of the tree, the element has to be the editor
        * report itself. */
       if (elm->id != ELEM_merge_info_report)
- return SVN_RA_DAV__XML_INVALID;
+ return UNEXPECTED_ELEMENT(nspace, elt_name);
     }
 
   if (elm->id == ELEM_merge_info_item)
@@ -89,12 +92,13 @@
     }
 
   if (mb->err)
- return NE_XML_ABORT;
+ return mb->err;
 
- return elm->id;
+ *elem = elm->id;
+ return SVN_NO_ERROR;
 }
 
-static int
+static svn_error_t *
 end_element(void *baton, int state, const char *nspace, const char *elt_name)
 {
   struct mergeinfo_baton *mb = baton;
@@ -103,7 +107,7 @@
     = svn_ra_dav__lookup_xml_elem(mergeinfo_report_elements, nspace,
                                   elt_name);
   if (! elm)
- return NE_XML_DECLINE;
+ return UNEXPECTED_ELEMENT(nspace, elt_name);
 
   if (elm->id == ELEM_merge_info_item)
     {
@@ -112,21 +116,18 @@
           apr_hash_t *temp;
 
           mb->err = svn_mergeinfo_parse(mb->curr_info, &temp, mb->pool);
- if (mb->err != SVN_NO_ERROR)
- goto fail;
+ if (mb->err)
+ return mb->err;
 
           apr_hash_set(mb->result, mb->curr_path, APR_HASH_KEY_STRING,
                        temp);
         }
     }
- fail:
- if (mb->err)
- return NE_XML_ABORT;
 
- return SVN_RA_DAV__XML_VALID;
+ return SVN_NO_ERROR;
 }
 
-static int
+static svn_error_t *
 cdata_handler(void *baton, int state, const char *cdata, size_t len)
 {
   struct mergeinfo_baton *mb = baton;
@@ -144,9 +145,9 @@
       break;
     }
   if (mb->err)
- return NE_XML_ABORT;
+ return mb->err;
 
- return 0; /* no error */
+ return SVN_NO_ERROR;
 }
 
 /* Request a merge-info-report from the URL attached to SESSION,

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Sep 19 13:29:44 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.