diff options
author | joerg <joerg> | 2009-08-02 17:56:44 +0000 |
---|---|---|
committer | joerg <joerg> | 2009-08-02 17:56:44 +0000 |
commit | ffab72b3cefae0e3f780b705530f3a741a80b7b9 (patch) | |
tree | 2200f2b83cbdd086792500ea31498bee564b2d93 /pkgtools | |
parent | c807d26da16c65729f61d8d2bd78da8b5a21e4a8 (diff) | |
download | pkgsrc-ffab72b3cefae0e3f780b705530f3a741a80b7b9.tar.gz |
pkg_install-20090727:
Make pkg_install WARNS=4 clean and fix a number of lint warnings.
Based on reports from veego about warnings with older GCC releases in
pkg_delete, where a variable is potentially used uninitialized.
Diffstat (limited to 'pkgtools')
27 files changed, 120 insertions, 154 deletions
diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c index 18088fd13ed..7fad55af7ce 100644 --- a/pkgtools/pkg_install/files/add/perform.c +++ b/pkgtools/pkg_install/files/add/perform.c @@ -1,4 +1,4 @@ -/* $NetBSD: perform.c,v 1.87 2009/05/28 08:59:59 joerg Exp $ */ +/* $NetBSD: perform.c,v 1.88 2009/08/02 17:56:44 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" #endif @@ -6,7 +6,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: perform.c,v 1.87 2009/05/28 08:59:59 joerg Exp $"); +__RCSID("$NetBSD: perform.c,v 1.88 2009/08/02 17:56:44 joerg Exp $"); /*- * Copyright (c) 2003 Grant Beattie <grant@NetBSD.org> @@ -120,7 +120,7 @@ static const struct pkg_meta_desc { { offsetof(struct pkg_meta, meta_views), VIEWS_FNAME, 0, 0444 }, { offsetof(struct pkg_meta, meta_required_by), REQUIRED_BY_FNAME, 0, 0644 }, { offsetof(struct pkg_meta, meta_installed_info), INSTALLED_INFO_FNAME, 0, 0644 }, - { 0, NULL, 0 }, + { 0, NULL, 0, 0 }, }; static int pkg_do(const char *, int, int); @@ -780,7 +780,7 @@ pkg_register_depends(struct pkg_task *pkg) if (fd == -1) { warn("can't open dependency file '%s'," "registration is incomplete!", required_by); - } else if (write(fd, text, text_len) != text_len) { + } else if (write(fd, text, text_len) != (ssize_t)text_len) { warn("can't write to dependency file `%s'", required_by); close(fd); } else if (close(fd) == -1) diff --git a/pkgtools/pkg_install/files/admin/audit.c b/pkgtools/pkg_install/files/admin/audit.c index 3da24845449..2d7c9332cef 100644 --- a/pkgtools/pkg_install/files/admin/audit.c +++ b/pkgtools/pkg_install/files/admin/audit.c @@ -1,4 +1,4 @@ -/* $NetBSD: audit.c,v 1.13 2009/05/10 21:11:43 joerg Exp $ */ +/* $NetBSD: audit.c,v 1.14 2009/08/02 17:56:44 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: audit.c,v 1.13 2009/05/10 21:11:43 joerg Exp $"); +__RCSID("$NetBSD: audit.c,v 1.14 2009/08/02 17:56:44 joerg Exp $"); /*- * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -379,7 +379,7 @@ fetch_pkg_vulnerabilities(int argc, char **argv) err(EXIT_FAILURE, "Cannot create pkg-vulnerability file %s", pkg_vulnerabilities_file); - if (write(fd, buf, buf_len) != buf_len) + if (write(fd, buf, buf_len) != (ssize_t)buf_len) err(EXIT_FAILURE, "Cannot write pkg-vulnerability file"); if (close(fd) == -1) err(EXIT_FAILURE, "Cannot close pkg-vulnerability file after write"); diff --git a/pkgtools/pkg_install/files/admin/main.c b/pkgtools/pkg_install/files/admin/main.c index 374a8d87959..60d0dafbd64 100644 --- a/pkgtools/pkg_install/files/admin/main.c +++ b/pkgtools/pkg_install/files/admin/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.53 2009/05/13 10:51:46 wiz Exp $ */ +/* $NetBSD: main.c,v 1.54 2009/08/02 17:56:44 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: main.c,v 1.53 2009/05/13 10:51:46 wiz Exp $"); +__RCSID("$NetBSD: main.c,v 1.54 2009/08/02 17:56:44 joerg Exp $"); /*- * Copyright (c) 1999-2008 The NetBSD Foundation, Inc. @@ -301,7 +301,7 @@ add_required_by(const char *pattern, const char *required_by) free(path); len = strlen(required_by); - if (write(fd, required_by, len) != len || + if (write(fd, required_by, len) != (ssize_t)len || write(fd, "\n", 1) != 1 || close(fd) == -1) errx(EXIT_FAILURE, "Cannot write to %s", path); @@ -469,7 +469,7 @@ main(int argc, char *argv[]) if (show_basename_only) rc = match_local_files(dir, use_default_sfx, 1, basep, lsbasepattern, NULL); else - rc = match_local_files(dir, use_default_sfx, 1, basep, lspattern, (void *)dir); + rc = match_local_files(dir, use_default_sfx, 1, basep, lspattern, __UNCONST(dir)); if (rc == -1) errx(EXIT_FAILURE, "Error from match_local_files(\"%s\", \"%s\", ...)", dir, basep); @@ -712,8 +712,3 @@ set_unset_variable(char **argv, Boolean unset) return; } - -void -cleanup(int signo) -{ -} diff --git a/pkgtools/pkg_install/files/create/build.c b/pkgtools/pkg_install/files/create/build.c index ee223c34044..14d84bebf1f 100644 --- a/pkgtools/pkg_install/files/create/build.c +++ b/pkgtools/pkg_install/files/create/build.c @@ -1,4 +1,4 @@ -/* $NetBSD: build.c,v 1.12 2009/05/13 03:33:50 joerg Exp $ */ +/* $NetBSD: build.c,v 1.13 2009/08/02 17:56:44 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: build.c,v 1.12 2009/05/13 03:33:50 joerg Exp $"); +__RCSID("$NetBSD: build.c,v 1.13 2009/08/02 17:56:44 joerg Exp $"); /*- * Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -150,7 +150,7 @@ write_entry(struct archive *archive, struct archive_entry *entry) len = archive_entry_size(entry); while (len > 0) { - buf_len = (len > sizeof(buf)) ? sizeof(buf) : (ssize_t)len; + buf_len = (len > (off_t)sizeof(buf)) ? (ssize_t)sizeof(buf) : (ssize_t)len; if ((buf_len = read(fd, buf, buf_len)) == 0) break; @@ -412,7 +412,7 @@ pkg_build(const char *pkg, const char *full_pkg, const char *suffix, PRESERVE_FNAME, 0444); } if (create_views) - views_file = make_and_add(plist, VIEWS_FNAME, "", 0444); + views_file = make_and_add(plist, VIEWS_FNAME, xstrdup(""), 0444); /* Finally, write out the packing list */ stringify_plist(plist, &plist_buf, &plist_len, realprefix); diff --git a/pkgtools/pkg_install/files/create/create.h b/pkgtools/pkg_install/files/create/create.h index 73dde690b99..11fd3006b02 100644 --- a/pkgtools/pkg_install/files/create/create.h +++ b/pkgtools/pkg_install/files/create/create.h @@ -1,4 +1,4 @@ -/* $NetBSD: create.h,v 1.12 2009/05/13 03:33:50 joerg Exp $ */ +/* $NetBSD: create.h,v 1.13 2009/08/02 17:56:44 joerg Exp $ */ /* from FreeBSD Id: create.h,v 1.13 1997/10/08 07:46:19 charnier Exp */ @@ -55,7 +55,7 @@ extern char *SrcDir; extern char *realprefix; extern char *DefaultOwner; extern char *DefaultGroup; -extern char *CompressionType; +extern const char *CompressionType; extern int PlistOnly; extern int RelativeLinks; extern int update_pkgdb; diff --git a/pkgtools/pkg_install/files/create/main.c b/pkgtools/pkg_install/files/create/main.c index b1165c77916..917d06feb80 100644 --- a/pkgtools/pkg_install/files/create/main.c +++ b/pkgtools/pkg_install/files/create/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.15 2009/05/13 03:33:50 joerg Exp $ */ +/* $NetBSD: main.c,v 1.16 2009/08/02 17:56:44 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: main.c,v 1.15 2009/05/13 03:33:50 joerg Exp $"); +__RCSID("$NetBSD: main.c,v 1.16 2009/08/02 17:56:44 joerg Exp $"); /* * FreeBSD install - a package for the installation and maintainance @@ -47,7 +47,7 @@ char *SrcDir = NULL; char *DefaultOwner = NULL; char *DefaultGroup = NULL; char *realprefix = NULL; -char *CompressionType = NULL; +const char *CompressionType = NULL; int update_pkgdb = 1; int create_views = 0; int PlistOnly = 0; @@ -70,11 +70,6 @@ usage(void) exit(1); } -void -cleanup(int in_signal) -{ -} - int main(int argc, char **argv) { diff --git a/pkgtools/pkg_install/files/create/perform.c b/pkgtools/pkg_install/files/create/perform.c index c2e2961d3fc..b20f8441907 100644 --- a/pkgtools/pkg_install/files/create/perform.c +++ b/pkgtools/pkg_install/files/create/perform.c @@ -1,4 +1,4 @@ -/* $NetBSD: perform.c,v 1.24 2009/02/03 13:15:34 joerg Exp $ */ +/* $NetBSD: perform.c,v 1.25 2009/08/02 17:56:44 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: perform.c,v 1.24 2009/02/03 13:15:34 joerg Exp $"); +__RCSID("$NetBSD: perform.c,v 1.25 2009/08/02 17:56:44 joerg Exp $"); /* * FreeBSD install - a package for the installation and maintainance @@ -99,18 +99,15 @@ fileGetContents(char *fname) int fd; if (stat(fname, &sb) == FAIL) { - cleanup(0); errx(2, "can't stat '%s'", fname); } contents = xmalloc((size_t) (sb.st_size) + 1); fd = open(fname, O_RDONLY, 0); if (fd == FAIL) { - cleanup(0); errx(2, "unable to open '%s' for reading", fname); } - if (read(fd, contents, (size_t) sb.st_size) != (size_t) sb.st_size) { - cleanup(0); + if (read(fd, contents, (size_t) sb.st_size) != (ssize_t) sb.st_size) { errx(2, "short read on '%s' - did not get %lld bytes", fname, (long long) sb.st_size); } diff --git a/pkgtools/pkg_install/files/delete/pkg_delete.c b/pkgtools/pkg_install/files/delete/pkg_delete.c index 65bb95e7d49..e127a0621f0 100644 --- a/pkgtools/pkg_install/files/delete/pkg_delete.c +++ b/pkgtools/pkg_install/files/delete/pkg_delete.c @@ -34,7 +34,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: pkg_delete.c,v 1.6 2009/04/24 14:00:25 joerg Exp $"); +__RCSID("$NetBSD: pkg_delete.c,v 1.7 2009/08/02 17:56:44 joerg Exp $"); #if HAVE_ERR_H #include <err.h> @@ -44,10 +44,6 @@ __RCSID("$NetBSD: pkg_delete.c,v 1.6 2009/04/24 14:00:25 joerg Exp $"); #include "lib.h" -#ifndef __UNCONST -#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) -#endif - static const char *pkgdb; static const char *destdir; static const char *prefix; @@ -531,7 +527,8 @@ remove_line(const char *fname, const char *fname_tmp, const char *text) if (rename(fname_tmp, fname) == -1) { warn("Unable to rename `%s' to `%s'", fname_tmp, fname); rv = 1; - } + } else + rv = 0; remove(fname_tmp); return rv; @@ -735,6 +732,8 @@ remove_pkg(const char *pkg) fname = pkgdb_pkg_file(pkg, VIEWS_FNAME); if (fexists(fname)) is_depoted_pkg = TRUE; + else + is_depoted_pkg = FALSE; free(fname); if (Fake) diff --git a/pkgtools/pkg_install/files/info/info.h b/pkgtools/pkg_install/files/info/info.h index f96c34e11f0..d9c3b6e965a 100644 --- a/pkgtools/pkg_install/files/info/info.h +++ b/pkgtools/pkg_install/files/info/info.h @@ -1,4 +1,4 @@ -/* $NetBSD: info.h,v 1.19 2009/05/13 03:18:05 joerg Exp $ */ +/* $NetBSD: info.h,v 1.20 2009/08/02 17:56:45 joerg Exp $ */ /* from FreeBSD Id: info.h,v 1.10 1997/02/22 16:09:40 peter Exp */ @@ -112,8 +112,8 @@ extern int Flags; extern enum which Which; extern Boolean File2Pkg; extern Boolean Quiet; -extern char *InfoPrefix; -extern char *BuildInfoVariable; +extern const char *InfoPrefix; +extern const char *BuildInfoVariable; extern size_t termwidth; extern lpkg_head_t pkgs; diff --git a/pkgtools/pkg_install/files/info/main.c b/pkgtools/pkg_install/files/info/main.c index 0c72052fbd8..812c267d24d 100644 --- a/pkgtools/pkg_install/files/info/main.c +++ b/pkgtools/pkg_install/files/info/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.26 2009/05/13 03:18:05 joerg Exp $ */ +/* $NetBSD: main.c,v 1.27 2009/08/02 17:56:45 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: main.c,v 1.26 2009/05/13 03:18:05 joerg Exp $"); +__RCSID("$NetBSD: main.c,v 1.27 2009/08/02 17:56:45 joerg Exp $"); /* * @@ -50,8 +50,8 @@ int Flags = 0; enum which Which = WHICH_LIST; Boolean File2Pkg = FALSE; Boolean Quiet = FALSE; -char *InfoPrefix = ""; -char *BuildInfoVariable = ""; +const char *InfoPrefix = ""; +const char *BuildInfoVariable = ""; size_t termwidth = 0; lpkg_head_t pkgs; diff --git a/pkgtools/pkg_install/files/info/perform.c b/pkgtools/pkg_install/files/info/perform.c index fb5479bdade..5bda21d1c96 100644 --- a/pkgtools/pkg_install/files/info/perform.c +++ b/pkgtools/pkg_install/files/info/perform.c @@ -1,4 +1,4 @@ -/* $NetBSD: perform.c,v 1.58 2009/07/24 19:06:45 joerg Exp $ */ +/* $NetBSD: perform.c,v 1.59 2009/08/02 17:56:45 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -13,7 +13,7 @@ #if HAVE_SYS_WAIT_H #include <sys/wait.h> #endif -__RCSID("$NetBSD: perform.c,v 1.58 2009/07/24 19:06:45 joerg Exp $"); +__RCSID("$NetBSD: perform.c,v 1.59 2009/08/02 17:56:45 joerg Exp $"); /*- * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -308,7 +308,7 @@ build_full_reqby(lpkg_head_t *reqby, struct pkg_meta *meta, int limit) if (iter == eol) continue; TAILQ_FOREACH(lpp, reqby, lp_link) { - if (strlen(lpp->lp_name) != eol - iter) + if (strlen(lpp->lp_name) + iter != eol) continue; if (memcmp(lpp->lp_name, iter, eol - iter) == 0) break; @@ -596,12 +596,6 @@ CheckForBestPkg(const char *pkgname) return 0; } -void -cleanup(int sig) -{ - exit(1); -} - static int perform_single_pkg(const char *pkg, void *cookie) { @@ -618,8 +612,6 @@ pkg_perform(lpkg_head_t *pkghead) { int err_cnt = 0; - signal(SIGINT, cleanup); - TAILQ_INIT(&files); desired_meta_data = 0; @@ -650,7 +642,6 @@ pkg_perform(lpkg_head_t *pkghead) if (Flags & SHOW_BUILD_VERSION) desired_meta_data |= LOAD_BUILD_VERSION; - if (Which != WHICH_LIST) { if (File2Pkg) { /* Show all files with the package they belong to */ @@ -664,7 +655,7 @@ pkg_perform(lpkg_head_t *pkghead) /* Show info on individual pkg(s) */ lpkg_t *lpp; - while ((lpp = TAILQ_FIRST(pkghead))) { + while ((lpp = TAILQ_FIRST(pkghead)) != NULL) { TAILQ_REMOVE(pkghead, lpp, lp_link); err_cnt += pkg_do(lpp->lp_name); free_lpkg(lpp); diff --git a/pkgtools/pkg_install/files/info/show.c b/pkgtools/pkg_install/files/info/show.c index 57a9167c901..c7cb172eb2f 100644 --- a/pkgtools/pkg_install/files/info/show.c +++ b/pkgtools/pkg_install/files/info/show.c @@ -1,4 +1,4 @@ -/* $NetBSD: show.c,v 1.29 2009/05/02 16:14:37 reed Exp $ */ +/* $NetBSD: show.c,v 1.30 2009/08/02 17:56:45 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: show.c,v 1.29 2009/05/02 16:14:37 reed Exp $"); +__RCSID("$NetBSD: show.c,v 1.30 2009/08/02 17:56:45 joerg Exp $"); /* * FreeBSD install - a package for the installation and maintainance @@ -68,8 +68,8 @@ __RCSID("$NetBSD: show.c,v 1.29 2009/05/02 16:14:37 reed Exp $"); /* Structure to define entries for the "show table" */ typedef struct show_t { pl_ent_t sh_type; /* type of entry */ - char *sh_quiet; /* message when quiet */ - char *sh_verbose; /* message when verbose */ + const char *sh_quiet; /* message when quiet */ + const char *sh_verbose; /* message when verbose */ } show_t; /* @@ -212,7 +212,7 @@ show_files(const char *title, package_t *plist) { plist_t *p; Boolean ign; - char *dir = "."; + const char *dir = "."; if (!Quiet) { printf("%s%s", InfoPrefix, title); diff --git a/pkgtools/pkg_install/files/lib/conflicts.c b/pkgtools/pkg_install/files/lib/conflicts.c index f77679ae473..9e15e5def72 100644 --- a/pkgtools/pkg_install/files/lib/conflicts.c +++ b/pkgtools/pkg_install/files/lib/conflicts.c @@ -1,4 +1,4 @@ -/* $NetBSD: conflicts.c,v 1.8 2009/02/02 12:35:01 joerg Exp $ */ +/* $NetBSD: conflicts.c,v 1.9 2009/08/02 17:56:45 joerg Exp $ */ /*- * Copyright (c) 2007 Roland Illig <rillig@NetBSD.org>. @@ -48,7 +48,7 @@ #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: conflicts.c,v 1.8 2009/02/02 12:35:01 joerg Exp $"); +__RCSID("$NetBSD: conflicts.c,v 1.9 2009/08/02 17:56:45 joerg Exp $"); #if HAVE_ERR_H #include <err.h> @@ -162,5 +162,4 @@ int main(int argc, char **argv) printf("no\n"); return 0; } -void cleanup(int i) {} #endif diff --git a/pkgtools/pkg_install/files/lib/decompress.c b/pkgtools/pkg_install/files/lib/decompress.c index 820f988691a..31500f2580d 100644 --- a/pkgtools/pkg_install/files/lib/decompress.c +++ b/pkgtools/pkg_install/files/lib/decompress.c @@ -1,4 +1,4 @@ -/* $NetBSD: decompress.c,v 1.2 2009/02/02 12:35:01 joerg Exp $ */ +/* $NetBSD: decompress.c,v 1.3 2009/08/02 17:56:45 joerg Exp $ */ /*- * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -39,7 +39,7 @@ #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: decompress.c,v 1.2 2009/02/02 12:35:01 joerg Exp $"); +__RCSID("$NetBSD: decompress.c,v 1.3 2009/08/02 17:56:45 joerg Exp $"); #ifdef BOOTSTRAP #include "lib.h" @@ -75,7 +75,7 @@ decompress_bzip2(const char *in, size_t in_len, char **out, size_t *out_len) *out_len = in_len; *out = xmalloc(*out_len + 1); - stream.next_in = (char *)in; + stream.next_in = __UNCONST(in); stream.avail_in = in_len; stream.next_out = *out; stream.avail_out = *out_len; @@ -125,7 +125,7 @@ decompress_zlib(const char *in, size_t in_len, char **out, size_t *out_len) *out_len = in_len; *out = xmalloc(*out_len + 1); - stream.next_in = (unsigned char *)in; + stream.next_in = __UNCONST(in); stream.avail_in = in_len; stream.next_out = (unsigned char *)*out; stream.avail_out = *out_len; diff --git a/pkgtools/pkg_install/files/lib/fexec.c b/pkgtools/pkg_install/files/lib/fexec.c index 5789bd4933c..540159863aa 100644 --- a/pkgtools/pkg_install/files/lib/fexec.c +++ b/pkgtools/pkg_install/files/lib/fexec.c @@ -1,4 +1,4 @@ -/* $NetBSD: fexec.c,v 1.11 2009/02/02 12:35:01 joerg Exp $ */ +/* $NetBSD: fexec.c,v 1.12 2009/08/02 17:56:45 joerg Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ #include "lib.h" -__RCSID("$NetBSD: fexec.c,v 1.11 2009/02/02 12:35:01 joerg Exp $"); +__RCSID("$NetBSD: fexec.c,v 1.12 2009/08/02 17:56:45 joerg Exp $"); static int vfcexec(const char *, int, const char *, va_list); @@ -80,7 +80,7 @@ pfcexec(const char *path, const char *file, const char **argv) if ((path != NULL) && (chdir(path) < 0)) _exit(127); - (void)execvp(file, (char ** const)argv); + (void)execvp(file, __UNCONST(argv)); _exit(127); /* NOTREACHED */ case -1: diff --git a/pkgtools/pkg_install/files/lib/file.c b/pkgtools/pkg_install/files/lib/file.c index 721ebeda302..ea44c93a525 100644 --- a/pkgtools/pkg_install/files/lib/file.c +++ b/pkgtools/pkg_install/files/lib/file.c @@ -1,4 +1,4 @@ -/* $NetBSD: file.c,v 1.27 2009/04/24 01:03:41 joerg Exp $ */ +/* $NetBSD: file.c,v 1.28 2009/08/02 17:56:45 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -13,7 +13,7 @@ #if HAVE_SYS_QUEUE_H #include <sys/queue.h> #endif -__RCSID("$NetBSD: file.c,v 1.27 2009/04/24 01:03:41 joerg Exp $"); +__RCSID("$NetBSD: file.c,v 1.28 2009/08/02 17:56:45 joerg Exp $"); /* * FreeBSD install - a package for the installation and maintainance @@ -178,7 +178,7 @@ isemptyfile(const char *fname) /* This struct defines the leading part of a valid URL name */ typedef struct url_t { - char *u_s; /* the leading part of the URL */ + const char *u_s; /* the leading part of the URL */ int u_len; /* its length */ } url_t; @@ -187,7 +187,7 @@ static const url_t urls[] = { {"file://", 7}, {"ftp://", 6}, {"http://", 7}, - {NULL} + {NULL, 0} }; /* @@ -219,12 +219,11 @@ URLlength(const char *fname) Boolean make_preserve_name(char *try, size_t max, const char *name, const char *file) { - int len, i; + size_t len, i; if ((len = strlen(file)) == 0) return FALSE; - else - i = len - 1; + i = len - 1; strncpy(try, file, max); if (try[i] == '/') /* Catch trailing slash early and save checking in the loop */ --i; @@ -253,6 +252,7 @@ remove_files(const char *path, const char *pattern) char fpath[MaxPathSize]; glob_t globbed; int i; + size_t j; (void) snprintf(fpath, sizeof(fpath), "%s/%s", path, pattern); if ((i=glob(fpath, GLOB_NOSORT, NULL, &globbed)) != 0) { @@ -274,9 +274,9 @@ remove_files(const char *path, const char *pattern) } /* deleting globbed files */ - for (i=0; i<globbed.gl_pathc; i++) - if (unlink(globbed.gl_pathv[i]) < 0) - warn("can't delete ``%s''", globbed.gl_pathv[i]); + for (j = 0; j < globbed.gl_pathc; j++) + if (unlink(globbed.gl_pathv[j]) < 0) + warn("can't delete ``%s''", globbed.gl_pathv[j]); return; } diff --git a/pkgtools/pkg_install/files/lib/gpgsig.c b/pkgtools/pkg_install/files/lib/gpgsig.c index e01c50d91ae..6f9aa1bdf21 100644 --- a/pkgtools/pkg_install/files/lib/gpgsig.c +++ b/pkgtools/pkg_install/files/lib/gpgsig.c @@ -1,4 +1,4 @@ -/* $NetBSD: gpgsig.c,v 1.2 2009/02/02 12:35:01 joerg Exp $ */ +/* $NetBSD: gpgsig.c,v 1.3 2009/08/02 17:56:45 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" #endif @@ -7,7 +7,7 @@ #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: gpgsig.c,v 1.2 2009/02/02 12:35:01 joerg Exp $"); +__RCSID("$NetBSD: gpgsig.c,v 1.3 2009/08/02 17:56:45 joerg Exp $"); /*- * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -52,10 +52,6 @@ __RCSID("$NetBSD: gpgsig.c,v 1.2 2009/02/02 12:35:01 joerg Exp $"); #include "lib.h" -#ifndef __UNCONST -#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) -#endif - static void verify_signature(const char *input, size_t input_len, const char *keyring, const char *detached_signature) @@ -99,7 +95,7 @@ verify_signature(const char *input, size_t input_len, const char *keyring, _exit(255); } close(fd[0]); - if (write(fd[1], input, input_len) != input_len) + if (write(fd[1], input, input_len) != (ssize_t)input_len) errx(EXIT_FAILURE, "Short read from GPG"); close(fd[1]); waitpid(child, &status, 0); @@ -223,7 +219,7 @@ detached_gpg_sign(const char *content, size_t len, char **sig, size_t *sig_len, _exit(255); } close(fd_in[0]); - if (write(fd_in[1], content, len) != len) + if (write(fd_in[1], content, len) != (ssize_t)len) errx(EXIT_FAILURE, "Short read from GPG"); close(fd_in[1]); diff --git a/pkgtools/pkg_install/files/lib/iterate.c b/pkgtools/pkg_install/files/lib/iterate.c index 1ab3b74428d..1e446950b89 100644 --- a/pkgtools/pkg_install/files/lib/iterate.c +++ b/pkgtools/pkg_install/files/lib/iterate.c @@ -1,4 +1,4 @@ -/* $NetBSD: iterate.c,v 1.6 2009/02/02 12:35:01 joerg Exp $ */ +/* $NetBSD: iterate.c,v 1.7 2009/08/02 17:56:45 joerg Exp $ */ /*- * Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -44,10 +44,6 @@ #include "lib.h" -#ifndef __UNCONST -#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) -#endif - /* * Generic iteration function: * - get new entries from srciter, stop on NULL @@ -182,7 +178,7 @@ match_by_basename(const char *pkg, void *cookie) return 0; } if (strncmp(pkg, target, pkg_version - pkg) == 0 && - strlen(target) == pkg_version - pkg) + pkg + strlen(target) == pkg_version) return 1; else return 0; @@ -198,7 +194,7 @@ match_by_pattern(const char *pkg, void *cookie) struct add_matching_arg { lpkg_head_t *pkghead; - size_t got_match; + int got_match; int (*match_fn)(const char *pkg, void *cookie); void *cookie; }; @@ -398,6 +394,7 @@ match_best_file(const char *filename, void *cookie) return 0; default: errx(EXIT_FAILURE, "Invalid error from pkg_order"); + /* NOTREACHED */ } } diff --git a/pkgtools/pkg_install/files/lib/lib.h b/pkgtools/pkg_install/files/lib/lib.h index b7e073702fc..1ffa3261f35 100644 --- a/pkgtools/pkg_install/files/lib/lib.h +++ b/pkgtools/pkg_install/files/lib/lib.h @@ -1,4 +1,4 @@ -/* $NetBSD: lib.h,v 1.55 2009/04/25 21:31:13 joerg Exp $ */ +/* $NetBSD: lib.h,v 1.56 2009/08/02 17:56:45 joerg Exp $ */ /* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */ @@ -65,6 +65,10 @@ #endif /* Macros */ +#ifndef __UNCONST +#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) +#endif + #define SUCCESS (0) #define FAIL (-1) @@ -251,7 +255,6 @@ int some_installed_package_conflicts_with(const char *, const char *, char **, c /* Prototypes */ /* Misc */ -void cleanup(int); void show_version(void); int fexec(const char *, ...); int fexec_skipempty(const char *, ...); @@ -325,7 +328,7 @@ void process_pkg_path(void); plist_t *new_plist_entry(void); plist_t *last_plist(package_t *); plist_t *find_plist(package_t *, pl_ent_t); -char *find_plist_option(package_t *, char *); +char *find_plist_option(package_t *, const char *); void plist_delete(package_t *, Boolean, pl_ent_t, char *); void free_plist(package_t *); void mark_plist(package_t *); diff --git a/pkgtools/pkg_install/files/lib/license.c b/pkgtools/pkg_install/files/lib/license.c index 1723b468e84..164cd87cf81 100644 --- a/pkgtools/pkg_install/files/lib/license.c +++ b/pkgtools/pkg_install/files/lib/license.c @@ -1,4 +1,4 @@ -/* $NetBSD: license.c,v 1.8 2009/07/26 09:18:29 wiz Exp $ */ +/* $NetBSD: license.c,v 1.9 2009/08/02 17:56:45 joerg Exp $ */ /*- * Copyright (c) 2009 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -265,8 +265,6 @@ acceptable_pkg_license_internal(const char **licensep, int toplevel, const char } license += len; } - - return is_true; } int diff --git a/pkgtools/pkg_install/files/lib/pkcs7.c b/pkgtools/pkg_install/files/lib/pkcs7.c index 6ebe4ebe578..0fd4f245c1e 100644 --- a/pkgtools/pkg_install/files/lib/pkcs7.c +++ b/pkgtools/pkg_install/files/lib/pkcs7.c @@ -1,4 +1,4 @@ -/* $NetBSD: pkcs7.c,v 1.4 2009/03/02 14:59:14 joerg Exp $ */ +/* $NetBSD: pkcs7.c,v 1.5 2009/08/02 17:56:45 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" #endif @@ -7,7 +7,7 @@ #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: pkcs7.c,v 1.4 2009/03/02 14:59:14 joerg Exp $"); +__RCSID("$NetBSD: pkcs7.c,v 1.5 2009/08/02 17:56:45 joerg Exp $"); /*- * Copyright (c) 2004, 2008 The NetBSD Foundation, Inc. @@ -51,15 +51,11 @@ __RCSID("$NetBSD: pkcs7.c,v 1.4 2009/03/02 14:59:14 joerg Exp $"); #include "lib.h" -#ifndef __UNCONST -#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) -#endif - #ifndef NS_ANY_CA #define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) #endif -static const int pkg_key_usage = XKU_CODE_SIGN | XKU_SMIME; +static const unsigned int pkg_key_usage = XKU_CODE_SIGN | XKU_SMIME; static int check_ca(X509 *cert) diff --git a/pkgtools/pkg_install/files/lib/pkg_signature.c b/pkgtools/pkg_install/files/lib/pkg_signature.c index 710482e56a9..e0cea4251b1 100644 --- a/pkgtools/pkg_install/files/lib/pkg_signature.c +++ b/pkgtools/pkg_install/files/lib/pkg_signature.c @@ -1,4 +1,4 @@ -/* $NetBSD: pkg_signature.c,v 1.8 2009/04/22 19:18:06 joerg Exp $ */ +/* $NetBSD: pkg_signature.c,v 1.9 2009/08/02 17:56:45 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: pkg_signature.c,v 1.8 2009/04/22 19:18:06 joerg Exp $"); +__RCSID("$NetBSD: pkg_signature.c,v 1.9 2009/08/02 17:56:45 joerg Exp $"); /*- * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -201,7 +201,7 @@ retry: *len = archive_entry_size(*entry); *content = xmalloc(*len + 1); - if (archive_read_data(archive, *content, *len) != *len) { + if (archive_read_data(archive, *content, *len) != (ssize_t)*len) { warnx("cannot read complete %s from archive", fname); free(*content); *len = 0; @@ -262,7 +262,7 @@ parse_hash_file(const char *hash_file, char **pkgname, errno = 0; if (!isdigit((unsigned char)*hash_file)) goto cleanup; - if (sizeof(off_t) >= sizeof(long long)) + if (/* CONSTCOND */sizeof(off_t) >= sizeof(long long)) state->pkg_size = strtoll(hash_file, &next, 10); else state->pkg_size = strtol(hash_file, &next, 10); @@ -548,11 +548,11 @@ pkg_sign_x509(const char *name, const char *output, const char *key_file, const free(pkgname); for (i = 0; i < archive_entry_size(entry); i += block_len) { - if (i + sizeof(block) < archive_entry_size(entry)) + if (i + (off_t)sizeof(block) < archive_entry_size(entry)) block_len = sizeof(block); else block_len = archive_entry_size(entry) % sizeof(block); - if (read(fd, block, block_len) != block_len) + if (read(fd, block, block_len) != (ssize_t)block_len) err(2, "short read"); hash_block(block, block_len, hash); tmp = xasprintf("%s%s\n", hash_file, hash); @@ -597,11 +597,11 @@ pkg_sign_x509(const char *name, const char *output, const char *key_file, const archive_write_header(pkg, entry); for (i = 0; i < size; i += block_len) { - if (i + sizeof(block) < size) + if (i + (off_t)sizeof(block) < size) block_len = sizeof(block); else block_len = size % sizeof(block); - if (read(fd, block, block_len) != block_len) + if (read(fd, block, block_len) != (ssize_t)block_len) err(2, "short read"); archive_write_data(pkg, block, block_len); } @@ -642,11 +642,11 @@ pkg_sign_gpg(const char *name, const char *output) free(pkgname); for (i = 0; i < archive_entry_size(entry); i += block_len) { - if (i + sizeof(block) < archive_entry_size(entry)) + if (i + (off_t)sizeof(block) < archive_entry_size(entry)) block_len = sizeof(block); else block_len = archive_entry_size(entry) % sizeof(block); - if (read(fd, block, block_len) != block_len) + if (read(fd, block, block_len) != (ssize_t)block_len) err(2, "short read"); hash_block(block, block_len, hash); tmp = xasprintf("%s%s\n", hash_file, hash); @@ -691,11 +691,11 @@ pkg_sign_gpg(const char *name, const char *output) archive_write_header(pkg, entry); for (i = 0; i < size; i += block_len) { - if (i + sizeof(block) < size) + if (i + (off_t)sizeof(block) < size) block_len = sizeof(block); else block_len = size % sizeof(block); - if (read(fd, block, block_len) != block_len) + if (read(fd, block, block_len) != (ssize_t)block_len) err(2, "short read"); archive_write_data(pkg, block, block_len); } diff --git a/pkgtools/pkg_install/files/lib/pkgdb.c b/pkgtools/pkg_install/files/lib/pkgdb.c index e319e039139..4ed4550b0e2 100644 --- a/pkgtools/pkg_install/files/lib/pkgdb.c +++ b/pkgtools/pkg_install/files/lib/pkgdb.c @@ -1,4 +1,4 @@ -/* $NetBSD: pkgdb.c,v 1.33 2009/02/03 13:49:56 joerg Exp $ */ +/* $NetBSD: pkgdb.c,v 1.34 2009/08/02 17:56:45 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: pkgdb.c,v 1.33 2009/02/03 13:49:56 joerg Exp $"); +__RCSID("$NetBSD: pkgdb.c,v 1.34 2009/08/02 17:56:45 joerg Exp $"); /*- * Copyright (c) 1999-2008 The NetBSD Foundation, Inc. @@ -138,9 +138,9 @@ pkgdb_store(const char *key, const char *val) if (pkgdbp == NULL) return -1; - keyd.data = (void *) key; + keyd.data = __UNCONST(key); keyd.size = strlen(key) + 1; - vald.data = (void *) val; + vald.data = __UNCONST(val); vald.size = strlen(val) + 1; if (keyd.size > MaxPathSize || vald.size > MaxPathSize) @@ -164,7 +164,7 @@ pkgdb_retrieve(const char *key) if (pkgdbp == NULL) return NULL; - keyd.data = (void *) key; + keyd.data = __UNCONST(key); keyd.size = strlen(key) + 1; errno = 0; /* to be sure it's 0 if the key doesn't match anything */ @@ -214,7 +214,7 @@ pkgdb_remove(const char *key) if (pkgdbp == NULL) return -1; - keyd.data = (char *) key; + keyd.data = __UNCONST(key); keyd.size = strlen(key) + 1; if (keyd.size > MaxPathSize) return -1; @@ -235,7 +235,7 @@ pkgdb_remove_pkg(const char *pkg) DBT key; int type; int ret; - int cc; + size_t cc; char cachename[MaxPathSize]; if (pkgdbp == NULL) { @@ -273,7 +273,7 @@ pkgdb_refcount_dir(void) static char buf[MaxPathSize]; char *tmp; - if ((tmp = getenv(PKG_REFCOUNT_DBDIR_VNAME))) + if ((tmp = getenv(PKG_REFCOUNT_DBDIR_VNAME)) != NULL) strlcpy(buf, tmp, sizeof(buf)); else snprintf(buf, sizeof(buf), "%s.refcount", _pkgdb_getPKGDB_DIR()); @@ -299,7 +299,7 @@ _pkgdb_getPKGDB_DIR(void) char *tmp; if (pkgdb_dir == NULL) { - if ((tmp = getenv(PKG_DBDIR))) + if ((tmp = getenv(PKG_DBDIR)) != NULL) _pkgdb_setPKGDB_DIR(tmp); else _pkgdb_setPKGDB_DIR(DEF_LOG_DIR); diff --git a/pkgtools/pkg_install/files/lib/plist.c b/pkgtools/pkg_install/files/lib/plist.c index 5489a396354..1ae5dcaff56 100644 --- a/pkgtools/pkg_install/files/lib/plist.c +++ b/pkgtools/pkg_install/files/lib/plist.c @@ -1,4 +1,4 @@ -/* $NetBSD: plist.c,v 1.28 2009/04/24 14:00:26 joerg Exp $ */ +/* $NetBSD: plist.c,v 1.29 2009/08/02 17:56:45 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: plist.c,v 1.28 2009/04/24 14:00:26 joerg Exp $"); +__RCSID("$NetBSD: plist.c,v 1.29 2009/08/02 17:56:45 joerg Exp $"); /* * FreeBSD install - a package for the installation and maintainance @@ -182,7 +182,7 @@ find_plist(package_t *pkg, pl_ent_t type) * Look for a specific boolean option argument in the list */ char * -find_plist_option(package_t *pkg, char *name) +find_plist_option(package_t *pkg, const char *name) { plist_t *p; @@ -265,6 +265,8 @@ plist_cmd(const char *s, char **arg) const char *cp, *sp; char *sp2; + sp = NULL; /* Older GCC can't detect that the loop is executed */ + for (cmdp = cmdv; cmdp->c_s; ++cmdp) { for (sp = s, cp = cmdp->c_s; *sp && *cp; ++cp, ++sp) if (*sp != *cp) @@ -463,11 +465,11 @@ stringify_plist(package_t *pkg, char **real_buf, size_t *real_len, #define UPDATE_LEN \ do { \ - if (item_len < 0 || item_len > len) \ + if (item_len < 0 || (size_t)item_len > len) \ errx(2, "Size computation failed, aborted."); \ buf += item_len; \ len -= item_len; \ -} while (0) +} while (/* CONSTCOND */0) for (p = pkg->head; p; p = p->next) { if (p->type == PLIST_FILE) { @@ -508,7 +510,7 @@ delete_package(Boolean ign_err, package_t *pkg, Boolean NoDeleteFiles, const char *destdir) { plist_t *p; - char *last_file = ""; + const char *last_file = ""; int fail = SUCCESS; Boolean preserve; char tmp[MaxPathSize]; @@ -579,7 +581,6 @@ delete_package(Boolean ign_err, package_t *pkg, Boolean NoDeleteFiles, if (NoDeleteFiles) break; format_cmd(tmp, sizeof(tmp), p->name, prefix, last_file); - /* XXX cleanup(0); */ printf("Executing `%s'\n", tmp); if (!Fake && system(tmp)) { warnx("unexec command for `%s' failed", tmp); diff --git a/pkgtools/pkg_install/files/lib/remove.c b/pkgtools/pkg_install/files/lib/remove.c index 03249766e45..9c08da7b1bb 100644 --- a/pkgtools/pkg_install/files/lib/remove.c +++ b/pkgtools/pkg_install/files/lib/remove.c @@ -1,4 +1,4 @@ -/* $NetBSD: remove.c,v 1.2 2009/02/02 12:35:01 joerg Exp $ */ +/* $NetBSD: remove.c,v 1.3 2009/08/02 17:56:45 joerg Exp $ */ /*- * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -39,7 +39,7 @@ #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: remove.c,v 1.2 2009/02/02 12:35:01 joerg Exp $"); +__RCSID("$NetBSD: remove.c,v 1.3 2009/08/02 17:56:45 joerg Exp $"); #if HAVE_DIRENT_H #include <dirent.h> @@ -75,7 +75,7 @@ static int long_remove(const char **path_ptr, int missing_ok, int *did_chdir) { char tmp_path[PATH_MAX + 1]; - const char *slash, *path; + const char *path; size_t i, len; int rv; @@ -84,7 +84,6 @@ long_remove(const char **path_ptr, int missing_ok, int *did_chdir) *did_chdir = 0; while (len >= PATH_MAX) { - slash = path; for (i = PATH_MAX - 1; i > 0; --i) { if (path[i] == '/') break; diff --git a/pkgtools/pkg_install/files/lib/var.c b/pkgtools/pkg_install/files/lib/var.c index af93f456557..c2c57f322e0 100644 --- a/pkgtools/pkg_install/files/lib/var.c +++ b/pkgtools/pkg_install/files/lib/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.7 2009/02/02 12:35:01 joerg Exp $ */ +/* $NetBSD: var.c,v 1.8 2009/08/02 17:56:45 joerg Exp $ */ /*- * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: var.c,v 1.7 2009/02/02 12:35:01 joerg Exp $"); +__RCSID("$NetBSD: var.c,v 1.8 2009/08/02 17:56:45 joerg Exp $"); #if HAVE_SYS_STAT_H #include <sys/stat.h> @@ -65,7 +65,7 @@ static void var_print(FILE *, const char *, const char *); int var_copy_list(const char *buf, const char **variables) { - const char *eol, *next, *p; + const char *eol, *next; size_t len; int i; @@ -79,8 +79,8 @@ var_copy_list(const char *buf, const char **variables) } for (i=0; variables[i]; i++) { - if ((p=var_cmp(buf, len, variables[i], - strlen(variables[i]))) != NULL) { + if (var_cmp(buf, len, variables[i], + strlen(variables[i])) != NULL) { printf("%.*s\n", (int)len, buf); break; } diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h index 4f86de4c552..e78635a5028 100644 --- a/pkgtools/pkg_install/files/lib/version.h +++ b/pkgtools/pkg_install/files/lib/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.132 2009/07/24 19:06:45 joerg Exp $ */ +/* $NetBSD: version.h,v 1.133 2009/08/02 17:56:45 joerg Exp $ */ /* * Copyright (c) 2001 Thomas Klausner. All rights reserved. @@ -27,6 +27,6 @@ #ifndef _INST_LIB_VERSION_H_ #define _INST_LIB_VERSION_H_ -#define PKGTOOLS_VERSION "20090724" +#define PKGTOOLS_VERSION "20090727" #endif /* _INST_LIB_VERSION_H_ */ |