summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-08 04:06:06 +0100
committerDan McGee <dan@archlinux.org>2011-01-08 04:15:47 +0100
commit62f5da377920c4e7823c4f8b8fb3673c9c2739e9 (patch)
tree3496e43e7161e765680daac4f0f56efe1dae754b /src
parentf966f3a8344cd96bd675c79a5c470c66920b890c (diff)
downloadpacman-62f5da377920c4e7823c4f8b8fb3673c9c2739e9.tar.gz
pacman-62f5da377920c4e7823c4f8b8fb3673c9c2739e9.tar.xz
Fix some more simple conversion "errors"
None of these warn at the normal "-Wall -Werror" level, but casts do occur that we are fine with. Make them explicit to silence some warnings when using "-Wconversion". Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/package.c2
-rw-r--r--src/pacman/pacman.c6
-rw-r--r--src/pacman/query.c8
-rw-r--r--src/pacman/sync.c2
-rw-r--r--src/pacman/util.c15
-rw-r--r--src/util/pactree.c2
6 files changed, 17 insertions, 18 deletions
diff --git a/src/pacman/package.c b/src/pacman/package.c
index 19c2daf4..66f21b14 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -242,7 +242,7 @@ void dump_pkg_changelog(pmpkg_t *pkg)
} else {
/* allocate a buffer to get the changelog back in chunks */
char buf[CLBUF_SIZE];
- int ret = 0;
+ size_t ret = 0;
while((ret = alpm_pkg_changelog_read(buf, CLBUF_SIZE, pkg, fp))) {
if(ret < CLBUF_SIZE) {
/* if we hit the end of the file, we need to add a null terminator */
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 12b3810d..c33c5804 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -461,7 +461,7 @@ static int parsearg_global(int opt)
case OP_ASK:
check_optarg();
config->noask = 1;
- config->ask = atoi(optarg);
+ config->ask = (unsigned int)atoi(optarg);
break;
case OP_CACHEDIR:
check_optarg();
@@ -483,7 +483,7 @@ static int parsearg_global(int opt)
* here, error and warning are set in config_new, though perhaps a
* --quiet option will remove these later */
if(optarg) {
- unsigned short debug = atoi(optarg);
+ unsigned short debug = (unsigned short)atoi(optarg);
switch(debug) {
case 2:
config->logmask |= PM_LOG_FUNCTION; /* fall through */
@@ -1356,7 +1356,7 @@ int main(int argc, char *argv[])
if(!isatty(fileno(stdin))) {
char line[PATH_MAX];
int i = 0;
- while(i < PATH_MAX && (line[i] = fgetc(stdin)) != EOF) {
+ while(i < PATH_MAX && (line[i] = (char)fgetc(stdin)) != EOF) {
if(isspace((unsigned char)line[i])) {
/* avoid adding zero length arg when multiple spaces separate args */
if(i > 0) {
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 04ef5e33..dea309a0 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -406,10 +406,10 @@ static int check(pmpkg_t *pkg)
}
if(!config->quiet) {
- printf(_n("%s: %d total file, ", "%s: %d total files, ", allfiles),
- pkgname, allfiles);
- printf(_n("%d missing file\n", "%d missing files\n", errors),
- errors);
+ printf(_n("%s: %d total file, ", "%s: %d total files, ",
+ (unsigned long)allfiles), pkgname, allfiles);
+ printf(_n("%d missing file\n", "%d missing files\n",
+ (unsigned long)errors), errors);
}
return(errors != 0 ? 1 : 0);
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 3b94437b..278f15e5 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -346,7 +346,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
/* print the package size with the output if ShowSize option set */
if(!config->quiet && config->showsize) {
/* Convert byte size to MB */
- double mbsize = alpm_pkg_get_size(pkg) / (1024.0 * 1024.0);
+ double mbsize = (double)alpm_pkg_get_size(pkg) / (1024.0 * 1024.0);
printf(" [%.2f MB]", mbsize);
}
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 4b53e931..4af639fd 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -275,7 +275,7 @@ char *strtoupper(char *str)
char *ptr = str;
while(*ptr) {
- (*ptr) = toupper((unsigned char)*ptr);
+ (*ptr) = (char)toupper((unsigned char)*ptr);
ptr++;
}
return str;
@@ -355,7 +355,7 @@ char *strreplace(const char *str, const char *needle, const char *replace)
q = alpm_list_getdata(i);
if(q > p){
/* add chars between this occurence and last occurence, if any */
- strncpy(newp, p, q - p);
+ strncpy(newp, p, (size_t)(q - p));
newp += q - p;
}
strncpy(newp, replace, replacesz);
@@ -389,7 +389,7 @@ alpm_list_t *strsplit(const char *str, const char splitchar)
char *dup = NULL;
while((str = strchr(str, splitchar))) {
- dup = strndup(prev, str - prev);
+ dup = strndup(prev, (size_t)(str - prev));
if(dup == NULL) {
return(NULL);
}
@@ -528,8 +528,7 @@ void display_targets(const alpm_list_t *pkgs, int install)
/* print the package size with the output if ShowSize option set */
if(config->showsize) {
- double mbsize = 0.0;
- mbsize = alpm_pkg_get_size(pkg) / (1024.0 * 1024.0);
+ double mbsize = (double)alpm_pkg_get_size(pkg) / (1024.0 * 1024.0);
pm_asprintf(&str, "%s-%s [%.2f MB]", alpm_pkg_get_name(pkg),
alpm_pkg_get_version(pkg), mbsize);
@@ -541,8 +540,8 @@ void display_targets(const alpm_list_t *pkgs, int install)
}
/* Convert byte sizes to MB */
- mbdlsize = dlsize / (1024.0 * 1024.0);
- mbisize = isize / (1024.0 * 1024.0);
+ mbdlsize = (double)dlsize / (1024.0 * 1024.0);
+ mbisize = (double)isize / (1024.0 * 1024.0);
if(install) {
pm_asprintf(&str, _("Targets (%d):"), alpm_list_count(targets));
@@ -646,7 +645,7 @@ void print_packages(const alpm_list_t *packages)
if(strstr(temp,"%s")) {
char *size;
double mbsize = 0.0;
- mbsize = pkg_get_size(pkg) / (1024.0 * 1024.0);
+ mbsize = (double)pkg_get_size(pkg) / (1024.0 * 1024.0);
pm_asprintf(&size, "%.2f", mbsize);
string = strreplace(temp, "%s", size);
free(size);
diff --git a/src/util/pactree.c b/src/util/pactree.c
index 3267e3d1..0ac3f246 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -116,7 +116,7 @@ static int parse_options(int argc, char *argv[])
break;
case 'd':
/* validate depth */
- max_depth = strtol(optarg, &endptr, 10);
+ max_depth = (int)strtol(optarg, &endptr, 10);
if(*endptr != '\0') {
fprintf(stderr, "error: invalid depth -- %s\n", optarg);
return 1;