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

Casting away "const"

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Tue, 28 Oct 2008 11:21:18 +0000

Recently there seems to be a large increase in the number of "casting
away 'const'" warnings. Something like 15 of these have been around for
years and are pretty much necessary. But it seems to me that in the last
few months the number has grown to more like 50.

When I edit/compile/debug, warnings unrelated to the changes I'm making
get in the way of me checking through those that my unfinished change is
causing, so I'd like to reduce them to the minimum. I prefer not to turn
off this warning because it's often a correct diagnosis: very few of
them are necessary.

Please remember that the apparent need for any type cast is often a sign
that something else is wrong, although there are certainly cases where
they are necessary or the best solution.

Several of the old warnings among those below are related to zlib and
bdb/fs_base and some in libsvn_client.

With trunk_at_33922:

[[[
subversion/libsvn_delta/svndiff.c: In function 'zlib_decode':
subversion/libsvn_delta/svndiff.c:387: cast discards qualifiers from pointer target type

--
subversion/libsvn_subr/checksum.c: In function 'svn_checksum_clear':
subversion/libsvn_subr/checksum.c:76: cast discards qualifiers from pointer target type
subversion/libsvn_subr/checksum.c: In function 'svn_checksum_parse_hex':
subversion/libsvn_subr/checksum.c:160: cast discards qualifiers from pointer target type
subversion/libsvn_subr/checksum.c: In function 'svn_checksum_dup':
subversion/libsvn_subr/checksum.c:191: cast discards qualifiers from pointer target type
subversion/libsvn_subr/checksum.c: In function 'svn_checksum':
subversion/libsvn_subr/checksum.c:211: cast discards qualifiers from pointer target type
subversion/libsvn_subr/checksum.c:217: cast discards qualifiers from pointer target type
subversion/libsvn_subr/checksum.c: In function 'svn_checksum_empty_checksum':
subversion/libsvn_subr/checksum.c:238: cast discards qualifiers from pointer target type
subversion/libsvn_subr/checksum.c:243: cast discards qualifiers from pointer target type
subversion/libsvn_subr/checksum.c: In function 'svn_checksum_final':
subversion/libsvn_subr/checksum.c:320: cast discards qualifiers from pointer target type
subversion/libsvn_subr/checksum.c:324: cast discards qualifiers from pointer target type
--
subversion/libsvn_subr/mergeinfo.c: In function 'mergeinfo_to_stringbuf':
subversion/libsvn_subr/mergeinfo.c:1247: cast discards qualifiers from pointer target type
--
subversion/libsvn_subr/properties.c: In function 'svn_prop_has_svn_prop':
subversion/libsvn_subr/properties.c:49: cast discards qualifiers from pointer target type
--
subversion/libsvn_subr/stream.c: In function 'write_handler_gz':
subversion/libsvn_subr/stream.c:680: cast discards qualifiers from pointer target type
subversion/libsvn_subr/stream.c: In function 'close_handler_md5':
subversion/libsvn_subr/stream.c:921: cast discards qualifiers from pointer target type
subversion/libsvn_subr/stream.c:928: cast discards qualifiers from pointer target type
--
subversion/libsvn_subr/svn_base64.c: In function 'svn_base64_from_checksum':
subversion/libsvn_subr/svn_base64.c:387: cast discards qualifiers from pointer target type
--
subversion/libsvn_fs_fs/caching.c: In function 'serialize_id':
subversion/libsvn_fs_fs/caching.c:52: cast discards qualifiers from pointer target type
--
subversion/libsvn_fs_fs/fs_fs.c: In function 'purge_shared_txn_body':
subversion/libsvn_fs_fs/fs_fs.c:748: cast discards qualifiers from pointer target type
subversion/libsvn_fs_fs/fs_fs.c: In function 'purge_shared_txn':
subversion/libsvn_fs_fs/fs_fs.c:759: cast discards qualifiers from pointer target type
--
subversion/libsvn_fs_base/bdb/dbt.c: In function 'svn_fs_base__set_dbt':
subversion/libsvn_fs_base/bdb/dbt.c:58: cast discards qualifiers from pointer target type
--
subversion/libsvn_fs_base/bdb/env.c: In function 'bdb_error_gatherer':
subversion/libsvn_fs_base/bdb/env.c:208: cast discards qualifiers from pointer target type
subversion/libsvn_fs_base/bdb/env.c:220: cast discards qualifiers from pointer target type
--
subversion/libsvn_fs_base/revs-txns.c: In function 'svn_fs_base__purge_txn':
subversion/libsvn_fs_base/revs-txns.c:947: cast discards qualifiers from pointer target type
subversion/libsvn_fs_base/revs-txns.c:955: cast discards qualifiers from pointer target type
subversion/libsvn_fs_base/revs-txns.c:964: cast discards qualifiers from pointer target type
--
subversion/libsvn_fs_base/util/fs_skels.c: In function 'svn_fs_base__parse_representation_skel':
subversion/libsvn_fs_base/util/fs_skels.c:550: cast discards qualifiers from pointer target type
subversion/libsvn_fs_base/util/fs_skels.c:556: cast discards qualifiers from pointer target type
--
subversion/libsvn_fs/access.c: In function 'svn_fs_access_add_lock_token2':
subversion/libsvn_fs/access.c:85: cast discards qualifiers from pointer target type
--
subversion/libsvn_repos/fs-wrap.c: In function 'svn_repos_fs_get_mergeinfo':
subversion/libsvn_repos/fs-wrap.c:583: cast discards qualifiers from pointer target type
--
subversion/libsvn_repos/log.c: In function 'compare_rangelist_paths':
subversion/libsvn_repos/log.c:1151: cast discards qualifiers from pointer target type
subversion/libsvn_repos/log.c:1152: cast discards qualifiers from pointer target type
--
subversion/libsvn_repos/rev_hunt.c: In function 'compare_path_revisions':
subversion/libsvn_repos/rev_hunt.c:1176: cast discards qualifiers from pointer target type
subversion/libsvn_repos/rev_hunt.c:1177: cast discards qualifiers from pointer target type
--
subversion/libsvn_ra_svn/cyrus_auth.c: In function 'svn_ra_svn__enable_sasl_encryption':
subversion/libsvn_ra_svn/cyrus_auth.c:655: cast discards qualifiers from pointer target type
--
subversion/libsvn_client/add.c: In function 'mkdir_urls':
subversion/libsvn_client/add.c:737: cast discards qualifiers from pointer target type
--
subversion/libsvn_client/copy.c: In function 'wc_to_repos_copy':
subversion/libsvn_client/copy.c:1291: cast discards qualifiers from pointer target type
--
subversion/libsvn_client/delete.c: In function 'delete_urls':
subversion/libsvn_client/delete.c:201: cast discards qualifiers from pointer target type
--
subversion/libsvn_client/externals.c: In function 'resolve_relative_external_url':
subversion/libsvn_client/externals.c:654: cast discards qualifiers from pointer target type
subversion/libsvn_client/externals.c:690: cast discards qualifiers from pointer target type
--
subversion/libsvn_client/url.c: In function 'svn_client__derive_location':
subversion/libsvn_client/url.c:117: cast discards qualifiers from pointer target type
--
subversion/libsvn_wc/entries.c: In function 'read_entries':
subversion/libsvn_wc/entries.c:1364: cast discards qualifiers from pointer target type
--
subversion/libsvn_wc/props.c: In function 'combine_mergeinfo_props':
subversion/libsvn_wc/props.c:1028: cast discards qualifiers from pointer target type
subversion/libsvn_wc/props.c: In function 'combine_forked_mergeinfo_props':
subversion/libsvn_wc/props.c:1058: cast discards qualifiers from pointer target type
subversion/libsvn_wc/props.c: In function 'apply_single_mergeinfo_prop_change':
subversion/libsvn_wc/props.c:1685: cast discards qualifiers from pointer target type
--
subversion/libsvn_diff/diff_memory.c: In function 'fill_source_tokens':
subversion/libsvn_diff/diff_memory.c:212: cast discards qualifiers from pointer target type
--
subversion/libsvn_diff/util.c: In function 'svn_diff__normalize_buffer':
subversion/libsvn_diff/util.c:209: cast discards qualifiers from pointer target type
subversion/libsvn_diff/util.c:372: cast discards qualifiers from pointer target type
--
subversion/svn/diff-cmd.c: In function 'svn_cl__diff':
subversion/svn/diff-cmd.c:318: cast discards qualifiers from pointer target type
subversion/svn/diff-cmd.c:362: cast discards qualifiers from pointer target type
--
subversion/svn/util.c: In function 'svn_cl__changelist_paths':
subversion/svn/util.c:1066: cast discards qualifiers from pointer target type
--
subversion/svnserve/cyrus_auth.c: In function 'cyrus_auth_request':
subversion/svnserve/cyrus_auth.c:361: cast discards qualifiers from pointer target type
--
subversion/svnsync/main.c: In function 'change_dir_prop':
subversion/svnsync/main.c:1019: cast discards qualifiers from pointer target type
--
subversion/tests/libsvn_subr/cache-test.c: In function 'deserialize_revnum':
subversion/tests/libsvn_subr/cache-test.c:72: cast discards qualifiers from pointer target type
--
subversion/tests/libsvn_subr/target-test.c: In function 'condense_targets_tests_helper':
subversion/tests/libsvn_subr/target-test.c:62: cast discards qualifiers from pointer target type
]]]
Visibility is half the cure. To see warnings listed in this form, my
build script pipes the output of "make" to a file and then searches the
file for them (displaying also one line Before each, and deleting the
path prefix and the word "warning:"):
  grep -B1 '/subversion[^/]*/subversion/.*: warning:' |
  sed -e 's,/home/julianfoad/src/subversion[^/]*/,,' \
      -e 's/ warning: / /'
- Julian
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-10-28 13:26:51 CET

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