index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | lib/libalpm/add.c | 92 | ||||
-rw-r--r-- | lib/libalpm/alpm.h | 16 | ||||
-rw-r--r-- | lib/libalpm/alpm_list.c | 13 | ||||
-rw-r--r-- | lib/libalpm/alpm_list.h | 1 | ||||
-rw-r--r-- | lib/libalpm/be_local.c | 9 | ||||
-rw-r--r-- | lib/libalpm/db.h | 2 | ||||
-rw-r--r-- | lib/libalpm/diskspace.c | 40 | ||||
-rw-r--r-- | lib/libalpm/dload.h | 2 | ||||
-rw-r--r-- | lib/libalpm/package.c | 10 | ||||
-rw-r--r-- | lib/libalpm/package.h | 9 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 4 | ||||
-rw-r--r-- | lib/libalpm/util.c | 59 | ||||
-rw-r--r-- | lib/libalpm/util.h | 5 | ||||
-rw-r--r-- | scripts/pacman-optimize.sh.in | 2 | ||||
-rw-r--r-- | scripts/repo-add.sh.in | 2 | ||||
-rw-r--r-- | src/pacman/callback.c | 1 | ||||
-rw-r--r-- | src/pacman/conf.c | 2 | ||||
-rw-r--r-- | src/pacman/deptest.c | 4 | ||||
-rw-r--r-- | src/pacman/package.c | 9 | ||||
-rw-r--r-- | src/pacman/pacman.c | 4 | ||||
-rw-r--r-- | src/pacman/query.c | 26 | ||||
-rw-r--r-- | src/pacman/remove.c | 10 | ||||
-rw-r--r-- | src/pacman/sync.c | 66 | ||||
-rw-r--r-- | src/pacman/upgrade.c | 2 | ||||
-rw-r--r-- | src/pacman/util.c | 34 | ||||
-rw-r--r-- | src/util/cleanupdelta.c | 6 | ||||
-rw-r--r-- | src/util/pactree.c | 6 | ||||
-rw-r--r-- | src/util/testdb.c | 6 |
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 653d2bd9..2ef41782 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -22,7 +22,6 @@ #include <stdlib.h> #include <errno.h> -#include <time.h> #include <string.h> #include <limits.h> #include <fcntl.h> @@ -132,6 +131,18 @@ static int perform_extraction(alpm_handle_t *handle, struct archive *archive, return 0; } +static int try_rename(alpm_handle_t *handle, const char *src, const char *dest) +{ + if(rename(src, dest)) { + _alpm_log(handle, ALPM_LOG_ERROR, _("could not rename %s to %s (%s)\n"), + src, dest, strerror(errno)); + alpm_logaction(handle, "error: could not rename %s to %s (%s)\n", + src, dest, strerror(errno)); + return 1; + } + return 0; +} + static int extract_single_file(alpm_handle_t *handle, struct archive *archive, struct archive_entry *entry, alpm_pkg_t *newpkg, alpm_pkg_t *oldpkg) { @@ -146,8 +157,6 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, entryname = archive_entry_pathname(entry); entrymode = archive_entry_mode(entry); - memset(filename, 0, PATH_MAX); /* just to be sure */ - if(strcmp(entryname, ".INSTALL") == 0) { /* the install script goes inside the db */ snprintf(filename, PATH_MAX, "%s%s-%s/install", @@ -282,17 +291,18 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, STRDUP(entryname_orig, entryname, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); if(needbackup) { - char checkfile[PATH_MAX]; + char *checkfile; char *hash_local = NULL, *hash_pkg = NULL; - int ret; + size_t len; - snprintf(checkfile, PATH_MAX, "%s.paccheck", filename); + len = strlen(filename) + 10; + MALLOC(checkfile, len, + errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup); + snprintf(checkfile, len, "%s.paccheck", filename); - ret = perform_extraction(handle, archive, entry, checkfile, entryname_orig); - if(ret == 1) { - /* error */ - FREE(entryname_orig); - return 1; + if(perform_extraction(handle, archive, entry, checkfile, entryname_orig)) { + errors++; + goto needbackup_cleanup; } hash_local = alpm_compute_md5sum(filename); @@ -320,29 +330,26 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, if(hash_local && hash_pkg && strcmp(hash_local, hash_pkg) != 0) { /* looks like we have a local file that has a different hash as the * file in the package, move it to a .pacorig */ - char newpath[PATH_MAX]; - snprintf(newpath, PATH_MAX, "%s.pacorig", filename); + char *newpath; + size_t newlen = strlen(filename) + 9; + MALLOC(newpath, newlen, + errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup); + snprintf(newpath, newlen, "%s.pacorig", filename); /* move the existing file to the "pacorig" */ - if(rename(filename, newpath)) { - _alpm_log(handle, ALPM_LOG_ERROR, _("could not rename %s to %s (%s)\n"), - filename, newpath, strerror(errno)); - alpm_logaction(handle, "error: could not rename %s to %s (%s)\n", - filename, newpath, strerror(errno)); + if(try_rename(handle, filename, newpath)) { + errors++; errors++; } else { /* rename the file we extracted to the real name */ - if(rename(checkfile, filename)) { - _alpm_log(handle, ALPM_LOG_ERROR, _("could not rename %s to %s (%s)\n"), - checkfile, filename, strerror(errno)); - alpm_logaction(handle, "error: could not rename %s to %s (%s)\n", - checkfile, filename, strerror(errno)); + if(try_rename(handle, checkfile, filename)) { errors++; } else { _alpm_log(handle, ALPM_LOG_WARNING, _("%s saved as %s\n"), filename, newpath); alpm_logaction(handle, "warning: %s saved as %s\n", filename, newpath); } } + free(newpath); } else { /* local file is identical to pkg one, so just remove pkg one */ unlink(checkfile); @@ -356,11 +363,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, _alpm_log(handle, ALPM_LOG_DEBUG, "action: installing new file: %s\n", entryname_orig); - if(rename(checkfile, filename)) { - _alpm_log(handle, ALPM_LOG_ERROR, _("could not rename %s to %s (%s)\n"), - checkfile, filename, strerror(errno)); - alpm_logaction(handle, "error: could not rename %s to %s (%s)\n", - checkfile, filename, strerror(errno)); + if(try_rename(handle, checkfile, filename)) { errors++; } } else { @@ -382,29 +385,30 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, _alpm_log(handle, ALPM_LOG_DEBUG, "action: leaving existing file in place\n"); unlink(checkfile); } else { - char newpath[PATH_MAX]; + char *newpath; + size_t newlen = strlen(filename) + 8; _alpm_log(handle, ALPM_LOG_DEBUG, "action: keeping current file and installing" " new one with .pacnew ending\n"); - snprintf(newpath, PATH_MAX, "%s.pacnew", filename); - if(rename(checkfile, newpath)) { - _alpm_log(handle, ALPM_LOG_ERROR, _("could not install %s as %s (%s)\n"), - filename, newpath, strerror(errno)); - alpm_logaction(handle, "error: could not install %s as %s (%s)\n", - filename, newpath, strerror(errno)); + MALLOC(newpath, newlen, + errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup); + snprintf(newpath, newlen, "%s.pacnew", filename); + if(try_rename(handle, checkfile, newpath)) { + errors++; } else { _alpm_log(handle, ALPM_LOG_WARNING, _("%s installed as %s\n"), filename, newpath); alpm_logaction(handle, "warning: %s installed as %s\n", filename, newpath); } + free(newpath); } } - FREE(hash_local); - FREE(hash_pkg); +needbackup_cleanup: + free(checkfile); + free(hash_local); + free(hash_pkg); } else { - int ret; - /* we didn't need a backup */ if(notouch) { /* change the path to a .pacnew extension */ @@ -423,11 +427,11 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, unlink(filename); } - ret = perform_extraction(handle, archive, entry, filename, entryname_orig); - if(ret == 1) { + if(perform_extraction(handle, archive, entry, filename, entryname_orig)) { /* error */ - FREE(entryname_orig); - return 1; + free(entryname_orig); + errors++; + return errors; } /* calculate an hash if this is in newpkg's backup */ @@ -444,7 +448,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, backup->hash = newhash; } } - FREE(entryname_orig); + free(entryname_orig); return errors; } diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index a93d4e3e..9fda9406 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -27,9 +27,9 @@ extern "C" { #endif -#include <sys/types.h> /* for off_t */ -#include <time.h> /* for time_t */ -#include <stdarg.h> /* for va_list */ +#include <inttypes.h> /* int64_t */ +#include <sys/types.h> /* off_t */ +#include <stdarg.h> /* va_list */ #include <alpm_list.h> @@ -44,6 +44,8 @@ extern "C" { * @{ */ +typedef int64_t alpm_time_t; + /* * Enumerations * These ones are used in multiple contexts, so are forward-declared. @@ -222,8 +224,8 @@ typedef struct _alpm_pgpkey_t { char *uid; char *name; char *email; - time_t created; - time_t expires; + alpm_time_t created; + alpm_time_t expires; } alpm_pgpkey_t; /** Signature result. Contains the key, status, and validity of a given @@ -754,13 +756,13 @@ const char *alpm_pkg_get_url(alpm_pkg_t *pkg); * @param pkg a pointer to package * @return the timestamp of the build time */ -time_t alpm_pkg_get_builddate(alpm_pkg_t *pkg); +alpm_time_t alpm_pkg_get_builddate(alpm_pkg_t *pkg); /** Returns the install timestamp of the package. * @param pkg a pointer to package * @return the timestamp of the install time */ -time_t alpm_pkg_get_installdate(alpm_pkg_t *pkg); +alpm_time_t alpm_pkg_get_installdate(alpm_pkg_t *pkg); /** Returns the packager's name. * @param pkg a pointer to package diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c index 15286aa1..cad6d096 100644 --- a/lib/libalpm/alpm_list.c +++ b/lib/libalpm/alpm_list.c @@ -576,19 +576,6 @@ alpm_list_t SYMEXPORT *alpm_list_last(const alpm_list_t *list) } } -/** - * @brief Get the data member of a list node. - * - * @param node the list node - * - * @return the contained data, or NULL if none - */ -void SYMEXPORT *alpm_list_getdata(const alpm_list_t *node) -{ - if(node == NULL) return NULL; - return node->data; -} - /* Misc */ /** diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h index cd7b0291..9f69e2c2 100644 --- a/lib/libalpm/alpm_list.h +++ b/lib/libalpm/alpm_list.h @@ -71,7 +71,6 @@ alpm_list_t *alpm_list_nth(const alpm_list_t *list, size_t n); alpm_list_t *alpm_list_next(const alpm_list_t *list); alpm_list_t *alpm_list_previous(const alpm_list_t *list); alpm_list_t *alpm_list_last(const alpm_list_t *list); -void *alpm_list_getdata(const alpm_list_t *entry); /* misc */ size_t alpm_list_count(const alpm_list_t *list); diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 56cf38bb..21d27481 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -28,7 +28,6 @@ #include <stdint.h> /* intmax_t */ #include <sys/stat.h> #include <dirent.h> -#include <time.h> #include <limits.h> /* PATH_MAX */ /* libalpm */ @@ -69,13 +68,13 @@ static const char *_cache_get_url(alpm_pkg_t *pkg) return pkg->url; } -static time_t _cache_get_builddate(alpm_pkg_t *pkg) +static alpm_time_t _cache_get_builddate(alpm_pkg_t *pkg) { LAZY_LOAD(INFRQ_DESC, 0); return pkg->builddate; } -static time_t _cache_get_installdate(alpm_pkg_t *pkg) +static alpm_time_t _cache_get_installdate(alpm_pkg_t *pkg) { LAZY_LOAD(INFRQ_DESC, 0); return pkg->installdate; @@ -794,11 +793,11 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq } if(info->builddate) { fprintf(fp, "%%BUILDDATE%%\n" - "%ld\n\n", info->builddate); + "%jd\n\n", (intmax_t)info->builddate); } if(info->installdate) { fprintf(fp, "%%INSTALLDATE%%\n" - "%ld\n\n", info->installdate); + "%jd\n\n", (intmax_t)info->installdate); } if(info->packager) { fprintf(fp, "%%PACKAGER%%\n" diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h index 224bfbeb..a1249d3e 100644 --- a/lib/libalpm/db.h +++ b/lib/libalpm/db.h @@ -22,8 +22,6 @@ #ifndef _ALPM_DB_H #define _ALPM_DB_H -#include <time.h> - /* libarchive */ #include <archive.h> #include <archive_entry.h> diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index fe2036d5..9dedbe1f 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -232,6 +232,27 @@ static int calculate_installed_size(alpm_handle_t *handle, return 0; } +static int check_mountpoint(alpm_handle_t *handle, alpm_mountpoint_t *mp) +{ + /* cushion is roughly min(5% capacity, 20MiB) */ + fsblkcnt_t fivepc = (mp->fsp.f_blocks / 20) + 1; + fsblkcnt_t twentymb = (20 * 1024 * 1024 / mp->fsp.f_bsize) + 1; + fsblkcnt_t cushion = fivepc < twentymb ? fivepc : twentymb; + blkcnt_t needed = mp->max_blocks_needed + cushion; + + _alpm_log(handle, ALPM_LOG_DEBUG, + "partition %s, needed %jd, cushion %ju, free %ju\n", + mp->mount_dir, (intmax_t)mp->max_blocks_needed, + (uintmax_t)cushion, (uintmax_t)mp->fsp.f_bfree); + if(needed >= 0 && (fsblkcnt_t)needed > mp->fsp.f_bfree) { + _alpm_log(handle, ALPM_LOG_ERROR, + _("Partition %s too full: %jd blocks needed, %jd blocks free\n"), + mp->mount_dir, (intmax_t)needed, (uintmax_t)mp->fsp.f_bfree); + return 1; + } + return 0; +} + int _alpm_check_diskspace(alpm_handle_t *handle) { alpm_list_t *mount_points, *i; @@ -300,23 +321,8 @@ int _alpm_check_diskspace(alpm_handle_t *handle) _alpm_log(handle, ALPM_LOG_ERROR, _("Partition %s is mounted read only\n"), data->mount_dir); error = 1; - } else if(data->used & USED_INSTALL) { - /* cushion is roughly min(5% capacity, 20MiB) */ - fsblkcnt_t fivepc = (data->fsp.f_blocks / 20) + 1; - fsblkcnt_t twentymb = (20 * 1024 * 1024 / data->fsp.f_bsize) + 1; - fsblkcnt_t cushion = fivepc < twentymb ? fivepc : twentymb; - blkcnt_t needed = data->max_blocks_needed + cushion; - - _alpm_log(handle, ALPM_LOG_DEBUG, - "partition %s, needed %jd, cushion %ju, free %ju\n", - data->mount_dir, (intmax_t)data->max_blocks_needed, - (uintmax_t)cushion, (uintmax_t)data->fsp.f_bfree); - if(needed >= 0 && (fsblkcnt_t)needed > data->fsp.f_bfree) { - _alpm_log(handle, ALPM_LOG_ERROR, - _("Partition %s too full: %jd blocks needed, %jd blocks free\n"), - data->mount_dir, (intmax_t)needed, (uintmax_t)data->fsp.f_bfree); - error = 1; - } + } else if(data->used & USED_INSTALL && check_mountpoint(handle, data)) { + error = 1; } } diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h index 5442c0e2..57a69f93 100644 --- a/lib/libalpm/dload.h +++ b/lib/libalpm/dload.h @@ -23,8 +23,6 @@ #include "alpm_list.h" #include "alpm.h" -#include <time.h> - struct dload_payload { alpm_handle_t *handle; const char *tempfile_openmode; diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index a5ff238f..0b0bf6e4 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -87,12 +87,12 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg) * populated package structures. */ static const char *_pkg_get_desc(alpm_pkg_t *pkg) { return pkg->desc; } static const char *_pkg_get_url(alpm_pkg_t *pkg) { return pkg->url; } -static time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate; } -static time_t _pkg_get_installdate(alpm_pkg_t *pkg) { return pkg->installdate; } +static alpm_time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate; } +static alpm_time_t _pkg_get_installdate(alpm_pkg_t *pkg) { return pkg->installdate; } static const char *_pkg_get_packager(alpm_pkg_t *pkg) { return pkg->packager; } static const char *_pkg_get_arch(alpm_pkg_t *pkg) { return pkg->arch; } static off_t _pkg_get_isize(alpm_pkg_t *pkg) { return pkg->isize; } -static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; } +static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; } static int _pkg_has_scriptlet(alpm_pkg_t *pkg) { return pkg->scriptlet; } static alpm_list_t *_pkg_get_licenses(alpm_pkg_t *pkg) { return pkg->licenses; } @@ -200,14 +200,14 @@ const char SYMEXPORT *alpm_pkg_get_url(alpm_pkg_t *pkg) return pkg->ops->get_url(pkg); } -time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg) +alpm_time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg) { ASSERT(pkg != NULL, return -1); pkg->handle->pm_errno = 0; return pkg->ops->get_builddate(pkg); } -time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg) +alpm_time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg) { ASSERT(pkg != NULL, return -1); pkg->handle->pm_errno = 0; diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index eff7d898..82a83264 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -27,7 +27,6 @@ #include "config.h" /* ensure off_t is correct length */ #include <sys/types.h> /* off_t */ -#include <time.h> /* time_t */ #include "alpm.h" #include "backup.h" @@ -44,8 +43,8 @@ struct pkg_operations { const char *(*get_desc) (alpm_pkg_t *); const char *(*get_url) (alpm_pkg_t *); - time_t (*get_builddate) (alpm_pkg_t *); - time_t (*get_installdate) (alpm_pkg_t *); + alpm_time_t (*get_builddate) (alpm_pkg_t *); + alpm_time_t (*get_installdate) (alpm_pkg_t *); const char *(*get_packager) (alpm_pkg_t *); const char *(*get_arch) (alpm_pkg_t *); off_t (*get_isize) (alpm_pkg_t *); @@ -89,8 +88,8 @@ struct __alpm_pkg_t { char *base64_sig; char *arch; - time_t builddate; - time_t installdate; + alpm_time_t builddate; + alpm_time_t installdate; off_t size; off_t isize; diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 08d634d6..968625b1 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -682,11 +682,11 @@ static int apply_deltas(alpm_handle_t *handle) } else { /* len = cachedir len + from len + '/' + null */ len = strlen(cachedir) + strlen(d->from) + 2; - CALLOC(from, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, 1)); + MALLOC(from, len, RET_ERR(handle, ALPM_ERR_MEMORY, 1)); snprintf(from, len, "%s/%s", cachedir, d->from); } len = strlen(cachedir) + strlen(d->to) + 2; - CALLOC(to, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, 1)); + MALLOC(to, len, RET_ERR(handle, ALPM_ERR_MEMORY, 1)); snprintf(to, len, "%s/%s", cachedir, d->to); /* build the patch command */ diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index beefa936..43f6cd52 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -918,16 +918,16 @@ int _alpm_test_checksum(const char *filepath, const char *expected, /* Note: does NOT handle sparse files on purpose for speed. */ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b) { - char *i = NULL; - int64_t offset; - int done = 0; - /* ensure we start populating our line buffer at the beginning */ b->line_offset = b->line; while(1) { + size_t block_remaining; + char *eol; + /* have we processed this entire block? */ if(b->block + b->block_size == b->block_offset) { + int64_t offset; if(b->ret == ARCHIVE_EOF) { /* reached end of archive on the last read, now we are out of data */ goto cleanup; @@ -937,20 +937,20 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b) b->ret = archive_read_data_block(a, (void *)&b->block, &b->block_size, &offset); b->block_offset = b->block; + block_remaining = b->block_size; /* error, cleanup */ if(b->ret < ARCHIVE_OK) { goto cleanup; } + } else { + block_remaining = b->block + b->block_size - b->block_offset; } - /* loop through the block looking for EOL characters */ - for(i = b->block_offset; i < (b->block + b->block_size); i++) { - /* check if read value was null or newline */ - if(*i == '\0' || *i == '\n') { - done = 1; - break; - } + /* look through the block looking for EOL characters */ + eol = memchr(b->block_offset, '\n', block_remaining); + if(!eol) { + eol = memchr(b->block_offset, '\0', block_remaining); } /* allocate our buffer, or ensure our existing one is big enough */ @@ -960,8 +960,8 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b) b->line_size = b->block_size + 1; b->line_offset = b->line; } else { - size_t needed = (size_t)((b->line_offset - b->line) - + (i - b->block_offset) + 1); + size_t new = eol ? (eol - b->block_offset) : block_remaining; + size_t needed = (size_t)((b->line_offset - b->line) + new + 1); if(needed > b->max_line_size) { b->ret = -ERANGE; goto cleanup; @@ -978,11 +978,11 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b) } } - if(done) { - size_t len = (size_t)(i - b->block_offset); + if(eol) { + size_t len = (size_t)(eol - b->block_offset); memcpy(b->line_offset, b->block_offset, len); b->line_offset[len] = '\0'; - b->block_offset = ++i; + b->block_offset = eol + 1; /* this is the main return point; from here you can read b->line */ return ARCHIVE_OK; } else { @@ -990,7 +990,7 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b) size_t len = (size_t)(b->block + b->block_size - b->block_offset); memcpy(b->line_offset, b->block_offset, len); b->line_offset += len; - b->block_offset = i; + b->block_offset = b->block + b->block_size; /* there was no new data, return what is left; saved ARCHIVE_EOF will be * returned on next call */ if(len == 0) { @@ -1107,8 +1107,12 @@ off_t _alpm_strtoofft(const char *line) return (off_t)result; } -time_t _alpm_parsedate(const char *line) +alpm_time_t _alpm_parsedate(const char *line) { + char *end; + long long result; + errno = 0; + if(isalpha((unsigned char)line[0])) { /* initialize to null in case of failure */ struct tm tmp_tm; @@ -1116,9 +1120,24 @@ time_t _alpm_parsedate(const char *line) setlocale(LC_TIME, "C"); strptime(line, "%a %b %e %H:%M:%S %Y", &tmp_tm); setlocale(LC_TIME, ""); - return mktime(&tmp_tm); + return (alpm_time_t)mktime(&tmp_tm); } - return (time_t)atol(line); + + result = strtoll(line, &end, 10); + if (result == 0 && end == line) { + /* line was not a number */ + errno = EINVAL; + return 0; + } else if (errno == ERANGE) { + /* line does not fit in long long */ + return 0; + } else if (*end) { + /* line began with a number but has junk left over at the end */ + errno = EINVAL; + return 0; + } + + return (alpm_time_t)result; } /** diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index 2a2d3a93..400a4eeb 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -35,7 +35,6 @@ #include <string.h> #include <stdarg.h> #include <stddef.h> /* size_t */ -#include <time.h> #include <sys/stat.h> /* struct stat */ #include <archive.h> /* struct archive */ #include <math.h> /* fabs */ @@ -51,7 +50,7 @@ #define ALLOC_FAIL(s) do { fprintf(stderr, "alloc failure: could not allocate %zd bytes\n", s); } while(0) -#define MALLOC(p, s, action) do { p = calloc(1, s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0) +#define MALLOC(p, s, action) do { p = malloc(s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0) #define CALLOC(p, l, s, action) do { p = calloc(l, s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0) /* This strdup macro is NULL safe- copying NULL will yield NULL */ #define STRDUP(r, s, action) do { if(s != NULL) { r = strdup(s); if(r == NULL) { ALLOC_FAIL(strlen(s)); action; } } else { r = NULL; } } while(0) @@ -120,7 +119,7 @@ int _alpm_splitname(const char *target, char **name, char **version, unsigned long *name_hash); unsigned long _alpm_hash_sdbm(const char *str); off_t _alpm_strtoofft(const char *line); -time_t _alpm_parsedate(const char *line); +alpm_time_t _alpm_parsedate(const char *line); int _alpm_raw_cmp(const char *first, const char *second); int _alpm_raw_ncmp(const char *first, const char *second, size_t max); int _alpm_access(alpm_handle_t *handle, const char *dir, const char *file, int amode); diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in index 5ff302e2..154f982e 100644 --- a/scripts/pacman-optimize.sh.in +++ b/scripts/pacman-optimize.sh.in @@ -113,7 +113,7 @@ fi # do not let pacman run while we do this touch "$lockfile" -workdir=$(mktemp -d /tmp/pacman-optimize.XXXXXXXXXX) || +workdir=$(mktemp -d "${TMPDIR:-/tmp}/pacman-optimize.XXXXXXXXXX") || die_r "$(gettext "Can not create temp directory for database building.")\n" >&2 # step 1: sum the old db diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 5e1d7702..fc008fc4 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -566,7 +566,7 @@ if [[ $cmd != "repo-add" && $cmd != "repo-remove" ]]; then exit 1 fi -tmpdir=$(mktemp -d /tmp/repo-tools.XXXXXXXXXX) || (\ +tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/repo-tools.XXXXXXXXXX") || (\ error "$(gettext "Cannot create temp directory for database building.")"; \ exit 1) mkdir $tmpdir/tree diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 3ba07b0c..f62d4449 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -25,6 +25,7 @@ #include <string.h> #include <sys/time.h> #include <sys/types.h> /* off_t */ +#include <time.h> #include <unistd.h> #include <wchar.h> #include <limits.h> /* UINT_MAX */ diff --git a/src/pacman/conf.c b/src/pacman/conf.c index fe2ebb3e..761c9a62 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -659,7 +659,7 @@ static int finish_section(struct section_t *section, int parse_options) } for(i = section->servers; i; i = alpm_list_next(i)) { - char *value = alpm_list_getdata(i); + char *value = i->data; if(_add_mirror(db, value) != 0) { pm_printf(ALPM_LOG_ERROR, _("could not add mirror '%s' to database '%s' (%s)\n"), diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c index 0055c37e..0bf9cd80 100644 --- a/src/pacman/deptest.c +++ b/src/pacman/deptest.c @@ -36,7 +36,7 @@ int pacman_deptest(alpm_list_t *targets) alpm_db_t *localdb = alpm_option_get_localdb(config->handle); for(i = targets; i; i = alpm_list_next(i)) { - char *target = alpm_list_getdata(i); + char *target = i->data; if(!alpm_find_satisfier(alpm_db_get_pkgcache(localdb), target)) { deps = alpm_list_add(deps, target); @@ -48,7 +48,7 @@ int pacman_deptest(alpm_list_t *targets) } for(i = deps; i; i = alpm_list_next(i)) { - const char *dep = alpm_list_getdata(i); + const char *dep = i->data; printf("%s\n", dep); } diff --git a/src/pacman/package.c b/src/pacman/package.c index 6a312f9a..49509571 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -26,6 +26,7 @@ #include <unistd.h> #include <limits.h> #include <errno.h> +#include <time.h> #include <alpm.h> #include <alpm_list.h> @@ -46,7 +47,7 @@ static void deplist_display(const char *title, { alpm_list_t *i, *text = NULL; for(i = deps; i; i = alpm_list_next(i)) { - alpm_depend_t *dep = alpm_list_getdata(i); + alpm_depend_t *dep = i->data; text = alpm_list_add(text, alpm_dep_compute_string(dep)); } list_display(title, text); @@ -74,11 +75,11 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) from = alpm_pkg_get_origin(pkg); /* set variables here, do all output below */ - bdate = alpm_pkg_get_builddate(pkg); + bdate = (time_t)alpm_pkg_get_builddate(pkg); if(bdate) { strftime(bdatestr, 50, "%c", localtime(&bdate)); } - idate = alpm_pkg_get_installdate(pkg); + idate = (time_t)alpm_pkg_get_installdate(pkg); if(idate) { strftime(idatestr, 50, "%c", localtime(&idate)); } @@ -223,7 +224,7 @@ void dump_pkg_backups(alpm_pkg_t *pkg) if(alpm_pkg_get_backup(pkg)) { /* package has backup files, so print them */ for(i = alpm_pkg_get_backup(pkg); i; i = alpm_list_next(i)) { - const alpm_backup_t *backup = alpm_list_getdata(i); + const alpm_backup_t *backup = i->data; const char *value; if(!backup->hash) { continue; diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 326664dd..d14b8879 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -211,7 +211,7 @@ static void usage(int op, const char * const myname) } list = alpm_list_msort(list, alpm_list_count(list), options_cmp); for (i = list; i; i = alpm_list_next(i)) { - printf("%s", (char *)alpm_list_getdata(i)); + printf("%s", (const char *)i->data); } alpm_list_free(list); #undef addlist @@ -905,7 +905,7 @@ int main(int argc, char *argv[]) printf("DB Path : %s\n", alpm_option_get_dbpath(config->handle)); printf("Cache Dirs: "); for(i = alpm_option_get_cachedirs(config->handle); i; i = alpm_list_next(i)) { - printf("%s ", (char *)alpm_list_getdata(i)); + printf("%s ", (const char *)i->data); } printf("\n"); printf("Lock File : %s\n", alpm_option_get_lockfile(config->handle)); diff --git a/src/pacman/query.c b/src/pacman/query.c index 1098b853..dbea9669 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -143,7 +143,7 @@ static int query_fileowner(alpm_list_t *targets) alpm_list_t *i; int found = 0; - filename = strdup(alpm_list_getdata(t)); + filename = strdup(t->data); if(lstat(filename, &buf) == -1) { /* if it is not a path but a program name, then check in PATH */ @@ -193,7 +193,7 @@ static int query_fileowner(alpm_list_t *targets) free(dname); for(i = alpm_db_get_pkgcache(db_local); i && !found; i = alpm_list_next(i)) { - alpm_pkg_t *info = alpm_list_getdata(i); + alpm_pkg_t *info = i->data; alpm_filelist_t *filelist = alpm_pkg_get_files(info); size_t j; @@ -263,7 +263,7 @@ static int query_search(alpm_list_t *targets) for(i = searchlist; i; i = alpm_list_next(i)) { alpm_list_t *grp; - alpm_pkg_t *pkg = alpm_list_getdata(i); + alpm_pkg_t *pkg = i->data; if(!config->quiet) { printf("local/%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg)); @@ -277,7 +277,7 @@ static int query_search(alpm_list_t *targets) alpm_list_t *k; printf(" ("); for(k = grp; k; k = alpm_list_next(k)) { - const char *group = alpm_list_getdata(k); + const char *group = k->data; printf("%s", group); if(alpm_list_next(k)) { /* only print a spacer if there are more groups */ @@ -304,33 +304,33 @@ static int query_search(alpm_list_t *targets) static int query_group(alpm_list_t *targets) { alpm_list_t *i, *j; - char *grpname = NULL; + const char *grpname = NULL; int ret = 0; alpm_db_t *db_local = alpm_option_get_localdb(config->handle); if(targets == NULL) { for(j = alpm_db_get_groupcache(db_local); j; j = alpm_list_next(j)) { - alpm_group_t *grp = alpm_list_getdata(j); + alpm_group_t *grp = j->data; const alpm_list_t *p; for(p = grp->packages; p; p = alpm_list_next(p)) { - alpm_pkg_t *pkg = alpm_list_getdata(p); + alpm_pkg_t *pkg = p->data; printf("%s %s\n", grp->name, alpm_pkg_get_name(pkg)); } } } else { for(i = targets; i; i = alpm_list_next(i)) { alpm_group_t *grp; - grpname = alpm_list_getdata(i); + grpname = i->data; grp = alpm_db_readgroup(db_local, grpname); if(grp) { const alpm_list_t *p; for(p = grp->packages; p; p = alpm_list_next(p)) { if(!config->quiet) { printf("%s %s\n", grpname, - alpm_pkg_get_name(alpm_list_getdata(p))); + alpm_pkg_get_name(p->data)); } else { - printf("%s\n", alpm_pkg_get_name(alpm_list_getdata(p))); + printf("%s\n", alpm_pkg_get_name(p->data)); } } } else { @@ -350,7 +350,7 @@ static int is_foreign(alpm_pkg_t *pkg) int match = 0; for(j = sync_dbs; j; j = alpm_list_next(j)) { - alpm_db_t *db = alpm_list_getdata(j); + alpm_db_t *db = j->data; alpm_pkg_t *findpkg = alpm_db_get_pkg(db, pkgname); if(findpkg) { match = 1; @@ -526,7 +526,7 @@ int pacman_query(alpm_list_t *targets) } for(i = alpm_db_get_pkgcache(db_local); i; i = alpm_list_next(i)) { - pkg = alpm_list_getdata(i); + pkg = i->data; if(filter(pkg)) { int value = display(pkg); if(value != 0) { @@ -552,7 +552,7 @@ int pacman_query(alpm_list_t *targets) /* operations on named packages in the local DB * valid: no-op (plain -Q), list, info, check */ for(i = targets; i; i = alpm_list_next(i)) { - char *strname = alpm_list_getdata(i); + const char *strname = i->data; if(config->op_q_isfile) { alpm_pkg_load(config->handle, strname, 1, 0, &pkg); diff --git a/src/pacman/remove.c b/src/pacman/remove.c index 3fc8279c..41957fe7 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -54,7 +54,7 @@ static int remove_target(const char *target) return -1; } for(p = grp->packages; p; p = alpm_list_next(p)) { - pkg = alpm_list_getdata(p); + pkg = p->data; if(alpm_remove_pkg(config->handle, pkg) == -1) { pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", target, alpm_strerror(alpm_errno(config->handle))); @@ -89,7 +89,7 @@ int pacman_remove(alpm_list_t *targets) /* Step 1: add targets to the created transaction */ for(i = targets; i; i = alpm_list_next(i)) { - char *target = alpm_list_getdata(i); + char *target = i->data; char *targ = strchr(target, '/'); if(targ && strncmp(target, "local", 5) == 0) { targ++; @@ -110,13 +110,13 @@ int pacman_remove(alpm_list_t *targets) switch(err) { case ALPM_ERR_PKG_INVALID_ARCH: for(i = data; i; i = alpm_list_next(i)) { - char *pkg = alpm_list_getdata(i); + const char *pkg = i->data; printf(_(":: package %s does not have a valid architecture\n"), pkg); } break; case ALPM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { - alpm_depmissing_t *miss = alpm_list_getdata(i); + alpm_depmissing_t *miss = i->data; char *depstring = alpm_dep_compute_string(miss->depend); printf(_(":: %s: requires %s\n"), miss->target, depstring); free(depstring); @@ -133,7 +133,7 @@ int pacman_remove(alpm_list_t *targets) /* Search for holdpkg in target list */ int holdpkg = 0; for(i = alpm_trans_get_remove(config->handle); i; i = alpm_list_next(i)) { - alpm_pkg_t *pkg = alpm_list_getdata(i); + alpm_pkg_t *pkg = i->data; if(alpm_list_find_str(config->holdpkg, alpm_pkg_get_name(pkg))) { pm_printf(ALPM_LOG_WARNING, _("%s is designated as a HoldPkg.\n"), alpm_pkg_get_name(pkg)); diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 5d6dcb99..dd8eb74c 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -95,7 +95,7 @@ static int sync_cleandb(const char *dbpath, int keep_used) len = strlen(dname); char *dbname = strndup(dname, len - 3); for(i = syncdbs; i && !found; i = alpm_list_next(i)) { - alpm_db_t *db = alpm_list_getdata(i); + alpm_db_t *db = i->data; found = !strcmp(dbname, alpm_db_get_name(db)); } free(dbname); @@ -155,7 +155,7 @@ static int sync_cleancache(int level) int ret = 0; for(i = cachedirs; i; i = alpm_list_next(i)) { - printf(_("Cache directory: %s\n"), (char *)alpm_list_getdata(i)); + printf(_("Cache directory: %s\n"), (const char *)i->data); } if(!config->cleanmethod) { @@ -183,7 +183,7 @@ static int sync_cleancache(int level) } for(i = cachedirs; i; i = alpm_list_next(i)) { - const char *cachedir = alpm_list_getdata(i); + const char *cachedir = i->data; DIR *dir = opendir(cachedir); struct dirent *ent; @@ -253,7 +253,7 @@ static int sync_cleancache(int level) alpm_list_t *j; /* check if this package is in a sync DB */ for(j = sync_dbs; j && delete; j = alpm_list_next(j)) { - alpm_db_t *db = alpm_list_getdata(j); + alpm_db_t *db = j->data; pkg = alpm_db_get_pkg(db, local_name); if(pkg != NULL && alpm_pkg_vercmp(local_version, alpm_pkg_get_version(pkg)) == 0) { @@ -288,7 +288,7 @@ static int sync_synctree(int level, alpm_list_t *syncs) int success = 0, ret; for(i = syncs; i; i = alpm_list_next(i)) { - alpm_db_t *db = alpm_list_getdata(i); + alpm_db_t *db = i->data; ret = alpm_db_update((level < 2 ? 0 : 1), db); if(ret < 0) { @@ -337,7 +337,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets) alpm_db_t *db_local = alpm_option_get_localdb(config->handle); for(i = syncs; i; i = alpm_list_next(i)) { - alpm_db_t *db = alpm_list_getdata(i); + alpm_db_t *db = i->data; /* if we have a targets list, search for packages matching it */ if(targets) { ret = alpm_db_search(db, targets); @@ -353,7 +353,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets) } for(j = ret; j; j = alpm_list_next(j)) { alpm_list_t *grp; - alpm_pkg_t *pkg = alpm_list_getdata(j); + alpm_pkg_t *pkg = j->data; if(!config->quiet) { printf("%s/%s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg), @@ -367,7 +367,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets) alpm_list_t *k; printf(" ("); for(k = grp; k; k = alpm_list_next(k)) { - const char *group = alpm_list_getdata(k); + const char *group = k->data; printf("%s", group); if(alpm_list_next(k)) { /* only print a spacer if there are more groups */ @@ -400,9 +400,9 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) if(targets) { for(i = targets; i; i = alpm_list_next(i)) { - const char *grpname = alpm_list_getdata(i); + const char *grpname = i->data; for(j = syncs; j; j = alpm_list_next(j)) { - alpm_db_t *db = alpm_list_getdata(j); + alpm_db_t *db = j->data; alpm_group_t *grp = alpm_db_readgroup(db, grpname); if(grp) { @@ -410,9 +410,9 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) for(k = grp->packages; k; k = alpm_list_next(k)) { if(!config->quiet) { printf("%s %s\n", grpname, - alpm_pkg_get_name(alpm_list_getdata(k))); + alpm_pkg_get_name(k->data)); } else { - printf("%s\n", alpm_pkg_get_name(alpm_list_getdata(k))); + printf("%s\n", alpm_pkg_get_name(k->data)); } } } @@ -420,15 +420,15 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) } } else { for(i = syncs; i; i = alpm_list_next(i)) { - alpm_db_t *db = alpm_list_getdata(i); + alpm_db_t *db = i->data; for(j = alpm_db_get_groupcache(db); j; j = alpm_list_next(j)) { - alpm_group_t *grp = alpm_list_getdata(j); + alpm_group_t *grp = j->data; if(level > 1) { for(k = grp->packages; k; k = alpm_list_next(k)) { printf("%s %s\n", grp->name, - alpm_pkg_get_name(alpm_list_getdata(k))); + alpm_pkg_get_name(k->data)); } } else { /* print grp names only, no package names */ @@ -448,7 +448,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) if(targets) { for(i = targets; i; i = alpm_list_next(i)) { - const char *target = alpm_list_getdata(i); + const char *target = i->data; char *name = strdup(target); char *repo, *pkgstr; int foundpkg = 0, founddb = 0; @@ -464,14 +464,14 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) } for(j = syncs; j; j = alpm_list_next(j)) { - alpm_db_t *db = alpm_list_getdata(j); + alpm_db_t *db = j->data; if(repo && strcmp(repo, alpm_db_get_name(db)) != 0) { continue; } founddb = 1; for(k = alpm_db_get_pkgcache(db); k; k = alpm_list_next(k)) { - alpm_pkg_t *pkg = alpm_list_getdata(k); + alpm_pkg_t *pkg = k->data; if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) { dump_pkg_full(pkg, config->op_s_info > 1); @@ -495,10 +495,10 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) } } else { for(i = syncs; i; i = alpm_list_next(i)) { - alpm_db_t *db = alpm_list_getdata(i); + alpm_db_t *db = i->data; for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) { - alpm_pkg_t *pkg = alpm_list_getdata(j); + alpm_pkg_t *pkg = j->data; dump_pkg_full(pkg, config->op_s_info > 1); } } @@ -514,11 +514,11 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) if(targets) { for(i = targets; i; i = alpm_list_next(i)) { - const char *repo = alpm_list_getdata(i); + const char *repo = i->data; alpm_db_t *db = NULL; for(j = syncs; j; j = alpm_list_next(j)) { - alpm_db_t *d = alpm_list_getdata(j); + alpm_db_t *d = j->data; if(strcmp(repo, alpm_db_get_name(d)) == 0) { db = d; @@ -540,10 +540,10 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) } for(i = ls; i; i = alpm_list_next(i)) { - alpm_db_t *db = alpm_list_getdata(i); + alpm_db_t *db = i->data; for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) { - alpm_pkg_t *pkg = alpm_list_getdata(j); + alpm_pkg_t *pkg = j->data; if(!config->quiet) { printf("%s %s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg), @@ -569,7 +569,7 @@ static alpm_list_t *syncfirst(void) { alpm_list_t *syncdbs = alpm_option_get_syncdbs(config->handle); for(i = config->syncfirst; i; i = alpm_list_next(i)) { - char *pkgname = alpm_list_getdata(i); + const char *pkgname = i->data; alpm_pkg_t *pkg = alpm_db_get_pkg(db_local, pkgname); if(pkg == NULL) { continue; @@ -647,7 +647,7 @@ static int process_group(alpm_list_t *dbs, const char *group) for(i = pkgs; i; i = alpm_list_next(i)) { if(array[n++] == 0) continue; - alpm_pkg_t *pkg = alpm_list_getdata(i); + alpm_pkg_t *pkg = i->data; if(process_pkg(pkg) == 1) { ret = 1; @@ -658,7 +658,7 @@ static int process_group(alpm_list_t *dbs, const char *group) free(array); } else { for(i = pkgs; i; i = alpm_list_next(i)) { - alpm_pkg_t *pkg = alpm_list_getdata(i); + alpm_pkg_t *pkg = i->data; if(process_pkg(pkg) == 1) { ret = 1; @@ -739,7 +739,7 @@ static int sync_trans(alpm_list_t *targets) /* process targets */ for(i = targets; i; i = alpm_list_next(i)) { - char *targ = alpm_list_getdata(i); + const char *targ = i->data; if(process_target(targ) == 1) { trans_release(); return 1; @@ -772,13 +772,13 @@ int sync_prepare_execute(void) switch(err) { case ALPM_ERR_PKG_INVALID_ARCH: for(i = data; i; i = alpm_list_next(i)) { - char *pkg = alpm_list_getdata(i); + const char *pkg = i->data; printf(_(":: package %s does not have a valid architecture\n"), pkg); } break; case ALPM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { - alpm_depmissing_t *miss = alpm_list_getdata(i); + alpm_depmissing_t *miss = i->data; char *depstring = alpm_dep_compute_string(miss->depend); printf(_(":: %s: requires %s\n"), miss->target, depstring); free(depstring); @@ -786,7 +786,7 @@ int sync_prepare_execute(void) break; case ALPM_ERR_CONFLICTING_DEPS: for(i = data; i; i = alpm_list_next(i)) { - alpm_conflict_t *conflict = alpm_list_getdata(i); + alpm_conflict_t *conflict = i->data; /* only print reason if it contains new information */ if(conflict->reason->mod == ALPM_DEP_MOD_ANY) { printf(_(":: %s and %s are in conflict\n"), @@ -841,7 +841,7 @@ int sync_prepare_execute(void) switch(err) { case ALPM_ERR_FILE_CONFLICTS: for(i = data; i; i = alpm_list_next(i)) { - alpm_fileconflict_t *conflict = alpm_list_getdata(i); + alpm_fileconflict_t *conflict = i->data; switch(conflict->type) { case ALPM_FILECONFLICT_TARGET: printf(_("%s exists in both '%s' and '%s'\n"), @@ -859,7 +859,7 @@ int sync_prepare_execute(void) case ALPM_ERR_PKG_INVALID_SIG: case ALPM_ERR_DLT_INVALID: for(i = data; i; i = alpm_list_next(i)) { - const char *filename = alpm_list_getdata(i); + const char *filename = i->data; printf(_("%s is invalid or corrupted\n"), filename); } break; diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index 3d4e34c1..06afde78 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -73,7 +73,7 @@ int pacman_upgrade(alpm_list_t *targets) printf(_("loading packages...\n")); /* add targets to the created transaction */ for(i = targets; i; i = alpm_list_next(i)) { - char *targ = alpm_list_getdata(i); + const char *targ = i->data; alpm_pkg_t *pkg; if(alpm_pkg_load(config->handle, targ, 1, level, &pkg) != 0) { diff --git a/src/pacman/util.c b/src/pacman/util.c index ee8fe3ff..278b65c1 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -23,7 +23,7 @@ #include <sys/types.h> #include <sys/ioctl.h> #include <sys/stat.h> -#include <sys/time.h> +#include <time.h> #include <stdio.h> #include <stdlib.h> @@ -400,7 +400,7 @@ char *strreplace(const char *str, const char *needle, const char *replace) p = str; newp = newstr; for(i = list; i; i = alpm_list_next(i)) { - q = alpm_list_getdata(i); + q = i->data; if(q > p) { /* add chars between this occurence and last occurence, if any */ memcpy(newp, p, (size_t)(q - p)); @@ -532,15 +532,15 @@ static size_t table_calc_widths(const alpm_list_t *header, } /* header determines column count and initial values of longest_strs */ for(i = header, curcol = 0; i; i = alpm_list_next(i), curcol++) { - colwidths[curcol] = string_length(alpm_list_getdata(i)); + colwidths[curcol] = string_length(i->data); } /* now find the longest string in each column */ for(i = rows; i; i = alpm_list_next(i)) { /* grab first column of each row and iterate through columns */ - const alpm_list_t *j = alpm_list_getdata(i); + const alpm_list_t *j = i->data; for(curcol = 0; j; j = alpm_list_next(j), curcol++) { - char *str = alpm_list_getdata(j); + const char *str = j->data; size_t str_len = string_length(str); if(str_len > colwidths[curcol]) { @@ -600,7 +600,7 @@ int table_display(const char *title, const alpm_list_t *header, printf("\n"); for(i = rows; i; i = alpm_list_next(i)) { - table_print_line(alpm_list_getdata(i), totalcols, widths); + table_print_line(i->data, totalcols, widths); } free(widths); @@ -622,11 +622,11 @@ void list_display(const char *title, const alpm_list_t *list) } else { const unsigned short maxcols = getcols(); size_t cols = len; - const char *str = alpm_list_getdata(list); + const char *str = list->data; printf("%s", str); cols += string_length(str); for(i = alpm_list_next(list); i; i = alpm_list_next(i)) { - str = alpm_list_getdata(i); + str = i->data; size_t s = string_length(str); /* wrap only if we have enough usable column space */ if(maxcols > len && cols + s + 2 >= maxcols) { @@ -662,7 +662,7 @@ void list_display_linebreak(const char *title, const alpm_list_t *list) } else { const alpm_list_t *i; /* Print the first element */ - indentprint((const char *) alpm_list_getdata(list), len); + indentprint((const char *)list->data, len); printf("\n"); /* Print the rest */ for(i = alpm_list_next(list); i; i = alpm_list_next(i)) { @@ -670,7 +670,7 @@ void list_display_linebreak(const char *title, const alpm_list_t *list) for(j = 1; j <= len; j++) { printf(" "); } - indentprint((const char *) alpm_list_getdata(i), len); + indentprint((const char *)i->data, len); printf("\n"); } } @@ -837,7 +837,7 @@ static void _display_targets(alpm_list_t *targets, int verbose) /* gather package info */ for(i = targets; i; i = alpm_list_next(i)) { - pm_target_t *target = alpm_list_getdata(i); + pm_target_t *target = i->data; if(target->install) { dlsize += alpm_pkg_download_size(target->install); @@ -881,7 +881,7 @@ static void _display_targets(alpm_list_t *targets, int verbose) /* rows is a list of lists of strings, free inner lists here */ for(i = rows; i; i = alpm_list_next(i)) { - alpm_list_t *lp = alpm_list_getdata(i); + alpm_list_t *lp = i->data; FREELIST(lp); } alpm_list_free(rows); @@ -938,7 +938,7 @@ void display_targets(void) alpm_db_t *db_local = alpm_option_get_localdb(config->handle); for(i = alpm_trans_get_add(config->handle); i; i = alpm_list_next(i)) { - alpm_pkg_t *pkg = alpm_list_getdata(i); + alpm_pkg_t *pkg = i->data; pm_target_t *targ = calloc(1, sizeof(pm_target_t)); if(!targ) return; targ->install = pkg; @@ -949,7 +949,7 @@ void display_targets(void) targets = alpm_list_add(targets, targ); } for(i = alpm_trans_get_remove(config->handle); i; i = alpm_list_next(i)) { - alpm_pkg_t *pkg = alpm_list_getdata(i); + alpm_pkg_t *pkg = i->data; pm_target_t *targ = calloc(1, sizeof(pm_target_t)); if(!targ) return; targ->remove = pkg; @@ -984,7 +984,7 @@ static char *pkg_get_location(alpm_pkg_t *pkg) case PM_OP_SYNC: servers = alpm_db_get_servers(alpm_pkg_get_db(pkg)); if(servers) { - pm_asprintf(&string, "%s/%s", alpm_list_getdata(servers), + pm_asprintf(&string, "%s/%s", servers->data, alpm_pkg_get_filename(pkg)); return string; } @@ -1039,7 +1039,7 @@ void print_packages(const alpm_list_t *packages) config->print_format = strdup("%l"); } for(i = packages; i; i = alpm_list_next(i)) { - alpm_pkg_t *pkg = alpm_list_getdata(i); + alpm_pkg_t *pkg = i->data; char *string = strdup(config->print_format); char *temp = string; /* %n : pkgname */ @@ -1132,7 +1132,7 @@ void select_display(const alpm_list_t *pkglist) const char *dbname = NULL; for (i = pkglist; i; i = i->next) { - alpm_pkg_t *pkg = alpm_list_getdata(i); + alpm_pkg_t *pkg = i->data; alpm_db_t *db = alpm_pkg_get_db(pkg); if(!dbname) diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c index 6553e6f6..7964609e 100644 --- a/src/util/cleanupdelta.c +++ b/src/util/cleanupdelta.c @@ -56,10 +56,10 @@ static void checkpkgs(alpm_list_t *pkglist) { alpm_list_t *i, *j; for(i = pkglist; i; i = alpm_list_next(i)) { - alpm_pkg_t *pkg = alpm_list_getdata(i); + alpm_pkg_t *pkg = i->data; alpm_list_t *unused = alpm_pkg_unused_deltas(pkg); for(j = unused; j; j = alpm_list_next(j)) { - char *delta = alpm_list_getdata(j); + const char *delta = j->data; printf("%s\n", delta); } alpm_list_free(unused); @@ -72,7 +72,7 @@ static void checkdbs(alpm_list_t *dbnames) { const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL; for(i = dbnames; i; i = alpm_list_next(i)) { - const char *dbname = alpm_list_getdata(i); + const char *dbname = i->data; db = alpm_db_register_sync(handle, dbname, level); if(db == NULL) { fprintf(stderr, "error: could not register sync database '%s' (%s)\n", diff --git a/src/util/pactree.c b/src/util/pactree.c index 997ba466..bb15b1bb 100644 --- a/src/util/pactree.c +++ b/src/util/pactree.c @@ -363,7 +363,7 @@ static alpm_pkg_t *get_pkg_from_dbs(alpm_list_t *dbs, const char *needle) { alpm_pkg_t *ret; for(i = dbs; i; i = alpm_list_next(i)) { - ret = alpm_db_get_pkg(alpm_list_getdata(i), needle); + ret = alpm_db_get_pkg(i->data, needle); if(ret) { return ret; } @@ -386,7 +386,7 @@ static void walk_reverse_deps(alpm_list_t *dblist, alpm_pkg_t *pkg, int depth) required_by = alpm_pkg_compute_requiredby(pkg); for(i = required_by; i; i = alpm_list_next(i)) { - const char *pkgname = alpm_list_getdata(i); + const char *pkgname = i->data; if(alpm_list_find_str(walked, pkgname)) { /* if we've already seen this package, don't print in "unique" output @@ -417,7 +417,7 @@ static void walk_deps(alpm_list_t *dblist, alpm_pkg_t *pkg, int depth) walked = alpm_list_add(walked, (void *)alpm_pkg_get_name(pkg)); for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) { - alpm_depend_t *depend = alpm_list_getdata(i); + alpm_depend_t *depend = i->data; alpm_pkg_t *provider = alpm_find_dbs_satisfier(handle, dblist, depend->name); if(provider) { diff --git a/src/util/testdb.c b/src/util/testdb.c index d85687a4..783d4993 100644 --- a/src/util/testdb.c +++ b/src/util/testdb.c @@ -101,7 +101,7 @@ static int checkdeps(alpm_list_t *pkglist) /* check dependencies */ data = alpm_checkdeps(handle, pkglist, NULL, pkglist, 0); for(i = data; i; i = alpm_list_next(i)) { - alpm_depmissing_t *miss = alpm_list_getdata(i); + alpm_depmissing_t *miss = i->data; char *depstring = alpm_dep_compute_string(miss->depend); printf("missing dependency for %s : %s\n", miss->target, depstring); @@ -119,7 +119,7 @@ static int checkconflicts(alpm_list_t *pkglist) /* check conflicts */ data = alpm_checkconflicts(handle, pkglist); for(i = data; i; i = i->next) { - alpm_conflict_t *conflict = alpm_list_getdata(i); + alpm_conflict_t *conflict = i->data; printf("%s conflicts with %s\n", conflict->package1, conflict->package2); ret++; @@ -154,7 +154,7 @@ static int check_syncdbs(alpm_list_t *dbnames) const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL; for(i = dbnames; i; i = alpm_list_next(i)) { - char *dbname = alpm_list_getdata(i); + const char *dbname = i->data; db = alpm_db_register_sync(handle, dbname, level); if(db == NULL) { fprintf(stderr, "error: could not register sync database (%s)\n", |