You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/08/29 12:07:25 UTC

svn commit: r990535 - in /subversion/branches/performance/subversion/libsvn_fs_fs: id.c temp_serializer.c

Author: stefan2
Date: Sun Aug 29 10:07:25 2010
New Revision: 990535

URL: http://svn.apache.org/viewvc?rev=990535&view=rev
Log:
Although this is not likely to actually change the tool behavior
on any platform, it is technically correct to check NULL pointers
only after de-serializing ("resolving") them. Their serialized
representation may be (or become in future) different from (int)0.

* subversion/libsvn_fs_fs/temp_serializer.c
  (deserialize_svn_string, deserialize_checksum,
   deserialize_representation, svn_fs_fs__noderev_deserialize):
  check for NULL pointers only after they got resolved from their 
  serialized representation

* subversion/libsvn_fs_fs/id.c
  (svn_fs_fs__id_deserialize): dito

Modified:
    subversion/branches/performance/subversion/libsvn_fs_fs/id.c
    subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.c

Modified: subversion/branches/performance/subversion/libsvn_fs_fs/id.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_fs_fs/id.c?rev=990535&r1=990534&r2=990535&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_fs_fs/id.c (original)
+++ subversion/branches/performance/subversion/libsvn_fs_fs/id.c Sun Aug 29 10:07:25 2010
@@ -369,15 +369,15 @@ deserialize_id_private(void *buffer, id_
 void
 svn_fs_fs__id_deserialize(void *buffer, svn_fs_id_t **id)
 {
-  /* no id, no fixup necessary */
-  if (*id == NULL)
-    return;
-
   /* The id maybe all what is in the whole buffer.
    * Don't try to fixup the pointer in that case*/
   if (*id != buffer)
     svn_temp_deserializer__resolve(buffer, (void**)id);
 
+  /* no id, no sub-structure fixup necessary */
+  if (*id == NULL)
+    return;
+
   /* the stored vtable is bogus at best -> set the right one */
   (*id)->vtable = &id_vtable;
 

Modified: subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.c?rev=990535&r1=990534&r2=990535&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.c (original)
+++ subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.c Sun Aug 29 10:07:25 2010
@@ -148,10 +148,10 @@ serialize_svn_string(svn_temp_serializer
 static void
 deserialize_svn_string(void *buffer, svn_string_t **string)
 {
+  svn_temp_deserializer__resolve(buffer, (void **)string);
   if (*string == NULL)
     return;
 
-  svn_temp_deserializer__resolve(buffer, (void **)string);
   svn_temp_deserializer__resolve(*string, (void **)&(*string)->data);
 }
 
@@ -186,10 +186,10 @@ serialize_checksum(svn_temp_serializer__
 static void
 deserialize_checksum(void *buffer, svn_checksum_t * const *cs)
 {
+  svn_temp_deserializer__resolve(buffer, (void **)cs);
   if (*cs == NULL)
     return;
 
-  svn_temp_deserializer__resolve(buffer, (void **)cs);
   svn_temp_deserializer__resolve(*cs, (void **)&(*cs)->digest);
 }
 
@@ -227,12 +227,12 @@ deserialize_representation(void *buffer,
                            representation_t **representation)
 {
   representation_t *rep;
-  if (*representation == NULL)
-    return;
 
   /* fixup the reference to the representation itself */
   svn_temp_deserializer__resolve(buffer, (void **)representation);
   rep = *representation;
+  if (rep == NULL)
+    return;
 
   /* fixup of sub-structures */
   deserialize_checksum(rep, &rep->md5_checksum);
@@ -387,8 +387,6 @@ svn_fs_fs__noderev_deserialize(void *buf
                                node_revision_t **noderev_p)
 {
   node_revision_t *noderev;
-  if (*noderev_p == NULL)
-    return;
 
   /* fixup the reference to the representation itself,
    * if this is part of a parent structure. */
@@ -396,6 +394,8 @@ svn_fs_fs__noderev_deserialize(void *buf
     svn_temp_deserializer__resolve(buffer, (void **)noderev_p);
 
   noderev = *noderev_p;
+  if (noderev == NULL)
+    return;
 
   /* fixup of sub-structures */
   svn_fs_fs__id_deserialize(noderev, (svn_fs_id_t **)&noderev->id);