summaryrefslogtreecommitdiffstats
path: root/src/pacman/util.c
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/pacman/util.c
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/pacman/util.c')
-rw-r--r--src/pacman/util.c15
1 files changed, 7 insertions, 8 deletions
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);