From 493d34104827f85a7b74c37bea6c812f61643de7 Mon Sep 17 00:00:00 2001 From: mrg Date: Mon, 20 Jun 2011 09:11:16 +0000 Subject: [PATCH] various build fixes for gcc 4.5. from chuq. XXX i'm not sure all of these work properly wtf pointer aliasing, but there are no casts at least... the lib/libpuffs/puffs_priv.h is definately a real bug fix. from chuq. --- common/lib/libc/gen/rb.c | 8 +++---- crypto/dist/heimdal/lib/krb5/convert_creds.c | 4 ++-- crypto/dist/heimdal/lib/krb5/init_creds_pw.c | 4 ++-- crypto/dist/heimdal/lib/krb5/rd_req.c | 4 ++-- .../external/bsd/openssh/dist/progressmeter.c | 6 ++--- external/bsd/bind/dist/lib/isc/unix/time.c | 4 ++-- .../openldap/dist/libraries/liblutil/detach.c | 4 ++-- lib/libc/compat/sys/compat_getdents.c | 9 +++++--- lib/libc/db/btree/bt_split.c | 23 +++++++++++-------- lib/libc/db/recno/rec_put.c | 6 ++--- lib/libc/gdtoa/strtof.c | 7 +++++- lib/libc/rpc/clnt_dg.c | 16 ++++++------- lib/libedit/eln.c | 6 ++--- lib/libpuffs/puffs_priv.h | 4 ++-- sys/arch/amd64/include/stdarg.h | 7 +++++- 15 files changed, 65 insertions(+), 47 deletions(-) diff --git a/common/lib/libc/gen/rb.c b/common/lib/libc/gen/rb.c index 3827182f5e14..098ab6cd1553 100644 --- a/common/lib/libc/gen/rb.c +++ b/common/lib/libc/gen/rb.c @@ -1,4 +1,4 @@ -/* $NetBSD: rb.c,v 1.10 2011/04/12 16:19:44 matt Exp $ */ +/* $NetBSD: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -39,10 +39,10 @@ #else #define KASSERT(s) do { } while (/*CONSTCOND*/ 0) #endif -__RCSID("$NetBSD: rb.c,v 1.10 2011/04/12 16:19:44 matt Exp $"); +__RCSID("$NetBSD: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp $"); #else #include -__KERNEL_RCSID(0, "$NetBSD: rb.c,v 1.10 2011/04/12 16:19:44 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp $"); #endif #ifdef _LIBC @@ -91,7 +91,7 @@ rb_tree_init(struct rb_tree *rbt, const rb_tree_ops_t *ops) { rbt->rbt_ops = ops; - *((const struct rb_node **)&rbt->rbt_root) = RB_SENTINEL_NODE; + rbt->rbt_root = RB_SENTINEL_NODE; RB_TAILQ_INIT(&rbt->rbt_nodes); #ifndef RBSMALL rbt->rbt_minmax[RB_DIR_LEFT] = rbt->rbt_root; /* minimum node */ diff --git a/crypto/dist/heimdal/lib/krb5/convert_creds.c b/crypto/dist/heimdal/lib/krb5/convert_creds.c index a3cab395013b..6d56554b4d2d 100644 --- a/crypto/dist/heimdal/lib/krb5/convert_creds.c +++ b/crypto/dist/heimdal/lib/krb5/convert_creds.c @@ -33,7 +33,7 @@ #include "krb5_locl.h" __RCSID("$Heimdal: convert_creds.c 22050 2007-11-11 11:20:46Z lha $" - "$NetBSD: convert_creds.c,v 1.2 2008/03/22 08:37:13 mlelstv Exp $"); + "$NetBSD: convert_creds.c,v 1.3 2011/06/20 09:11:16 mrg Exp $"); #include "krb5-v4compat.h" @@ -172,7 +172,7 @@ krb524_convert_creds_kdc_ccache(krb5_context context, keytype = v5_creds->session.keytype; - if (keytype != ENCTYPE_DES_CBC_CRC) { + if (keytype != (krb5_keytype)ENCTYPE_DES_CBC_CRC) { /* MIT krb524d doesn't like nothing but des-cbc-crc tickets, so go get one */ krb5_creds template; diff --git a/crypto/dist/heimdal/lib/krb5/init_creds_pw.c b/crypto/dist/heimdal/lib/krb5/init_creds_pw.c index 041342f95979..56b99b4ecafe 100644 --- a/crypto/dist/heimdal/lib/krb5/init_creds_pw.c +++ b/crypto/dist/heimdal/lib/krb5/init_creds_pw.c @@ -34,7 +34,7 @@ #include "krb5_locl.h" __RCSID("$Heimdal: init_creds_pw.c 21931 2007-08-27 14:11:55Z lha $" - "$NetBSD: init_creds_pw.c,v 1.2 2008/03/22 08:37:13 mlelstv Exp $"); + "$NetBSD: init_creds_pw.c,v 1.3 2011/06/20 09:11:16 mrg Exp $"); typedef struct krb5_get_init_creds_ctx { KDCOptions flags; @@ -806,7 +806,7 @@ pa_pw_or_afs3_salt(krb5_context context, heim_octet_string *data) { krb5_error_code ret; - if (paid->etype == ENCTYPE_NULL) + if (paid->etype == (krb5_enctype)ENCTYPE_NULL) return NULL; ret = set_paid(paid, context, paid->etype, diff --git a/crypto/dist/heimdal/lib/krb5/rd_req.c b/crypto/dist/heimdal/lib/krb5/rd_req.c index 7239404ed985..eac6461930b1 100644 --- a/crypto/dist/heimdal/lib/krb5/rd_req.c +++ b/crypto/dist/heimdal/lib/krb5/rd_req.c @@ -34,7 +34,7 @@ #include __RCSID("$Heimdal: rd_req.c 22235 2007-12-08 21:52:07Z lha $" - "$NetBSD: rd_req.c,v 1.2 2008/03/22 08:37:15 mlelstv Exp $"); + "$NetBSD: rd_req.c,v 1.3 2011/06/20 09:11:16 mrg Exp $"); static krb5_error_code decrypt_tkt_enc_part (krb5_context context, @@ -482,7 +482,7 @@ krb5_verify_ap_req2(krb5_context context, if (ap_req_options) { *ap_req_options = 0; - if (ac->keytype != ETYPE_NULL) + if (ac->keytype != (krb5_keytype)ETYPE_NULL) *ap_req_options |= AP_OPTS_USE_SUBKEY; if (ap_req->ap_options.use_session_key) *ap_req_options |= AP_OPTS_USE_SESSION_KEY; diff --git a/crypto/external/bsd/openssh/dist/progressmeter.c b/crypto/external/bsd/openssh/dist/progressmeter.c index 3fd63074becf..1e9cd6884ed2 100644 --- a/crypto/external/bsd/openssh/dist/progressmeter.c +++ b/crypto/external/bsd/openssh/dist/progressmeter.c @@ -1,4 +1,4 @@ -/* $NetBSD: progressmeter.c,v 1.2 2009/06/07 22:38:47 christos Exp $ */ +/* $NetBSD: progressmeter.c,v 1.3 2011/06/20 09:11:16 mrg Exp $ */ /* $OpenBSD: progressmeter.c,v 1.37 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2003 Nils Nordman. All rights reserved. @@ -25,7 +25,7 @@ */ #include "includes.h" -__RCSID("$NetBSD: progressmeter.c,v 1.2 2009/06/07 22:38:47 christos Exp $"); +__RCSID("$NetBSD: progressmeter.c,v 1.3 2011/06/20 09:11:16 mrg Exp $"); #include #include #include @@ -182,7 +182,7 @@ refresh_progress_meter(void) percent = ((float)cur_pos / end_pos) * 100; else percent = 100; - snprintf(buf + strlen(buf), win_size - strlen(buf-8), + snprintf(buf + strlen(buf), win_size - strlen(buf) - 8, " %3d%% ", percent); /* amount transferred */ diff --git a/external/bsd/bind/dist/lib/isc/unix/time.c b/external/bsd/bind/dist/lib/isc/unix/time.c index 7828a3bb0628..4f9240ea1548 100644 --- a/external/bsd/bind/dist/lib/isc/unix/time.c +++ b/external/bsd/bind/dist/lib/isc/unix/time.c @@ -1,4 +1,4 @@ -/* $NetBSD: time.c,v 1.2 2011/02/16 03:47:15 christos Exp $ */ +/* $NetBSD: time.c,v 1.3 2011/06/20 09:11:16 mrg Exp $ */ /* * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") @@ -373,7 +373,7 @@ isc_time_secondsastimet(const isc_time_t *t, time_t *secondsp) { (time_t)0.5 != 0.5 && /* Not a floating point type. */ (i = (time_t)-1) != 4294967295u && /* Is signed. */ (seconds & - (1U << (sizeof(time_t) * CHAR_BIT - 1))) != 0U) { /* Negative. */ + (1ULL << (sizeof(time_t) * CHAR_BIT - 1))) != 0ULL) { /* Negative. */ /* * This UNUSED() is here to shut up the IRIX compiler: * variable "i" was set but never used diff --git a/external/bsd/openldap/dist/libraries/liblutil/detach.c b/external/bsd/openldap/dist/libraries/liblutil/detach.c index e3919ff9a86f..4d995a1b6285 100644 --- a/external/bsd/openldap/dist/libraries/liblutil/detach.c +++ b/external/bsd/openldap/dist/libraries/liblutil/detach.c @@ -1,4 +1,4 @@ -/* $NetBSD: detach.c,v 1.1.1.3 2010/12/12 15:22:08 adam Exp $ */ +/* $NetBSD: detach.c,v 1.2 2011/06/20 09:11:17 mrg Exp $ */ /* detach.c -- routines to daemonize a process */ /* OpenLDAP: pkg/ldap/libraries/liblutil/detach.c,v 1.18.2.5 2010/04/13 20:23:05 kurt Exp */ @@ -130,7 +130,7 @@ lutil_detach( int debug, int do_close ) #ifdef HAVE_SETSID (void) setsid(); -#elif TIOCNOTTY +#elif defined(TIOCNOTTY) if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) { (void) ioctl( sd, TIOCNOTTY, NULL ); (void) close( sd ); diff --git a/lib/libc/compat/sys/compat_getdents.c b/lib/libc/compat/sys/compat_getdents.c index 20a70e498d95..5d0b3b6c33c0 100644 --- a/lib/libc/compat/sys/compat_getdents.c +++ b/lib/libc/compat/sys/compat_getdents.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat_getdents.c,v 1.3 2008/04/28 20:22:59 martin Exp $ */ +/* $NetBSD: compat_getdents.c,v 1.4 2011/06/20 09:11:17 mrg Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_getdents.c,v 1.3 2008/04/28 20:22:59 martin Exp $"); +__RCSID("$NetBSD: compat_getdents.c,v 1.4 2011/06/20 09:11:17 mrg Exp $"); #endif /* LIBC_SCCS and not lint */ #define __LIBC12_SOURCE__ @@ -50,6 +50,7 @@ getdents(int fd, char *buf, size_t nbytes) { struct dirent *ndp, *nndp, *endp; struct dirent12 *odp; + ino_t ino; int rv; if ((rv = __getdents30(fd, buf, nbytes)) == -1) @@ -67,7 +68,9 @@ getdents(int fd, char *buf, size_t nbytes) for (; ndp < endp; ndp = nndp) { nndp = _DIRENT_NEXT(ndp); /* XXX: avoid unaligned 64-bit access on sparc64 */ - odp->d_ino = ((u_int32_t *)(void *)&ndp->d_ino)[_QUAD_LOWWORD]; + /* XXX: does this work? */ + memcpy(&ino, &ndp->d_ino, sizeof(ino_t)); + odp->d_ino = (uint32_t)ino; if (ndp->d_namlen >= sizeof(odp->d_name)) odp->d_namlen = sizeof(odp->d_name) - 1; else diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c index 8a97501b5d50..f7356c7e30d8 100644 --- a/lib/libc/db/btree/bt_split.c +++ b/lib/libc/db/btree/bt_split.c @@ -1,4 +1,4 @@ -/* $NetBSD: bt_split.c,v 1.19 2009/04/22 18:44:06 christos Exp $ */ +/* $NetBSD: bt_split.c,v 1.20 2011/06/20 09:11:17 mrg Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -37,7 +37,7 @@ #endif #include -__RCSID("$NetBSD: bt_split.c,v 1.19 2009/04/22 18:44:06 christos Exp $"); +__RCSID("$NetBSD: bt_split.c,v 1.20 2011/06/20 09:11:17 mrg Exp $"); #include "namespace.h" #include @@ -245,10 +245,12 @@ __bt_split(BTREE *t, PAGE *sp, const DBT *key, const DBT *data, int flags, WR_BINTERNAL(dest, nksize ? nksize : bl->ksize, rchild->pgno, bl->flags & P_BIGKEY); memmove(dest, bl->bytes, nksize ? nksize : bl->ksize); - if (bl->flags & P_BIGKEY && - bt_preserve(t, *(pgno_t *)(void *)bl->bytes) == - RET_ERROR) - goto err1; + if (bl->flags & P_BIGKEY) { + pgno_t pgno; + memcpy(&pgno, bl->bytes, sizeof(pgno)); + if (bt_preserve(t, pgno) == RET_ERROR) + goto err1; + } break; case P_RINTERNAL: /* @@ -564,9 +566,12 @@ bt_broot(BTREE *t, PAGE *h, PAGE *l, PAGE *r) * If the key is on an overflow page, mark the overflow chain * so it isn't deleted when the leaf copy of the key is deleted. */ - if (bl->flags & P_BIGKEY && - bt_preserve(t, *(pgno_t *)(void *)bl->bytes) == RET_ERROR) - return (RET_ERROR); + if (bl->flags & P_BIGKEY) { + pgno_t pgno; + memcpy(&pgno, bl->bytes, sizeof(pgno)); + if (bt_preserve(t, pgno) == RET_ERROR) + return (RET_ERROR); + } break; case P_BINTERNAL: bi = GETBINTERNAL(r, 0); diff --git a/lib/libc/db/recno/rec_put.c b/lib/libc/db/recno/rec_put.c index 7c1181c6428a..c8dddd286683 100644 --- a/lib/libc/db/recno/rec_put.c +++ b/lib/libc/db/recno/rec_put.c @@ -1,4 +1,4 @@ -/* $NetBSD: rec_put.c,v 1.17 2008/09/11 12:58:00 joerg Exp $ */ +/* $NetBSD: rec_put.c,v 1.18 2011/06/20 09:11:17 mrg Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -34,7 +34,7 @@ #endif #include -__RCSID("$NetBSD: rec_put.c,v 1.17 2008/09/11 12:58:00 joerg Exp $"); +__RCSID("$NetBSD: rec_put.c,v 1.18 2011/06/20 09:11:17 mrg Exp $"); #include "namespace.h" #include @@ -208,7 +208,7 @@ __rec_iput(BTREE *t, recno_t nrec, const DBT *data, u_int flags) return (RET_ERROR); tdata.data = db; tdata.size = NOVFLSIZE; - *(pgno_t *)(void *)db = pg; + memcpy(db, &pg, sizeof(*db)); _DBFIT(data->size, uint32_t); *(uint32_t *)(void *)(db + sizeof(pgno_t)) = (uint32_t)data->size; diff --git a/lib/libc/gdtoa/strtof.c b/lib/libc/gdtoa/strtof.c index 3226c519ad86..bee802fffc44 100644 --- a/lib/libc/gdtoa/strtof.c +++ b/lib/libc/gdtoa/strtof.c @@ -1,4 +1,4 @@ -/* $NetBSD: strtof.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */ +/* $NetBSD: strtof.c,v 1.5 2011/06/20 09:11:17 mrg Exp $ */ /**************************************************************** @@ -82,6 +82,11 @@ strtof(CONST char *s, char **sp) case STRTOG_NaN: u.L[0] = f_QNAN; + break; + + default: + u.L[0] = 0; /* for gcc warning */ + break; } if (k & STRTOG_Neg) u.L[0] |= 0x80000000L; diff --git a/lib/libc/rpc/clnt_dg.c b/lib/libc/rpc/clnt_dg.c index d077878a0b4e..22fb893bcaf3 100644 --- a/lib/libc/rpc/clnt_dg.c +++ b/lib/libc/rpc/clnt_dg.c @@ -1,4 +1,4 @@ -/* $NetBSD: clnt_dg.c,v 1.24 2010/12/08 02:06:38 joerg Exp $ */ +/* $NetBSD: clnt_dg.c,v 1.25 2011/06/20 09:11:17 mrg Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro"; #else -__RCSID("$NetBSD: clnt_dg.c,v 1.24 2010/12/08 02:06:38 joerg Exp $"); +__RCSID("$NetBSD: clnt_dg.c,v 1.25 2011/06/20 09:11:17 mrg Exp $"); #endif #endif @@ -415,12 +415,12 @@ send_again: cu->cu_error.re_status = RPC_CANTRECV; goto out; } - if (recvlen >= (ssize_t)sizeof(uint32_t) && - (*((uint32_t *)(void *)(cu->cu_inbuf)) == - *((uint32_t *)(void *)(cu->cu_outbuf)))) { - /* We now assume we have the proper reply. */ - break; - } + if (recvlen >= (ssize_t)sizeof(uint32_t)) { + if (memcmp(cu->cu_inbuf, cu->cu_outbuf, + sizeof(uint32_t)) == 0) + /* Assume we have the proper reply. */ + break; + } } if (n == -1) { cu->cu_error.re_errno = errno; diff --git a/lib/libedit/eln.c b/lib/libedit/eln.c index 04e992fbad2b..ee6bb917efcc 100644 --- a/lib/libedit/eln.c +++ b/lib/libedit/eln.c @@ -1,4 +1,4 @@ -/* $NetBSD: eln.c,v 1.9 2010/11/04 13:53:12 christos Exp $ */ +/* $NetBSD: eln.c,v 1.10 2011/06/20 09:11:17 mrg Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: eln.c,v 1.9 2010/11/04 13:53:12 christos Exp $"); +__RCSID("$NetBSD: eln.c,v 1.10 2011/06/20 09:11:17 mrg Exp $"); #endif /* not lint && not SCCSID */ #include "histedit.h" @@ -275,7 +275,7 @@ el_get(EditLine *el, int op, ...) case EL_RPROMPT_ESC: { el_pfunc_t *p = va_arg(ap, el_pfunc_t *); char *c = va_arg(ap, char *); - wchar_t wc; + wchar_t wc = 0; ret = prompt_get(el, p, &wc, op); *c = (unsigned char)wc; break; diff --git a/lib/libpuffs/puffs_priv.h b/lib/libpuffs/puffs_priv.h index b7369a4bdf75..fe7fe988a7e9 100644 --- a/lib/libpuffs/puffs_priv.h +++ b/lib/libpuffs/puffs_priv.h @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_priv.h,v 1.43 2010/12/06 14:50:34 pooka Exp $ */ +/* $NetBSD: puffs_priv.h,v 1.44 2011/06/20 09:11:17 mrg Exp $ */ /* * Copyright (c) 2006, 2007, 2008 Antti Kantee. All Rights Reserved. @@ -114,7 +114,7 @@ struct puffs_usermount { #define PU_SETSTATE(pu, s) (pu->pu_state = (s) | (pu->pu_state & ~PU_STATEMASK)) #define PU_SETSFLAG(pu, s) (pu->pu_state |= (s)) #define PU_CLRSFLAG(pu, s) \ - (pu->pu_state = ((pu->pu_state &= ~(s)) | (pu->pu_state & PU_STATEMASK))) + (pu->pu_state = ((pu->pu_state & ~(s)) | (pu->pu_state & PU_STATEMASK))) int pu_dpipe[2]; struct puffs_node *pu_pn_root; diff --git a/sys/arch/amd64/include/stdarg.h b/sys/arch/amd64/include/stdarg.h index 7c8b0b4fdc8f..1c91c655222a 100644 --- a/sys/arch/amd64/include/stdarg.h +++ b/sys/arch/amd64/include/stdarg.h @@ -1,4 +1,4 @@ -/* $NetBSD: stdarg.h,v 1.6 2008/10/26 00:08:15 mrg Exp $ */ +/* $NetBSD: stdarg.h,v 1.7 2011/06/20 09:11:17 mrg Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -44,12 +44,17 @@ typedef _BSD_VA_LIST_ va_list; #ifdef __lint__ #define __builtin_next_arg(t) ((t) ? 0 : 0) #define __builtin_stdarg_start(a, l) ((a) = (va_list)(void *)&(l)) +#define __builtin_va_start(a, l) ((a) = (va_list)(void *)&(l)) #define __builtin_va_arg(a, t) ((a) ? (t) 0 : (t) 0) #define __builtin_va_end(a) /* nothing */ #define __builtin_va_copy(d, s) ((d) = (s)) #endif +#if __GNUC_PREREQ__(4, 5) +#define va_start(ap, last) __builtin_va_start((ap), (last)) +#else #define va_start(ap, last) __builtin_stdarg_start((ap), (last)) +#endif #define va_arg __builtin_va_arg #define va_end(ap) __builtin_va_end(ap) #define __va_copy(dest, src) __builtin_va_copy((dest), (src))