Hide private functions from createrepo_c library #407
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The library exported 274 symbols. However, many of them were not declared in any public header file, hence application were not supposed to use them. In other words, the library offered functions which were not part of an API. That was not good because:
These private functions enlarged an attack surface. These private functions polluted binary interface and triggered warnigs by ABI checkers (e.g. when libXML-2.12.0 changed xmlParserCtxt structure).
These private functions could fool a user into calling them and that would increase a pressure on broadening createrepo_c API.
I reviewed all the 274 symbols and hid 52 of them:
cr_char_handler
cr_cktype_from_zck
cr_db_add_filelists_pkg
cr_db_add_other_pkg
cr_db_add_primary_pkg
cr_db_destroy_filelists_statements
cr_db_destroy_other_statements
cr_db_destroy_primary_statements
cr_db_prepare_filelists_statements
cr_db_prepare_other_statements
cr_db_prepare_primary_statements
cr_destroy_metadata_hashtable
cr_free_values
cr_get_compressed_content_stat
cr_new_metadata_hashtable
cr_newpkgcb
cr_package_copy_into
cr_prestodeltatask_free
cr_remove_dir_cb
cr_xml_dump_delta
cr_xml_dump_filelists_chunk
cr_xml_dump_filelists_items
cr_xml_dump_files
cr_xml_dump_int
cr_xml_dump_other_changelog
cr_xml_dump_other_items
cr_xml_dump_repomd_body
cr_xml_dump_repomd_record
cr_xml_dump_updatecollectionmodule
cr_xml_dump_updatecollectionpackages
cr_xml_dump_updateinfo_body
cr_xml_dump_updateinforecord_internal
cr_xml_dump_updateinforecord_pkglist
cr_xml_dump_updateinforecord_references
cr_xmlfile_write_xml_footer
cr_xmlfile_write_xml_header
cr_xmlNewProp
cr_xmlNewTextChild
cr_xml_parse_filelists_internal
cr_xml_parse_other_internal
cr_xml_parse_primary_internal
cr_xml_parser_data
cr_xml_parser_data_free
cr_xml_parser_generic
cr_xml_parser_generic_from_string
cr_xml_parser_strtoll
cr_xml_parser_warning
filelists_parser_data_new
other_parser_data_new
prepare_split_media_baseurl
primary_parser_data_new
unescape_ampersand_from_values
I kept these 10 private symbols because they are called either from createrepo_c program or from a Python binding:
cr_compress_groupfile
cr_delayed_dump_run
cr_delayed_dump_set
cr_distrotag_new
cr_dumper_thread
cr_metadata_load_modulemd
cr_metadata_modulemd
cr_repomd_compare
cr_xml_dump_primary_base_items
cr_xml_dump_primary_dump_pco
This patch minimizes a symbol table by making the private functions static or by setting their visibility to a hidden state. As result, they disappear from the library binary interface.