[pacman-dev] [PATCH] Declare all local functions static

Allan McRae allan at archlinux.org
Sat Dec 18 10:58:45 EST 2010


All functions that are limited to the local translation unit are
declared static.  This exposed that the _pkg_get_deltas declaration
in be_local.c was being satified by the function in packages.c which
when declared static caused linker failures.

Fixes all warnings with -Wmissing-{declarations,prototypes}.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 lib/libalpm/be_local.c   |   62 ++++++++++++++++++++++++---------------------
 lib/libalpm/be_package.c |    8 +++---
 lib/libalpm/package.c    |   52 +++++++++++++++++++-------------------
 src/pacman/pacman.c      |    2 +-
 src/util/cleanupdelta.c  |    2 +-
 src/util/testdb.c        |    2 +-
 src/util/testpkg.c       |    2 +-
 7 files changed, 67 insertions(+), 63 deletions(-)

diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 22a56bd..0daa9be 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -67,13 +67,13 @@
  * initialized.
  */
 
-const char *_cache_get_filename(pmpkg_t *pkg)
+static const char *_cache_get_filename(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, NULL);
 	return pkg->filename;
 }
 
-const char *_cache_get_name(pmpkg_t *pkg)
+static const char *_cache_get_name(pmpkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return(NULL));
 	return pkg->name;
@@ -91,79 +91,79 @@ static const char *_cache_get_desc(pmpkg_t *pkg)
 	return pkg->desc;
 }
 
-const char *_cache_get_url(pmpkg_t *pkg)
+static const char *_cache_get_url(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, NULL);
 	return pkg->url;
 }
 
-time_t _cache_get_builddate(pmpkg_t *pkg)
+static time_t _cache_get_builddate(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, 0);
 	return pkg->builddate;
 }
 
-time_t _cache_get_installdate(pmpkg_t *pkg)
+static time_t _cache_get_installdate(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, 0);
 	return pkg->installdate;
 }
 
-const char *_cache_get_packager(pmpkg_t *pkg)
+static const char *_cache_get_packager(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, NULL);
 	return pkg->packager;
 }
 
-const char *_cache_get_md5sum(pmpkg_t *pkg)
+static const char *_cache_get_md5sum(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, NULL);
 	return pkg->md5sum;
 }
 
-const char *_cache_get_arch(pmpkg_t *pkg)
+static const char *_cache_get_arch(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, NULL);
 	return pkg->arch;
 }
 
-off_t _cache_get_size(pmpkg_t *pkg)
+static off_t _cache_get_size(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, -1);
 	return pkg->size;
 }
 
-off_t _cache_get_isize(pmpkg_t *pkg)
+static off_t _cache_get_isize(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, -1);
 	return pkg->isize;
 }
 
-pmpkgreason_t _cache_get_reason(pmpkg_t *pkg)
+static pmpkgreason_t _cache_get_reason(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, -1);
 	return pkg->reason;
 }
 
-alpm_list_t *_cache_get_licenses(pmpkg_t *pkg)
+static alpm_list_t *_cache_get_licenses(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, NULL);
 	return pkg->licenses;
 }
 
-alpm_list_t *_cache_get_groups(pmpkg_t *pkg)
+static alpm_list_t *_cache_get_groups(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, NULL);
 	return pkg->groups;
 }
 
-int _cache_get_epoch(pmpkg_t *pkg)
+static int _cache_get_epoch(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, -1);
 	return pkg->epoch;
 }
 
-int _cache_has_scriptlet(pmpkg_t *pkg)
+static int _cache_has_scriptlet(pmpkg_t *pkg)
 {
 	ALPM_LOG_FUNC;
 
@@ -177,37 +177,43 @@ int _cache_has_scriptlet(pmpkg_t *pkg)
 	return pkg->scriptlet;
 }
 
-alpm_list_t *_cache_get_depends(pmpkg_t *pkg)
+static alpm_list_t *_cache_get_depends(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, NULL);
 	return pkg->depends;
 }
 
-alpm_list_t *_cache_get_optdepends(pmpkg_t *pkg)
+static alpm_list_t *_cache_get_optdepends(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, NULL);
 	return pkg->optdepends;
 }
 
-alpm_list_t *_cache_get_conflicts(pmpkg_t *pkg)
+static alpm_list_t *_cache_get_conflicts(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, NULL);
 	return pkg->conflicts;
 }
 
-alpm_list_t *_cache_get_provides(pmpkg_t *pkg)
+static alpm_list_t *_cache_get_provides(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, NULL);
 	return pkg->provides;
 }
 
-alpm_list_t *_cache_get_replaces(pmpkg_t *pkg)
+static alpm_list_t *_cache_get_replaces(pmpkg_t *pkg)
 {
 	LAZY_LOAD(INFRQ_DESC, NULL);
 	return pkg->replaces;
 }
 
-alpm_list_t *_cache_get_files(pmpkg_t *pkg)
+/* local packages can not have deltas */
+static alpm_list_t *_cache_get_deltas(pmpkg_t *pkg)
+{
+	return NULL;
+}
+
+static alpm_list_t *_cache_get_files(pmpkg_t *pkg)
 {
 	ALPM_LOG_FUNC;
 
@@ -222,7 +228,7 @@ alpm_list_t *_cache_get_files(pmpkg_t *pkg)
 	return pkg->files;
 }
 
-alpm_list_t *_cache_get_backup(pmpkg_t *pkg)
+static alpm_list_t *_cache_get_backup(pmpkg_t *pkg)
 {
 	ALPM_LOG_FUNC;
 
@@ -243,7 +249,7 @@ alpm_list_t *_cache_get_backup(pmpkg_t *pkg)
  * @param pkg the package (from db) to read the changelog
  * @return a 'file stream' to the package changelog
  */
-void *_cache_changelog_open(pmpkg_t *pkg)
+static void *_cache_changelog_open(pmpkg_t *pkg)
 {
 	ALPM_LOG_FUNC;
 
@@ -269,14 +275,14 @@ void *_cache_changelog_open(pmpkg_t *pkg)
  * @param fp a 'file stream' to the package changelog
  * @return the number of characters read, or 0 if there is no more data
  */
-size_t _cache_changelog_read(void *ptr, size_t size,
+static size_t _cache_changelog_read(void *ptr, size_t size,
 		const pmpkg_t *pkg, const void *fp)
 {
 	return ( fread(ptr, 1, size, (FILE*)fp) );
 }
 
 /*
-int _cache_changelog_feof(const pmpkg_t *pkg, void *fp)
+static int _cache_changelog_feof(const pmpkg_t *pkg, void *fp)
 {
 	return( feof((FILE*)fp) );
 }
@@ -289,13 +295,11 @@ int _cache_changelog_feof(const pmpkg_t *pkg, void *fp)
  * @param fp a 'file stream' to the package changelog
  * @return whether closing the package changelog stream was successful
  */
-int _cache_changelog_close(const pmpkg_t *pkg, void *fp)
+static int _cache_changelog_close(const pmpkg_t *pkg, void *fp)
 {
 	return( fclose((FILE*)fp) );
 }
 
-/* We're cheating, local packages can't have deltas anyway. */
-alpm_list_t *_pkg_get_deltas(pmpkg_t *pkg);
 
 /** The local database operations struct. Get package fields through
  * lazy accessor methods that handle any backend loading and caching
@@ -324,7 +328,7 @@ static struct pkg_operations local_pkg_ops = {
 	.get_conflicts   = _cache_get_conflicts,
 	.get_provides    = _cache_get_provides,
 	.get_replaces    = _cache_get_replaces,
-	.get_deltas      = _pkg_get_deltas,
+	.get_deltas      = _cache_get_deltas,
 	.get_files       = _cache_get_files,
 	.get_backup      = _cache_get_backup,
 
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 6426fe9..4ce0d9c 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -45,7 +45,7 @@
  * @param pkg the package (file) to read the changelog
  * @return a 'file stream' to the package changelog
  */
-void *_package_changelog_open(pmpkg_t *pkg)
+static void *_package_changelog_open(pmpkg_t *pkg)
 {
 	ALPM_LOG_FUNC;
 
@@ -90,7 +90,7 @@ void *_package_changelog_open(pmpkg_t *pkg)
  * @param fp a 'file stream' to the package changelog
  * @return the number of characters read, or 0 if there is no more data
  */
-size_t _package_changelog_read(void *ptr, size_t size,
+static size_t _package_changelog_read(void *ptr, size_t size,
 		const pmpkg_t *pkg, const void *fp)
 {
 	ssize_t sret = archive_read_data((struct archive*)fp, ptr, size);
@@ -104,7 +104,7 @@ size_t _package_changelog_read(void *ptr, size_t size,
 }
 
 /*
-int _package_changelog_feof(const pmpkg_t *pkg, void *fp)
+static int _package_changelog_feof(const pmpkg_t *pkg, void *fp)
 {
 	// note: this doesn't quite work, no feof in libarchive
 	return( archive_read_data((struct archive*)fp, NULL, 0) );
@@ -118,7 +118,7 @@ int _package_changelog_feof(const pmpkg_t *pkg, void *fp)
  * @param fp a 'file stream' to the package changelog
  * @return whether closing the package changelog stream was successful
  */
-int _package_changelog_close(const pmpkg_t *pkg, void *fp)
+static int _package_changelog_close(const pmpkg_t *pkg, void *fp)
 {
 	return( archive_read_finish((struct archive *)fp) );
 }
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index edfb7bd..332a082 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -97,32 +97,32 @@ int SYMEXPORT alpm_pkg_checkmd5sum(pmpkg_t *pkg)
  * backend logic that needs lazy access, such as the local database through
  * a lazy-load cache. However, the defaults will work just fine for fully-
  * populated package structures. */
-const char *_pkg_get_filename(pmpkg_t *pkg)    { return pkg->filename; }
-const char *_pkg_get_name(pmpkg_t *pkg)        { return pkg->name; }
-const char *_pkg_get_version(pmpkg_t *pkg)     { return pkg->version; }
-const char *_pkg_get_desc(pmpkg_t *pkg)        { return pkg->desc; }
-const char *_pkg_get_url(pmpkg_t *pkg)         { return pkg->url; }
-time_t _pkg_get_builddate(pmpkg_t *pkg)        { return pkg->builddate; }
-time_t _pkg_get_installdate(pmpkg_t *pkg)      { return pkg->installdate; }
-const char *_pkg_get_packager(pmpkg_t *pkg)    { return pkg->packager; }
-const char *_pkg_get_md5sum(pmpkg_t *pkg)      { return pkg->md5sum; }
-const char *_pkg_get_arch(pmpkg_t *pkg)        { return pkg->arch; }
-off_t _pkg_get_size(pmpkg_t *pkg)              { return pkg->size; }
-off_t _pkg_get_isize(pmpkg_t *pkg)             { return pkg->isize; }
-pmpkgreason_t _pkg_get_reason(pmpkg_t *pkg)    { return pkg->reason; }
-int _pkg_get_epoch(pmpkg_t *pkg)               { return pkg->epoch; }
-int _pkg_has_scriptlet(pmpkg_t *pkg)           { return pkg->scriptlet; }
-
-alpm_list_t *_pkg_get_licenses(pmpkg_t *pkg)   { return pkg->licenses; }
-alpm_list_t *_pkg_get_groups(pmpkg_t *pkg)     { return pkg->groups; }
-alpm_list_t *_pkg_get_depends(pmpkg_t *pkg)    { return pkg->depends; }
-alpm_list_t *_pkg_get_optdepends(pmpkg_t *pkg) { return pkg->optdepends; }
-alpm_list_t *_pkg_get_conflicts(pmpkg_t *pkg)  { return pkg->conflicts; }
-alpm_list_t *_pkg_get_provides(pmpkg_t *pkg)   { return pkg->provides; }
-alpm_list_t *_pkg_get_replaces(pmpkg_t *pkg)   { return pkg->replaces; }
-alpm_list_t *_pkg_get_deltas(pmpkg_t *pkg)     { return pkg->deltas; }
-alpm_list_t *_pkg_get_files(pmpkg_t *pkg)      { return pkg->files; }
-alpm_list_t *_pkg_get_backup(pmpkg_t *pkg)     { return pkg->backup; }
+static const char *_pkg_get_filename(pmpkg_t *pkg)    { return pkg->filename; }
+static const char *_pkg_get_name(pmpkg_t *pkg)        { return pkg->name; }
+static const char *_pkg_get_version(pmpkg_t *pkg)     { return pkg->version; }
+static const char *_pkg_get_desc(pmpkg_t *pkg)        { return pkg->desc; }
+static const char *_pkg_get_url(pmpkg_t *pkg)         { return pkg->url; }
+static time_t _pkg_get_builddate(pmpkg_t *pkg)        { return pkg->builddate; }
+static time_t _pkg_get_installdate(pmpkg_t *pkg)      { return pkg->installdate; }
+static const char *_pkg_get_packager(pmpkg_t *pkg)    { return pkg->packager; }
+static const char *_pkg_get_md5sum(pmpkg_t *pkg)      { return pkg->md5sum; }
+static const char *_pkg_get_arch(pmpkg_t *pkg)        { return pkg->arch; }
+static off_t _pkg_get_size(pmpkg_t *pkg)              { return pkg->size; }
+static off_t _pkg_get_isize(pmpkg_t *pkg)             { return pkg->isize; }
+static pmpkgreason_t _pkg_get_reason(pmpkg_t *pkg)    { return pkg->reason; }
+static int _pkg_get_epoch(pmpkg_t *pkg)               { return pkg->epoch; }
+static int _pkg_has_scriptlet(pmpkg_t *pkg)           { return pkg->scriptlet; }
+
+static alpm_list_t *_pkg_get_licenses(pmpkg_t *pkg)   { return pkg->licenses; }
+static alpm_list_t *_pkg_get_groups(pmpkg_t *pkg)     { return pkg->groups; }
+static alpm_list_t *_pkg_get_depends(pmpkg_t *pkg)    { return pkg->depends; }
+static alpm_list_t *_pkg_get_optdepends(pmpkg_t *pkg) { return pkg->optdepends; }
+static alpm_list_t *_pkg_get_conflicts(pmpkg_t *pkg)  { return pkg->conflicts; }
+static alpm_list_t *_pkg_get_provides(pmpkg_t *pkg)   { return pkg->provides; }
+static alpm_list_t *_pkg_get_replaces(pmpkg_t *pkg)   { return pkg->replaces; }
+static alpm_list_t *_pkg_get_deltas(pmpkg_t *pkg)     { return pkg->deltas; }
+static alpm_list_t *_pkg_get_files(pmpkg_t *pkg)      { return pkg->files; }
+static alpm_list_t *_pkg_get_backup(pmpkg_t *pkg)     { return pkg->backup; }
 
 /** The standard package operations struct. Get fields directly from the
  * struct itself with no abstraction layer or any type of lazy loading.
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 700b74d..20f44b7 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -846,7 +846,7 @@ static char *get_tempfile(const char *path, const char *filename) {
 }
 
 /** External fetch callback */
-int download_with_xfercommand(const char *url, const char *localpath,
+static int download_with_xfercommand(const char *url, const char *localpath,
 		int force) {
 	int ret = 0;
 	int retval;
diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c
index 2010282..a2d1541 100644
--- a/src/util/cleanupdelta.c
+++ b/src/util/cleanupdelta.c
@@ -37,7 +37,7 @@ static void cleanup(int signum) {
 	exit(signum);
 }
 
-void output_cb(pmloglevel_t level, char *fmt, va_list args)
+static void output_cb(pmloglevel_t level, char *fmt, va_list args)
 {
 	if(strlen(fmt)) {
 		switch(level) {
diff --git a/src/util/testdb.c b/src/util/testdb.c
index f77583a..07046b0 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -40,7 +40,7 @@ static void cleanup(int signum) {
 	exit(signum);
 }
 
-void output_cb(pmloglevel_t level, char *fmt, va_list args)
+static void output_cb(pmloglevel_t level, char *fmt, va_list args)
 {
 	if(strlen(fmt)) {
 		switch(level) {
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index 6fc0ce0..0dd8db8 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -24,7 +24,7 @@
 
 #define BASENAME "testpkg"
 
-void output_cb(pmloglevel_t level, char *fmt, va_list args)
+static void output_cb(pmloglevel_t level, char *fmt, va_list args)
 {
 	if(fmt[0] == '\0') {
 		return;
-- 
1.7.3.3



More information about the pacman-dev mailing list