You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ri...@apache.org on 2026/01/17 18:17:35 UTC

svn commit: r1931392 - subversion/trunk/subversion/libsvn_subr

Author: rinrab
Date: Sat Jan 17 18:17:34 2026
New Revision: 1931392

Log:
Follow-up to r1931389: Fix compilation with MSVC.

* subversion/libsvn_subr/checksum_apr.c
  (svn_checksum__sha1, svn_checksum__sha1_ctx_update): Cast 'void *' to
  'char *' explicitly.

Modified:
   subversion/trunk/subversion/libsvn_subr/checksum_apr.c

Modified: subversion/trunk/subversion/libsvn_subr/checksum_apr.c
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/checksum_apr.c	Sat Jan 17 18:11:49 2026	(r1931391)
+++ subversion/trunk/subversion/libsvn_subr/checksum_apr.c	Sat Jan 17 18:17:34 2026	(r1931392)
@@ -99,7 +99,7 @@ sha1_update(apr_sha1_ctx_t *ctx,
       else
         block = UINT_MAX;
 
-      apr_sha1_update(ctx, data, block);
+      apr_sha1_update(ctx, (const char *)data, block);
 
       len -= block;
       data += block;
@@ -146,7 +146,7 @@ svn_checksum__sha1_ctx_update(svn_checks
                               const void *data,
                               apr_size_t len)
 {
-  sha1_update(&ctx->apr_ctx, data, len);
+  sha1_update(&ctx->apr_ctx, (const char *)data, len);
   return SVN_NO_ERROR;
 }
 


Re: svn commit: r1931392 - subversion/trunk/subversion/libsvn_subr

Posted by Timofei Zhakov <ti...@chemodax.net>.
On Sun, Jan 18, 2026 at 5:20 AM Branko Čibej <br...@apache.org> wrote:

> On 17. 1. 26 19:17, rinrab@apache.org wrote:
>
> Author: rinrab
> Date: Sat Jan 17 18:17:34 2026
> New Revision: 1931392
>
> Log:
> Follow-up to r1931389: Fix compilation with MSVC.
>
> * subversion/libsvn_subr/checksum_apr.c
>   (svn_checksum__sha1, svn_checksum__sha1_ctx_update): Cast 'void *' to
>   'char *' explicitly.
>
>
>
> I don't understand. Implicit conversion from (const void*) to (const
> char*) is allowed in C, it's only forbidden in C++, where you have to use static_cast<const
> char*>. If MSVC treats this as an error, then it's not a C compiler,
> which I doubt. So what was the error message from the compiler that
> prompted this change?
>
> The reason I'm commenting on this apparently trivial change is that
> typecasts – any typecasts – in C are always suspect and should be avoided
> if at all possible. Not because of some philosophical purity but because
> they can silently hide new bug that might be introduced because of some
> code change sometime in the future.
>
> -- Brane
>
>
It was not the cause of the issue. I reverted this revision later
in r1931394. I'm just stupid because I was adding a void pointer and an
integer inside of the function (that handles blocks). For some reason, GCC
doesn't treat it as an error nor a warning.

The actual fix is r1931395.

-- 
Timofei Zhakov

Re: svn commit: r1931392 - subversion/trunk/subversion/libsvn_subr

Posted by Branko Čibej <br...@apache.org>.
On 17. 1. 26 19:17, rinrab@apache.org wrote:
> Author: rinrab
> Date: Sat Jan 17 18:17:34 2026
> New Revision: 1931392
>
> Log:
> Follow-up to r1931389: Fix compilation with MSVC.
>
> * subversion/libsvn_subr/checksum_apr.c
>    (svn_checksum__sha1, svn_checksum__sha1_ctx_update): Cast 'void *' to
>    'char *' explicitly.


I don't understand. Implicit conversion from (const void*) to (const 
char*) is allowed in C, it's only forbidden in C++, where you have to 
use static_cast<const char*>. If MSVC treats this as an error, then it's 
not a C compiler, which I doubt. So what was the error message from the 
compiler that prompted this change?

The reason I'm commenting on this apparently trivial change is that 
typecasts – any typecasts – in C are always suspect and should be 
avoided if at all possible. Not because of some philosophical purity but 
because they can silently hide new bug that might be introduced because 
of some code change sometime in the future.

-- Brane