1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-23 00:08:50 -05:00

int typing: s/unsigned short/int/ in libalpm

After our recent screwup with size_t and ssize_t in the download code, I
found the `-Wsign-conversion` flag to GCC to see if we were doing anything
else boneheaded. I didn't find anything quite as bad, but we did have some
goofups- most of our public unsigned methods would return -1 on error, which
is a bit odd in an unsigned context.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2009-10-11 13:51:47 -05:00
parent cf0d619670
commit 35dc9b0314
10 changed files with 23 additions and 25 deletions

View File

@ -128,8 +128,8 @@ int alpm_option_set_logfile(const char *logfile);
const char *alpm_option_get_lockfile(); const char *alpm_option_get_lockfile();
/* no set_lockfile, path is determined from dbpath */ /* no set_lockfile, path is determined from dbpath */
unsigned short alpm_option_get_usesyslog(); int alpm_option_get_usesyslog();
void alpm_option_set_usesyslog(unsigned short usesyslog); void alpm_option_set_usesyslog(int usesyslog);
alpm_list_t *alpm_option_get_noupgrades(); alpm_list_t *alpm_option_get_noupgrades();
void alpm_option_add_noupgrade(const char *pkg); void alpm_option_add_noupgrade(const char *pkg);
@ -154,7 +154,7 @@ int alpm_option_remove_ignoregrp(const char *grp);
const char *alpm_option_get_arch(); const char *alpm_option_get_arch();
void alpm_option_set_arch(const char *arch); void alpm_option_set_arch(const char *arch);
void alpm_option_set_usedelta(unsigned short usedelta); void alpm_option_set_usedelta(int usedelta);
pmdb_t *alpm_option_get_localdb(); pmdb_t *alpm_option_get_localdb();
alpm_list_t *alpm_option_get_syncdbs(); alpm_list_t *alpm_option_get_syncdbs();
@ -195,7 +195,7 @@ typedef enum _pmpkgreason_t {
PM_PKG_REASON_DEPEND = 1 /* installed as a dependency for another package */ PM_PKG_REASON_DEPEND = 1 /* installed as a dependency for another package */
} pmpkgreason_t; } pmpkgreason_t;
int alpm_pkg_load(const char *filename, unsigned short full, pmpkg_t **pkg); int alpm_pkg_load(const char *filename, int full, pmpkg_t **pkg);
int alpm_pkg_free(pmpkg_t *pkg); int alpm_pkg_free(pmpkg_t *pkg);
int alpm_pkg_checkmd5sum(pmpkg_t *pkg); int alpm_pkg_checkmd5sum(pmpkg_t *pkg);
char *alpm_fetch_pkgurl(const char *url); char *alpm_fetch_pkgurl(const char *url);
@ -231,8 +231,8 @@ size_t alpm_pkg_changelog_read(void *ptr, size_t size,
const pmpkg_t *pkg, const void *fp); const pmpkg_t *pkg, const void *fp);
/*int alpm_pkg_changelog_feof(const pmpkg_t *pkg, void *fp);*/ /*int alpm_pkg_changelog_feof(const pmpkg_t *pkg, void *fp);*/
int alpm_pkg_changelog_close(const pmpkg_t *pkg, void *fp); int alpm_pkg_changelog_close(const pmpkg_t *pkg, void *fp);
unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg); int alpm_pkg_has_scriptlet(pmpkg_t *pkg);
unsigned short alpm_pkg_has_force(pmpkg_t *pkg); int alpm_pkg_has_force(pmpkg_t *pkg);
off_t alpm_pkg_download_size(pmpkg_t *newpkg); off_t alpm_pkg_download_size(pmpkg_t *newpkg);

View File

@ -132,7 +132,7 @@ static int parse_descfile(struct archive *a, pmpkg_t *newpkg)
* through the full archive * through the full archive
* @return An information filled pmpkg_t struct * @return An information filled pmpkg_t struct
*/ */
static pmpkg_t *pkg_load(const char *pkgfile, unsigned short full) static pmpkg_t *pkg_load(const char *pkgfile, int full)
{ {
int ret = ARCHIVE_OK; int ret = ARCHIVE_OK;
int config = 0; int config = 0;
@ -269,8 +269,7 @@ error:
* @param pkg address of the package pointer * @param pkg address of the package pointer
* @return 0 on success, -1 on error (pm_errno is set accordingly) * @return 0 on success, -1 on error (pm_errno is set accordingly)
*/ */
int SYMEXPORT alpm_pkg_load(const char *filename, unsigned short full, int SYMEXPORT alpm_pkg_load(const char *filename, int full, pmpkg_t **pkg)
pmpkg_t **pkg)
{ {
ALPM_LOG_FUNC; ALPM_LOG_FUNC;

View File

@ -323,7 +323,7 @@ alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles)
/** @} */ /** @} */
static pmdb_t *_alpm_db_new(const char *treename, unsigned short is_local) static pmdb_t *_alpm_db_new(const char *treename, int is_local)
{ {
pmdb_t *db; pmdb_t *db;

View File

@ -43,9 +43,9 @@ struct __pmdb_t {
char *treename; char *treename;
/* do not access directly, use _alpm_db_path(db) for lazy access */ /* do not access directly, use _alpm_db_path(db) for lazy access */
char *_path; char *_path;
unsigned short pkgcache_loaded; int pkgcache_loaded;
unsigned short grpcache_loaded; int grpcache_loaded;
unsigned short is_local; int is_local;
alpm_list_t *pkgcache; alpm_list_t *pkgcache;
alpm_list_t *grpcache; alpm_list_t *grpcache;
alpm_list_t *servers; alpm_list_t *servers;

View File

@ -169,7 +169,7 @@ const char SYMEXPORT *alpm_option_get_lockfile()
return handle->lockfile; return handle->lockfile;
} }
unsigned short SYMEXPORT alpm_option_get_usesyslog() int SYMEXPORT alpm_option_get_usesyslog()
{ {
if (handle == NULL) { if (handle == NULL) {
pm_errno = PM_ERR_HANDLE_NULL; pm_errno = PM_ERR_HANDLE_NULL;
@ -437,7 +437,7 @@ int SYMEXPORT alpm_option_set_logfile(const char *logfile)
return(0); return(0);
} }
void SYMEXPORT alpm_option_set_usesyslog(unsigned short usesyslog) void SYMEXPORT alpm_option_set_usesyslog(int usesyslog)
{ {
handle->usesyslog = usesyslog; handle->usesyslog = usesyslog;
} }
@ -536,7 +536,7 @@ void SYMEXPORT alpm_option_set_arch(const char *arch)
if(arch) handle->arch = strdup(arch); if(arch) handle->arch = strdup(arch);
} }
void SYMEXPORT alpm_option_set_usedelta(unsigned short usedelta) void SYMEXPORT alpm_option_set_usedelta(int usedelta)
{ {
handle->usedelta = usedelta; handle->usedelta = usedelta;
} }

View File

@ -57,9 +57,9 @@ typedef struct _pmhandle_t {
alpm_list_t *ignoregrp; /* List of groups to ignore */ alpm_list_t *ignoregrp; /* List of groups to ignore */
/* options */ /* options */
unsigned short usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */ int usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */
char *arch; /* Architecture of packages we should allow */ char *arch; /* Architecture of packages we should allow */
unsigned short usedelta; /* Download deltas if possible */ int usedelta; /* Download deltas if possible */
} pmhandle_t; } pmhandle_t;
/* global handle variable */ /* global handle variable */

View File

@ -295,7 +295,7 @@ alpm_list_t SYMEXPORT *alpm_pkg_get_groups(pmpkg_t *pkg)
return pkg->groups; return pkg->groups;
} }
unsigned short SYMEXPORT alpm_pkg_has_force(pmpkg_t *pkg) int SYMEXPORT alpm_pkg_has_force(pmpkg_t *pkg)
{ {
ALPM_LOG_FUNC; ALPM_LOG_FUNC;
@ -541,7 +541,7 @@ int SYMEXPORT alpm_pkg_changelog_close(const pmpkg_t *pkg, void *fp)
return(ret); return(ret);
} }
unsigned short SYMEXPORT alpm_pkg_has_scriptlet(pmpkg_t *pkg) int SYMEXPORT alpm_pkg_has_scriptlet(pmpkg_t *pkg)
{ {
ALPM_LOG_FUNC; ALPM_LOG_FUNC;

View File

@ -49,8 +49,8 @@ struct __pmpkg_t {
off_t size; off_t size;
off_t isize; off_t isize;
off_t download_size; off_t download_size;
unsigned short scriptlet; int scriptlet;
unsigned short force; int force;
pmpkgreason_t reason; pmpkgreason_t reason;
alpm_list_t *licenses; alpm_list_t *licenses;
alpm_list_t *replaces; alpm_list_t *replaces;

View File

@ -380,8 +380,7 @@ int _alpm_rmrf(const char *path)
return(0); return(0);
} }
int _alpm_logaction(unsigned short usesyslog, FILE *f, int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args)
const char *fmt, va_list args)
{ {
int ret = 0; int ret = 0;

View File

@ -64,7 +64,7 @@ int _alpm_lckmk();
int _alpm_lckrm(); int _alpm_lckrm();
int _alpm_unpack(const char *archive, const char *prefix, const char *fn); int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
int _alpm_rmrf(const char *path); int _alpm_rmrf(const char *path);
int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *fmt, va_list args); int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args);
int _alpm_run_chroot(const char *root, const char *cmd); int _alpm_run_chroot(const char *root, const char *cmd);
int _alpm_ldconfig(const char *root); int _alpm_ldconfig(const char *root);
int _alpm_str_cmp(const void *s1, const void *s2); int _alpm_str_cmp(const void *s1, const void *s2);