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 2013/02/14 23:53:21 UTC

svn commit: r1446377 - in /subversion/branches/fsfs-format7/subversion/libsvn_fs_fs: cached_data.c index.c

Author: stefan2
Date: Thu Feb 14 22:53:20 2013
New Revision: 1446377

URL: http://svn.apache.org/r1446377
Log:
On the fsfs-format7 branch:  Use portable number format specs in printf
or cast parameters to a specific type, e.g. long.

* subversion/libsvn_fs_fs/cached_data.c
  (dgb__log_access): cast smaller values to 'long'; use portable spec
   for potentially large values

* subversion/libsvn_fs_fs/index.c
  (packed_number_stream_t): cast offsets to largest type available;
  (stream_error_create,
   packed_stream_read): prefix hex with "0x"; use portable format spec

Suggested by: rhuijben

Modified:
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/index.c

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c?rev=1446377&r1=1446376&r2=1446377&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c Thu Feb 14 22:53:20 2013
@@ -96,16 +96,18 @@ dgb__log_access(svn_fs_t *fs,
   if (item_type == SVN_FS_FS__ITEM_TYPE_NODEREV && item != NULL)
     {
       node_revision_t *node = item;
-      const char *data_rep = node->data_rep
-                           ? apr_psprintf(scratch_pool, " d=%ld/%ld",
-                                          node->data_rep->revision,
-                                          node->data_rep->item_index)
-                           : "";
-      const char *prop_rep = node->prop_rep
-                           ? apr_psprintf(scratch_pool, " p=%ld/%ld",
-                                          node->prop_rep->revision,
-                                          node->prop_rep->item_index)
-                           : "";
+      const char *data_rep
+        = node->data_rep
+        ? apr_psprintf(scratch_pool, " d=%ld/%" APR_UINT64_T_FMT,
+                       node->data_rep->revision,
+                       node->data_rep->item_index)
+        : "";
+      const char *prop_rep
+        = node->prop_rep
+        ? apr_psprintf(scratch_pool, " p=%ld/%" APR_UINT64_T_FMT,
+                       node->prop_rep->revision,
+                       node->prop_rep->item_index)
+        : "";
       description = apr_psprintf(scratch_pool, "%s   (pc=%d%s%s)",
                                  node->created_path,
                                  node->predecessor_count,
@@ -122,7 +124,8 @@ dgb__log_access(svn_fs_t *fs,
       else if (header->is_delta_vs_empty)
         description = "  DELTA";
       else
-        description = apr_psprintf(scratch_pool, "  DELTA against %ld/%ld",
+        description = apr_psprintf(scratch_pool,
+                                   "  DELTA against %ld/%" APR_UINT64_T_FMT,
                                    header->base_revision,
                                    header->base_item_index);
     }
@@ -163,16 +166,20 @@ dgb__log_access(svn_fs_t *fs,
         }
 
       /* line output */
-      printf("%5s%4lx:%04lx -%4lx:%04lx %s %7ld %5ld   %s\n",
-             pack, offset / ffd->block_size, offset % ffd->block_size,
-             end_offset / ffd->block_size, end_offset % ffd->block_size,
+      printf("%5s%4lx:%04lx -%4lx:%04lx %s %7ld %5"APR_UINT64_T_FMT"   %s\n",
+             pack, (long)(offset / ffd->block_size),
+             (long)(offset % ffd->block_size),
+             (long)(end_offset / ffd->block_size),
+             (long)(end_offset % ffd->block_size),
              type, revision, item_index, description);
     }
   else
     {
       /* reduced logging for format 6 and earlier */
-      printf("%5s%10lx %s %7ld %7ld   %s\n",
-             pack, offset, type, revision, item_index, description);
+      printf("%5s%10" APR_UINT64_T_HEX_FMT " %s %7ld %7" APR_UINT64_T_FMT \
+             "   %s\n",
+             pack, (apr_uint64_t)(offset), type, revision, item_index,
+             description);
     }
 
 #endif

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/index.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/index.c?rev=1446377&r1=1446376&r2=1446377&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/index.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/index.c Thu Feb 14 22:53:20 2013
@@ -172,7 +172,7 @@ typedef struct packed_number_stream_t
 
 /* Return an svn_error_t * object for error ERR on STREAM with the given
  * MESSAGE string.  The latter must have a placeholder for the index file
- * name ("%s") and the current read offset (e.g. "%lx").
+ * name ("%s") and the current read offset (e.g. "0x%lx").
  */
 static svn_error_t *
 stream_error_create(packed_number_stream_t *stream,
@@ -184,7 +184,9 @@ stream_error_create(packed_number_stream
   SVN_ERR(svn_io_file_name_get(&file_name, stream->file,
                                stream->pool));
   SVN_ERR(svn_io_file_seek(stream->file, SEEK_CUR, &offset, stream->pool));
-  return svn_error_createf(err, NULL, message, file_name, offset);
+
+  return svn_error_createf(err, NULL, message, file_name,
+                           (apr_uint64_t)offset);
 }
 
 /* Read up to MAX_NUMBER_PREFETCH numbers from the STREAM->NEXT_OFFSET in
@@ -228,7 +230,7 @@ packed_stream_read(packed_number_stream_
   err = apr_file_read(stream->file, buffer, &read);
   if (err && !APR_STATUS_IS_EOF(err))
     return stream_error_create(stream, err,
-                               _("Can't read index file '%s' at offset %lx"));
+      _("Can't read index file '%s' at offset 0x%" APR_UINT64_T_HEX_FMT));
 
   /* if the last number is incomplete, trim it from the buffer */
   while (read > 0 && buffer[read-1] >= 0x80)
@@ -238,7 +240,7 @@ packed_stream_read(packed_number_stream_
    * at least *one* further number. */
   if SVN__PREDICT_FALSE(read == 0)
     return stream_error_create(stream, err,
-                          _("Unexpected end of index file %s at offset %lx"));
+      _("Unexpected end of index file %s at offset 0x%"APR_UINT64_T_HEX_FMT));
 
   /* parse file buffer and expand into stream buffer */
   target = stream->buffer;