From b5a7734a7ecdd35f64f33eeed5252423ca005fd2 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Fri, 5 Apr 2013 10:12:04 -0400 Subject: use off_t for table_row_t.size size went from off_t in _display_targets to int in add_transaction_sizes and back to off_t in humanize_size leading to potential overflows. Fixes FS#34616. Signed-off-by: Andrew Gregory Signed-off-by: Allan McRae --- src/pacman/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pacman/util.c') diff --git a/src/pacman/util.c b/src/pacman/util.c index 862c8e8b..643b6fea 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -49,7 +49,7 @@ struct table_row_t { const char *label; - int size; + off_t size; }; int trans_init(alpm_transflag_t flags, int check_valid) @@ -828,7 +828,7 @@ static alpm_list_t *create_verbose_row(pm_target_t *target) return ret; } -static void add_transaction_sizes_row(alpm_list_t **table, const char *label, int size) +static void add_transaction_sizes_row(alpm_list_t **table, const char *label, off_t size) { struct table_row_t *row = malloc(sizeof(struct table_row_t)); -- cgit v1.2.3-70-g09d2 From 769facca22db733f0a70ce6a38062d37fe8d2579 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Sun, 14 Apr 2013 19:33:46 -0700 Subject: Fix spelling errors using 'codespell' tool Signed-off-by: Allan McRae --- NEWS | 2 +- lib/libalpm/add.c | 2 +- lib/libalpm/be_package.c | 4 ++-- lib/libalpm/deps.c | 2 +- lib/libalpm/signing.c | 2 +- lib/libalpm/util.c | 6 +++--- m4/pkg.m4 | 2 +- scripts/library/README | 2 +- src/pacman/conf.c | 4 ++-- src/pacman/pacman.c | 4 ++-- src/pacman/util.c | 8 ++++---- test/scripts/parseopts_test.sh | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/pacman/util.c') diff --git a/NEWS b/NEWS index 3a0361d0..ce52e6f4 100644 --- a/NEWS +++ b/NEWS @@ -912,7 +912,7 @@ VERSION DESCRIPTION - HTTP/1.1 support - an improved progress bar with transfer rates and ETA - cleaned up warning output a bit -2.7.2 - Supressed "No such file" messages during stripping +2.7.2 - Suppressed "No such file" messages during stripping - Removed extra newlines in /var/log/pacman.log - Added a --noextract option to makepkg to skip source extraction 2.7.1 - Fixed a couple obscure segfaults diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 1d9db602..3ef81e37 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -314,7 +314,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, hash_local = alpm_compute_md5sum(filename); hash_pkg = alpm_compute_md5sum(checkfile); - /* update the md5 hash in newpkg's backup (it will be the new orginal) */ + /* update the md5 hash in newpkg's backup (it will be the new original) */ alpm_list_t *i; for(i = alpm_pkg_get_backup(newpkg); i; i = i->next) { alpm_backup_t *backup = i->data; diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index 3b43ed84..cfe5fb36 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -390,7 +390,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, /* If full is false, only read through the archive until we find our needed * metadata. If it is true, read through the entire archive, which serves - * as a verfication of integrity and allows us to create the filelist. */ + * as a verification of integrity and allows us to create the filelist. */ while((ret = archive_read_next_header(archive, &entry)) == ARCHIVE_OK) { const char *entry_name = archive_entry_pathname(entry); @@ -460,7 +460,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, } } - if(ret != ARCHIVE_EOF && ret != ARCHIVE_OK) { /* An error occured */ + if(ret != ARCHIVE_EOF && ret != ARCHIVE_OK) { /* An error occurred */ _alpm_log(handle, ALPM_LOG_ERROR, _("error while reading package %s: %s\n"), pkgfile, archive_error_string(archive)); handle->pm_errno = ALPM_ERR_LIBARCHIVE; diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index aebfd0b5..96c49a9f 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -488,7 +488,7 @@ alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep) /* These parameters are messy. We check if this package, given a list of * targets and a db is safe to remove. We do NOT remove it if it is in the - * target list, or if if the package was explictly installed and + * target list, or if if the package was explicitly installed and * include_explicit == 0 */ static int can_remove_package(alpm_db_t *db, alpm_pkg_t *pkg, alpm_list_t *targets, int include_explicit) diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c index c653e454..32084585 100644 --- a/lib/libalpm/signing.c +++ b/lib/libalpm/signing.c @@ -105,7 +105,7 @@ static alpm_list_t *list_sigsum(gpgme_sigsum_t sigsum) sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_CRL_TOO_OLD, "crl too old"); /* A policy was not met. */ sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_BAD_POLICY, "bad policy"); - /* A system error occured. */ + /* A system error occurred. */ sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_SYS_ERROR, "sys error"); /* Fallback case */ if(!sigsum) { diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index dc1d0435..f84fb666 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -527,7 +527,7 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[]) goto cleanup; } - /* fork- parent and child each have seperate code blocks below */ + /* fork- parent and child each have separate code blocks below */ pid = fork(); if(pid == -1) { _alpm_log(handle, ALPM_LOG_ERROR, _("could not fork a new process (%s)\n"), strerror(errno)); @@ -677,7 +677,7 @@ char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename) return NULL; } -/** Check the alpm cachedirs for existance and find a writable one. +/** Check the alpm cachedirs for existence and find a writable one. * If no valid cache directory can be found, use /tmp. * @param handle the context handle * @return pointer to a writable cache directory. @@ -1251,7 +1251,7 @@ int _alpm_access(alpm_handle_t *handle, const char *dir, const char *file, int a /** Checks whether a string matches a shell wildcard pattern. * Wrapper around fnmatch. - * @param pattern pattern to match aganist + * @param pattern pattern to match against * @param string string to check against pattern * @return 0 if string matches pattern, non-zero if they don't match and on * error diff --git a/m4/pkg.m4 b/m4/pkg.m4 index 5152a4b1..5c202442 100644 --- a/m4/pkg.m4 +++ b/m4/pkg.m4 @@ -53,7 +53,7 @@ fi[]dnl # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -# only at the first occurence in configure.ac, so if the first place +# only at the first occurrence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- diff --git a/scripts/library/README b/scripts/library/README index c28ebc60..9e2b6a14 100644 --- a/scripts/library/README +++ b/scripts/library/README @@ -17,7 +17,7 @@ the short opts, any number of valid long opts may be be passed. The end of the options delimiter must then be added, followed by the user arguments to the calling program. -Reccommended Usage: +Recommended Usage: OPT_SHORT='fb:z' OPT_LONG=('foo' 'bar:' 'baz') if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 2ea49cc3..5adc96cf 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -519,7 +519,7 @@ static int _parse_options(const char *key, char *value, char *endptr; const char *oldlocale; - /* set the locale to 'C' for consistant decimal parsing (0.7 and never + /* set the locale to 'C' for consistent decimal parsing (0.7 and never * 0,7) from config files, then restore old setting when we are done */ oldlocale = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C"); @@ -636,7 +636,7 @@ static int _add_mirror(alpm_db_t *db, char *value) } /** Sets up libalpm global stuff in one go. Called after the command line - * and inital config file parsing. Once this is complete, we can see if any + * and initial config file parsing. Once this is complete, we can see if any * paths were defined. If a rootdir was defined and nothing else, we want all * of our paths to live under the rootdir that was specified. Safe to call * multiple times (will only do anything the first time). diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 82f117bc..921331c6 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -287,7 +287,7 @@ static ssize_t xwrite(int fd, const void *buf, size_t count) } /** Catches thrown signals. Performs necessary cleanup to ensure database is - * in a consistant state. + * in a consistent state. * @param signum the thrown signal */ static void handler(int signum) @@ -312,7 +312,7 @@ static void handler(int signum) return; } } - /* SIGINT: no commiting transaction, release it now and then exit pacman + /* SIGINT: no committing transaction, release it now and then exit pacman * SIGHUP, SIGTERM: release no matter what */ alpm_trans_release(config->handle); /* output a newline to be sure we clear any line we may be on */ diff --git a/src/pacman/util.c b/src/pacman/util.c index 643b6fea..35359678 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -314,7 +314,7 @@ size_t strtrim(char *str) return end - pch; } -/* Replace all occurances of 'needle' with 'replace' in 'str', returning +/* Replace all occurrences of 'needle' with 'replace' in 'str', returning * a new string (must be free'd) */ char *strreplace(const char *str, const char *needle, const char *replace) { @@ -336,11 +336,11 @@ char *strreplace(const char *str, const char *needle, const char *replace) q = strstr(p, needle); } - /* no occurences of needle found */ + /* no occurrences of needle found */ if(!list) { return strdup(str); } - /* size of new string = size of old string + "number of occurences of needle" + /* size of new string = size of old string + "number of occurrences of needle" * x "size difference between replace and needle" */ newsz = strlen(str) + 1 + alpm_list_count(list) * (replacesz - needlesz); @@ -354,7 +354,7 @@ char *strreplace(const char *str, const char *needle, const char *replace) for(i = list; i; i = alpm_list_next(i)) { q = i->data; if(q > p) { - /* add chars between this occurence and last occurence, if any */ + /* add chars between this occurrence and last occurrence, if any */ memcpy(newp, p, (size_t)(q - p)); newp += q - p; } diff --git a/test/scripts/parseopts_test.sh b/test/scripts/parseopts_test.sh index 1693b9f9..2862caec 100755 --- a/test/scripts/parseopts_test.sh +++ b/test/scripts/parseopts_test.sh @@ -83,7 +83,7 @@ parse '-p PKGBUILD --' 3 -pPKGBUILD # valid shortopts as a long opt parse '--' 1 --sir -# long opt wiht no optarg +# long opt with no optarg parse '--log --' 2 --log # long opt with missing optarg -- cgit v1.2.3-70-g09d2 From 34da9d25e4884c3f89092f6295f1ca6070604c7e Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Sat, 4 May 2013 09:39:28 -0400 Subject: pacman/util.c: fix output flushing in questions Flush stream before taking input in select_question() and only flush once during question(). Also fix some tabs inside related fprintf statements. Signed-off-by: Andrew Gregory Signed-off-by: Allan McRae --- src/pacman/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/pacman/util.c') diff --git a/src/pacman/util.c b/src/pacman/util.c index 35359678..59d3519e 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1388,7 +1388,7 @@ int multiselect_question(char *array, int count) fprintf(stream, "\n"); fprintf(stream, _("Enter a selection (default=all)")); - fprintf(stream, ": "); + fprintf(stream, ": "); fflush(stream); if(config->noconfirm) { @@ -1452,7 +1452,8 @@ int select_question(int count) while(1) { fprintf(stream, "\n"); fprintf(stream, _("Enter a number (default=%d)"), preset); - fprintf(stream, ": "); + fprintf(stream, ": "); + fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); @@ -1513,7 +1514,6 @@ static int question(short preset, const char *format, va_list args) return preset; } - fflush(stream); flush_term_input(fd_in); if(fgets(response, sizeof(response), stdin)) { -- cgit v1.2.3-70-g09d2 From 692633264a5cf1aa3e526522d7daf68d73943f12 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Sat, 4 May 2013 09:36:02 -0400 Subject: pacman/util.c: add missing braces Signed-off-by: Andrew Gregory Signed-off-by: Allan McRae --- src/pacman/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/pacman/util.c') diff --git a/src/pacman/util.c b/src/pacman/util.c index 59d3519e..bd09adc9 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -847,8 +847,9 @@ static void display_transaction_sizes(alpm_list_t *table) struct table_row_t *row = i->data; int len = string_length(row->label); - if(len > max_len) + if(len > max_len) { max_len = len; + } } max_len += 2; -- cgit v1.2.3-70-g09d2