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

[PATCH] Fix compiler warnings

From: <jerenkrantz_at_apache.org>
Date: 2003-01-21 19:16:38 CET

This patch removes a bunch of compiler warnings seen with Sun Forte.
Besides one 'statement not reachable' warning, the rest are
signed/unsigned conflicts. The real root of this stems from the fact
that apr_md5_* only deals with unsigned char*'s while everything else
in SVN only deals with char*s. (Does GCC ignore these warnings?)

Perhaps the bigger question is whether to somehow fix the apr_md5_*
API to take char*'s instead? I'm sort of on the fence here. Before
starting what will most likely be a painful discussion on dev@apr,
I'd like to see what you guys (namely Karl since he wrote most of the
checksum code that uses MD5) think first. What makes more sense?
Fixing SVN or fixing APR? -- justin

* subversion/libsvn_fs/reps-strings.c
  (svn_fs__reps_contents, txn_body_read_rep, txn_body_write_rep,
  svn_fs__rep_undeltify): Ensure strings sent to apr_md5_update are
unsigned
  char *'s.
* subversion/libsvn_wc/props.c (svn_wc__conflicting_propchanges_p):
  Remove code that is unreachable. (The answer to the comment is
'no.')
* subversion/libsvn_subr/svn_base64.c
  (encode_baton): Make buf an unsigned char.
  (encode_partial_group): Make extra an unsigned char.
  (svn_base64_encode_string): Make ingroup an unsigned char.
  (svn_base64_from_md5): Attempt to deal with signed/unsigned
mismatch by
  removing some abstractions that only deal with 'char'
* subversion/tests/libsvn_fs/fs-test.c
  (get_file_digest, file_integrity_helper, verify_checksum): Ensure
strings
  sent to apr_md5_update are unsigned char *'s.
* subversion/tests/libsvn_repos/md5args.c (main): Ditto.
* subversion/libsvn_delta/text_delta.c
  (svn_txdelta_next_window, apply_window): Ditto.
* subversion/libsvn_ra_dav/fetch.c
  (get_file_reader): Ditto.

Index: subversion/libsvn_fs/reps-strings.c
===================================================================
--- subversion/libsvn_fs/reps-strings.c (revision 4481)
+++ subversion/libsvn_fs/reps-strings.c (working copy)
@@ -728,7 +728,7 @@
     unsigned char checksum[MD5_DIGESTSIZE];

     apr_md5_init (md5_context);
- apr_md5_update (md5_context, str-data, str-len);
+ apr_md5_update (md5_context, (unsigned char*)str-data,
str-len);
     apr_md5_final (checksum, md5_context);

     SVN_ERR (svn_fs__bdb_read_rep (rep, fs, rep_key, trail));
@@ -804,7 +804,8 @@
        */
       if (! args-rb-checksum_finalized)
         {
- apr_md5_update ((args-rb-md5_context), args-buf,
*(args-len));
+ apr_md5_update ((args-rb-md5_context), (unsigned
char*)args-buf,
+ *(args-len));

           if (args-rb-offset == args-rb-size)
             {
@@ -991,7 +992,8 @@
                       args-wb-txn_id,
                       trail));

- apr_md5_update ((args-wb-md5_context), args-buf, args-len);
+ apr_md5_update ((args-wb-md5_context), (unsigned
char*)args-buf,
+ args-len);

   return SVN_NO_ERROR;
 }
@@ -1567,7 +1569,7 @@

       len = SVN_STREAM_CHUNK_SIZE;
       SVN_ERR (svn_stream_read (source_stream, buf, len));
- apr_md5_update (context, buf, len);
+ apr_md5_update (context, (unsigned char*)buf, len);
       len_read = len;
       SVN_ERR (svn_stream_write (target_stream, buf, len));
       if (len_read != len)
Index: subversion/libsvn_wc/props.c
===================================================================
--- subversion/libsvn_wc/props.c (revision 4481)
+++ subversion/libsvn_wc/props.c (working copy)
@@ -205,9 +205,6 @@
   else
     /* values are the same, so another implicit merge. */
     return FALSE; /* no conflict */
-
- /* Default (will anyone ever reach this line?) */
- return FALSE; /* no conflict found */
 }

Index: subversion/libsvn_subr/svn_base64.c
===================================================================
--- subversion/libsvn_subr/svn_base64.c (revision 4481)
+++ subversion/libsvn_subr/svn_base64.c (working copy)
@@ -40,7 +40,7 @@

 struct encode_baton {
   svn_stream_t *output;
- char buf[3]; /* Bytes waiting to be encoded */
+ unsigned char buf[3]; /* Bytes waiting to be encoded */
   int buflen; /* Number of bytes waiting */
   int linelen; /* Bytes output so far on this line
*/
   apr_pool_t *pool;
@@ -99,8 +99,8 @@
 /* Encode leftover data, if any, and possibly a final newline,
    appending to STR. LEN must be in the range 0..2. */
 static void
-encode_partial_group (svn_stringbuf_t *str, const char *extra, int
len,
- int linelen)
+encode_partial_group (svn_stringbuf_t *str, const unsigned char
*extra,
+ int len, int linelen)
 {
   unsigned char ingroup[3];
   char outgroup[4];
@@ -184,7 +184,7 @@
 svn_base64_encode_string (svn_stringbuf_t *str, apr_pool_t *pool)
 {
   svn_stringbuf_t *encoded = svn_stringbuf_create (, pool);
- char ingroup[3];
+ unsigned char ingroup[3];
   int ingrouplen = 0, linelen = 0;

   encode_bytes (encoded, str-data, str-len, ingroup, ingrouplen,
linelen);
@@ -333,10 +333,17 @@
 svn_base64_from_md5 (unsigned char digest[], apr_pool_t *pool)
 {
   svn_stringbuf_t *md5str;
+ unsigned char ingroup[3];
+ int ingrouplen = 0, linelen = 0;
+
+ md5str = svn_stringbuf_create (, pool);
+ /* This cast is safe because we know encode_bytes does a memcpy and
+ * does an implicit unsigned char * cast.
+ */
+ encode_bytes (md5str, (char*)digest, MD5_DIGESTSIZE, ingroup,
ingrouplen,
+ linelen);
+ encode_partial_group (md5str, ingroup, ingrouplen, linelen);

- md5str = svn_stringbuf_ncreate (digest, MD5_DIGESTSIZE, pool);
- md5str = svn_base64_encode_string (md5str, pool);
-
   /* Our base64-encoding routines append a final newline if any data
      was created at all, so let's hack that off. */
   if ((md5str)-len)
Index: subversion/tests/libsvn_fs/fs-test.c
===================================================================
--- subversion/tests/libsvn_fs/fs-test.c (revision 4481)
+++ subversion/tests/libsvn_fs/fs-test.c (working copy)
@@ -4271,7 +4271,7 @@
       SVN_ERR (svn_stream_read (stream, buf, len));

       /* Update the MD5 calculation with the data we just read. */
- apr_md5_update (context, buf, len);
+ apr_md5_update (context, (unsigned char*)buf, len);

     } while (len == buf_size); /* Continue until a short read. */

@@ -4380,7 +4380,7 @@
   SVN_ERR (svn_fs_txn_root (txn_root, txn, subpool));
   SVN_ERR (svn_fs_make_file (txn_root, bigfile, subpool));
   random_data_to_buffer (content_buffer, filesize, TRUE, seed);
- apr_md5 (digest, contents.data, contents.len);
+ apr_md5 (digest, (unsigned char*)contents.data, contents.len);
   SVN_ERR (svn_fs_apply_textdelta
            (wh_func, wh_baton, txn_root, bigfile, NULL, NULL,
subpool));
   SVN_ERR (svn_txdelta_send_string (contents, wh_func, wh_baton,
subpool));
@@ -4394,7 +4394,7 @@
   SVN_ERR (svn_fs_begin_txn (txn, fs, youngest_rev, subpool));
   SVN_ERR (svn_fs_txn_root (txn_root, txn, subpool));
   random_data_to_buffer (content_buffer, 20, TRUE, seed);
- apr_md5 (digest, contents.data, contents.len);
+ apr_md5 (digest, (unsigned char*)contents.data, contents.len);
   SVN_ERR (svn_fs_apply_textdelta
            (wh_func, wh_baton, txn_root, bigfile, NULL, NULL,
subpool));
   SVN_ERR (svn_txdelta_send_string (contents, wh_func, wh_baton,
subpool));
@@ -4407,7 +4407,7 @@
   SVN_ERR (svn_fs_begin_txn (txn, fs, youngest_rev, subpool));
   SVN_ERR (svn_fs_txn_root (txn_root, txn, subpool));
   random_data_to_buffer (content_buffer + (filesize - 20), 20, TRUE,
seed);
- apr_md5 (digest, contents.data, contents.len);
+ apr_md5 (digest, (unsigned char*)contents.data, contents.len);
   SVN_ERR (svn_fs_apply_textdelta
            (wh_func, wh_baton, txn_root, bigfile, NULL, NULL,
subpool));
   SVN_ERR (svn_txdelta_send_string (contents, wh_func, wh_baton,
subpool));
@@ -4422,7 +4422,7 @@
   SVN_ERR (svn_fs_txn_root (txn_root, txn, subpool));
   random_data_to_buffer (content_buffer, 20, TRUE, seed);
   random_data_to_buffer (content_buffer + (filesize - 20), 20, TRUE,
seed);
- apr_md5 (digest, contents.data, contents.len);
+ apr_md5 (digest, (unsigned char*)contents.data, contents.len);
   SVN_ERR (svn_fs_apply_textdelta
            (wh_func, wh_baton, txn_root, bigfile, NULL, NULL,
subpool));
   SVN_ERR (svn_txdelta_send_string (contents, wh_func, wh_baton,
subpool));
@@ -4439,7 +4439,7 @@
       SVN_ERR (svn_fs_begin_txn (txn, fs, youngest_rev, subpool));
       SVN_ERR (svn_fs_txn_root (txn_root, txn, subpool));
       random_data_to_buffer (content_buffer, filesize, FALSE, seed);
- apr_md5 (digest, contents.data, contents.len);
+ apr_md5 (digest, (unsigned char*)contents.data, contents.len);
       SVN_ERR (svn_fs_apply_textdelta (wh_func, wh_baton, txn_root,
                                        bigfile, NULL, NULL,
subpool));
       SVN_ERR (svn_txdelta_send_string
@@ -5577,7 +5577,7 @@
     return SVN_NO_ERROR;

   str = svn_stringbuf_create (My text editor charges me rent.,
pool);
- apr_md5 (expected_digest, str-data, str-len);
+ apr_md5 (expected_digest, (unsigned char*)str-data, str-len);

   SVN_ERR (svn_test__create_fs (fs, test-repo-verify-checksum,
pool));
   SVN_ERR (svn_fs_begin_txn (txn, fs, 0, pool));
Index: subversion/tests/libsvn_repos/md5args.c
===================================================================
--- subversion/tests/libsvn_repos/md5args.c (revision 4481)
+++ subversion/tests/libsvn_repos/md5args.c (working copy)
@@ -97,7 +97,7 @@
   printf (args=%s\n, string-data);

   /* Now, run the MD5 digest calculation on that string. */
- apr_md5 (digest, string-data, string-len);
+ apr_md5 (digest, (unsigned char*)string-data, string-len);
   digest_str = svn_stringbuf_create (, pool);
   for (i = 0; i MD5_DIGESTSIZE; i++)
     {
Index: subversion/libsvn_delta/text_delta.c
===================================================================
--- subversion/libsvn_delta/text_delta.c (revision 4481)
+++ subversion/libsvn_delta/text_delta.c (working copy)
@@ -288,7 +288,8 @@
          APR_SUCCESS. As such, we are proposing to the APR folks
that
          its interface change to be a void function. In the
meantime,
          we'll simply ignore the return value. */
- apr_md5_update ((stream-context), stream-buf, source_len);
+ apr_md5_update ((stream-context), (unsigned
char*)stream-buf,
+ source_len);

       /* Read the target stream. */
       if (err == SVN_NO_ERROR)
@@ -515,7 +516,7 @@
      svn_stream_closed(). But this might be overkill for issue #689;
      so for now we just update the context here. */
   if (ab-result_checksum)
- apr_md5_update((ab-md5_context), ab-tbuf, len);
+ apr_md5_update((ab-md5_context), (unsigned char*)ab-tbuf,
len);

   return svn_stream_write (ab-target, ab-tbuf, );
 }
Index: subversion/libsvn_ra_dav/fetch.c
===================================================================
--- subversion/libsvn_ra_dav/fetch.c (revision 4481)
+++ subversion/libsvn_ra_dav/fetch.c (working copy)
@@ -798,7 +798,7 @@
   svn_stream_t *stream = fwc-stream;

   if (fwc-do_checksum)
- apr_md5_update((fwc-md5_context), buf, len);
+ apr_md5_update((fwc-md5_context), (const unsigned char*) buf,
len);

   /* Write however many bytes were passed in by neon. */
   wlen = len;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 14 02:04:17 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.