This fixes many compiler warnings and some styles. ok?
Index: l2tp/l2tp.h =================================================================== RCS file: /cvs/src/usr.sbin/npppd/l2tp/l2tp.h,v retrieving revision 1.5 diff -u -p -r1.5 l2tp.h --- l2tp/l2tp.h 15 Oct 2011 03:24:11 -0000 1.5 +++ l2tp/l2tp.h 15 Oct 2011 07:19:35 -0000 @@ -313,7 +313,7 @@ typedef struct _l2tpd { /** timeout event context */ struct event ev_timeout; /** instance ID */ - unsigned id; + u_int id; /** listener list */ slist listener; /** state */ @@ -347,7 +347,7 @@ typedef struct _l2tpd { typedef struct _l2tp_ctrl { struct event ev_timeout; /** ID */ - unsigned id; + u_int id; /** parent L2TPD */ l2tpd *l2tpd; /** listener index number */ @@ -425,7 +425,7 @@ typedef struct _l2tp_ctrl { */ typedef struct _l2tp_call { /** ID */ - unsigned id; + u_int id; /** state */ int state; /** parent control connection */ @@ -475,10 +475,10 @@ void l2tpd_release_call (l2t int l2tpd_start (l2tpd *); void l2tpd_stop (l2tpd *); void l2tpd_stop_immediatly (l2tpd *); -l2tp_ctrl *l2tpd_get_ctrl (l2tpd *, int); +l2tp_ctrl *l2tpd_get_ctrl (l2tpd *, u_int); void l2tpd_add_ctrl (l2tpd *, l2tp_ctrl *); void l2tpd_ctrl_finished_notify(l2tpd *); -void l2tpd_remove_ctrl (l2tpd *, int); +void l2tpd_remove_ctrl (l2tpd *, u_int); int l2tpd_add_listener (l2tpd *, int, const char *, struct sockaddr *); void l2tpd_log (l2tpd *, int, const char *, ...) __attribute__((__format__ (__printf__, 3, 4))); Index: l2tp/l2tp_ctrl.c =================================================================== RCS file: /cvs/src/usr.sbin/npppd/l2tp/l2tp_ctrl.c,v retrieving revision 1.7 diff -u -p -r1.7 l2tp_ctrl.c --- l2tp/l2tp_ctrl.c 15 Oct 2011 03:24:11 -0000 1.7 +++ l2tp/l2tp_ctrl.c 15 Oct 2011 07:19:36 -0000 @@ -93,7 +93,7 @@ static inline const char *l2tp_ctrl_sta #endif /* Sequence # of l2tp_ctrl ID */ -static unsigned l2tp_ctrl_id_seq = 0; +static u_int l2tp_ctrl_id_seq = 0; #define SEQ_LT(a,b) ((int16_t)((a) - (b)) < 0) #define SEQ_GT(a,b) ((int16_t)((a) - (b)) > 0) Index: l2tp/l2tp_subr.h =================================================================== RCS file: /cvs/src/usr.sbin/npppd/l2tp/l2tp_subr.h,v retrieving revision 1.3 diff -u -p -r1.3 l2tp_subr.h --- l2tp/l2tp_subr.h 2 Jul 2010 21:20:57 -0000 1.3 +++ l2tp/l2tp_subr.h 15 Oct 2011 07:19:36 -0000 @@ -83,13 +83,13 @@ avp_set_val32(struct l2tp_avp *avp, uint static inline int short_cmp(const void *m, const void *n) { - return (int)((int)m - (int)n); + return ((intptr_t)m - (intptr_t)n); } static inline uint32_t short_hash(const void *v, int sz) { - return (int)v % sz; + return ((uintptr_t)v % sz); } /* Index: l2tp/l2tpd.c =================================================================== RCS file: /cvs/src/usr.sbin/npppd/l2tp/l2tpd.c,v retrieving revision 1.6 diff -u -p -r1.6 l2tpd.c --- l2tp/l2tpd.c 16 Mar 2011 09:49:11 -0000 1.6 +++ l2tp/l2tpd.c 15 Oct 2011 07:19:36 -0000 @@ -80,7 +80,7 @@ static inline int short_cmp (const static inline uint32_t short_hash (const void *, int); /* sequence # of l2tpd ID */ -static unsigned l2tpd_id_seq = 0; +static u_int l2tpd_id_seq = 0; #ifndef USE_LIBSOCKUTIL struct in_ipsec_sa_cookie { }; @@ -99,7 +99,8 @@ struct in_ipsec_sa_cookie { }; int l2tpd_init(l2tpd *_this) { - int i, id, off; + int i, off; + u_int id; struct sockaddr_in sin4; struct sockaddr_in6 sin6; @@ -143,8 +144,8 @@ l2tpd_init(l2tpd *_this) id = (i + off) % L2TP_SESSION_ID_MASK; if (id == 0) id = (off - 1) % L2TP_SESSION_ID_MASK; - if (slist_add(&_this->free_session_id_list, (void *)id) - == NULL) { + if (slist_add(&_this->free_session_id_list, + (void *)(uintptr_t)id) == NULL) { l2tpd_log(_this, LOG_ERR, "slist_add() failed on %s(): %m", __func__); return 1; @@ -254,11 +255,12 @@ l2tpd_uninit(l2tpd *_this) int l2tpd_assign_call(l2tpd *_this, l2tp_call *call) { - int shuffle_cnt, session_id; + int shuffle_cnt; + u_int session_id; shuffle_cnt = 0; do { - session_id = (int)slist_remove_first( + session_id = (uintptr_t)slist_remove_first( &_this->free_session_id_list); if (session_id != L2TP_SESSION_ID_SHUFFLE_MARK) break; @@ -284,7 +286,7 @@ l2tpd_assign_call(l2tpd *_this, l2tp_cal void l2tpd_release_call(l2tpd *_this, l2tp_call *call) { - slist_add(&_this->free_session_id_list, (void *)call->id); + slist_add(&_this->free_session_id_list, (void *)(uintptr_t)call->id); } @@ -861,11 +863,11 @@ l2tpd_io_event(int fd, short evtype, voi * L2TP control */ l2tp_ctrl * -l2tpd_get_ctrl(l2tpd *_this, int tunid) +l2tpd_get_ctrl(l2tpd *_this, unsigned tunid) { hash_link *hl; - hl = hash_lookup(_this->ctrl_map, (void *)tunid); + hl = hash_lookup(_this->ctrl_map, (void *)(uintptr_t)tunid); if (hl == NULL) return NULL; @@ -875,13 +877,13 @@ l2tpd_get_ctrl(l2tpd *_this, int tunid) void l2tpd_add_ctrl(l2tpd *_this, l2tp_ctrl *ctrl) { - hash_insert(_this->ctrl_map, (void *)ctrl->tunnel_id, ctrl); + hash_insert(_this->ctrl_map, (void *)(uintptr_t)ctrl->tunnel_id, ctrl); } void -l2tpd_remove_ctrl(l2tpd *_this, int tunid) +l2tpd_remove_ctrl(l2tpd *_this, unsigned tunid) { - hash_delete(_this->ctrl_map, (void *)tunid, 0); + hash_delete(_this->ctrl_map, (void *)(uintptr_t)tunid, 0); } Index: npppd/npppd.c =================================================================== RCS file: /cvs/src/usr.sbin/npppd/npppd/npppd.c,v retrieving revision 1.12 diff -u -p -r1.12 npppd.c --- npppd/npppd.c 8 Jul 2011 06:14:54 -0000 1.12 +++ npppd/npppd.c 15 Oct 2011 07:19:37 -0000 @@ -1258,7 +1258,7 @@ pipex_periodic(npppd *_this) } for (i = 0; i < req.plr_ppp_id_count; i++) { ppp_id = req.plr_ppp_id[i]; - slist_add(&dlist, (void *)ppp_id); + slist_add(&dlist, (void *)(uintptr_t)ppp_id); } } while (req.plr_flags & PIPEX_LISTREQ_MORE); @@ -1275,7 +1275,7 @@ pipex_periodic(npppd *_this) slist_itr_first(&dlist); while (slist_itr_has_next(&dlist)) { /* FIXME: Linear search by PPP Id eats CPU */ - ppp_id = (int)slist_itr_next(&dlist); + ppp_id = (uintptr_t)slist_itr_next(&dlist); slist_itr_first(&users); ppp = NULL; while (slist_itr_has_next(&users)) { Index: npppd/npppd_ctl.c =================================================================== RCS file: /cvs/src/usr.sbin/npppd/npppd/npppd_ctl.c,v retrieving revision 1.7 diff -u -p -r1.7 npppd_ctl.c --- npppd/npppd_ctl.c 24 Sep 2010 14:50:30 -0000 1.7 +++ npppd/npppd_ctl.c 15 Oct 2011 07:19:38 -0000 @@ -380,7 +380,7 @@ user_end: npppd_ctl_log(_this, LOG_ERR, "Received unknown command %04x", command); } -fail: + return; } Index: npppd/npppd_pool.c =================================================================== RCS file: /cvs/src/usr.sbin/npppd/npppd/npppd_pool.c,v retrieving revision 1.4 diff -u -p -r1.4 npppd_pool.c --- npppd/npppd_pool.c 20 Jul 2010 20:47:17 -0000 1.4 +++ npppd/npppd_pool.c 15 Oct 2011 07:19:38 -0000 @@ -231,8 +231,8 @@ npppd_pool_reload(npppd_pool *_this) continue; if (count >= NPPPD_MAX_POOLED_ADDRS) break; - slist_add(&_this->dyna_addrs, (void *) - (range->addr + i)); + slist_add(&_this->dyna_addrs, + (void *)(uintptr_t)(range->addr + i)); count++; } } @@ -323,7 +323,7 @@ uint32_t npppd_pool_get_dynamic(npppd_pool *_this, npppd_ppp *ppp) { int shuffle_cnt; - void *result = NULL; + uintptr_t result = 0; struct sockaddr_in sin4 = { .sin_len = sizeof(struct sockaddr_in), .sin_family = AF_INET @@ -335,8 +335,8 @@ npppd_pool_get_dynamic(npppd_pool *_this slist_itr_first(&_this->dyna_addrs); while (slist_length(&_this->dyna_addrs) > 1 && slist_itr_has_next(&_this->dyna_addrs)) { - result = slist_itr_next(&_this->dyna_addrs); - if (result == NULL) + result = (uintptr_t)slist_itr_next(&_this->dyna_addrs); + if (result == 0) break; /* shuffle */ if ((uint32_t)result == SHUFLLE_MARK) { @@ -346,13 +346,13 @@ npppd_pool_get_dynamic(npppd_pool *_this * If succeed to get address twice, it means no address to use. */ if (shuffle_cnt++ > 0) { - result = NULL; + result = 0; break; } NPPPD_POOL_DBG((_this, LOG_DEBUG, "shuffle")); slist_itr_remove(&_this->dyna_addrs); slist_shuffle(&_this->dyna_addrs); - slist_add(&_this->dyna_addrs, result); + slist_add(&_this->dyna_addrs, (void *)result); slist_itr_first(&_this->dyna_addrs); continue; } @@ -426,8 +426,7 @@ npppd_pool_assign_ip(npppd_pool *_this, /* If the address contains dynamic pool address list, delete it. */ slist_itr_first(&_this->dyna_addrs); while (slist_itr_has_next(&_this->dyna_addrs)) { - if ((uint32_t)slist_itr_next( - &_this->dyna_addrs) != ip4) + if ((uintptr_t)slist_itr_next(&_this->dyna_addrs) != ip4) continue; slist_itr_remove(&_this->dyna_addrs); break; @@ -499,7 +498,8 @@ npppd_pool_release_ip(npppd_pool *_this, if (_this != NULL && ppp->assign_dynapool != 0) /* return to dynamic address pool list */ slist_add(&((npppd_pool *)ppp->assigned_pool)->dyna_addrs, - (void *)ntohl(ppp->ppp_framed_ip_address.s_addr)); + (void *)(uintptr_t)ntohl( + ppp->ppp_framed_ip_address.s_addr)); if (snp != NULL && snp->snp_next != NULL) { /* Index: npppd/npppd_radius.c =================================================================== RCS file: /cvs/src/usr.sbin/npppd/npppd/npppd_radius.c,v retrieving revision 1.1 diff -u -p -r1.1 npppd_radius.c --- npppd/npppd_radius.c 6 Jul 2011 20:52:28 -0000 1.1 +++ npppd/npppd_radius.c 15 Oct 2011 07:19:38 -0000 @@ -120,7 +120,7 @@ npppd_ppp_radius_acct_reqcb(void *contex { int ppp_id; - ppp_id = (int)context; + ppp_id = (uintptr_t)context; if ((flags & RADIUS_REQUEST_TIMEOUT) != 0) { log_printf(LOG_WARNING, "ppp id=%d radius accounting request " "failed: no response from the server.", ppp_id); @@ -151,7 +151,7 @@ npppd_ppp_radius_acct_reqcb(void *contex sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) != 0) { strlcpy(hbuf, "unknown", sizeof(hbuf)); - strlcpy(sbuf, "", sizeof(hbuf)); + strlcpy(sbuf, "", sizeof(sbuf)); } log_printf(LOG_DEBUG, "ppp id=%d " "fail over to %s:%s for radius accounting request", @@ -198,7 +198,7 @@ radius_acct_request(npppd *pppd, npppd_p == NULL) goto reigai; - if (radius_prepare(rad_setting, (void *)ppp->id, &radctx, + if (radius_prepare(rad_setting, (void *)(uintptr_t)ppp->id, &radctx, npppd_ppp_radius_acct_reqcb, 0) != 0) goto reigai; Index: npppd/ppp.c =================================================================== RCS file: /cvs/src/usr.sbin/npppd/npppd/ppp.c,v retrieving revision 1.9 diff -u -p -r1.9 ppp.c --- npppd/ppp.c 15 Oct 2011 03:24:11 -0000 1.9 +++ npppd/ppp.c 15 Oct 2011 07:19:38 -0000 @@ -388,14 +388,15 @@ ppp_stop0(npppd_ppp *_this) snprintf(mppe_str, sizeof(mppe_str), "mppe=no"); ppp_log(_this, LOG_NOTICE, "logtype=TUNNELUSAGE user=\"%s\" duration=%ldsec layer2=%s " - "layer2from=%s auth=%s data_in=%qubytes,%upackets " - "data_out=%qubytes,%upackets error_in=%u error_out=%u %s " + "layer2from=%s auth=%s data_in=%llubytes,%upackets " + "data_out=%llubytes,%upackets error_in=%u error_out=%u %s " "iface=%s", _this->username[0]? _this->username : "<unknown>", (long)(_this->end_monotime - _this->start_monotime), _this->phy_label, label, _this->username[0]? ppp_peer_auth_string(_this) : "none", - _this->ibytes, _this->ipackets, _this->obytes, _this->opackets, + (unsigned long long)_this->ibytes, _this->ipackets, + (unsigned long long)_this->obytes, _this->opackets, _this->ierrors, _this->oerrors, mppe_str, npppd_ppp_get_iface_name(_this->pppd, _this)); Index: npppd/radius+.c =================================================================== RCS file: /cvs/src/usr.sbin/npppd/npppd/radius+.c,v retrieving revision 1.4 diff -u -p -r1.4 radius+.c --- npppd/radius+.c 6 Jul 2011 20:52:28 -0000 1.4 +++ npppd/radius+.c 15 Oct 2011 07:19:38 -0000 @@ -821,7 +821,8 @@ int radius_put_message_authenticator(RAD { if (attr->type == RADIUS_TYPE_MESSAGE_AUTHENTICATOR) { - memcpy(attr->data, md5result, sizeof(md5result)); + memcpy((u_char *)&attr->data[0], md5result, + sizeof(md5result)); break; } } Index: pppoe/pppoe_session.c =================================================================== RCS file: /cvs/src/usr.sbin/npppd/pppoe/pppoe_session.c,v retrieving revision 1.4 diff -u -p -r1.4 pppoe_session.c --- pppoe/pppoe_session.c 16 Mar 2011 09:48:45 -0000 1.4 +++ pppoe/pppoe_session.c 15 Oct 2011 07:19:39 -0000 @@ -385,8 +385,8 @@ pppoe_session_recv_PADR(pppoe_session *_ goto fail; _this->acookie = *(uint32_t *)(ac_cookie->value); - hash_insert(pppoed0->acookie_hash, (void *)_this->acookie, - _this); + hash_insert(pppoed0->acookie_hash, + (void *)(intptr_t)_this->acookie, _this); } if (pppoe_session_send_PADS(_this, hostuniq, service_name) != 0) Index: pppoe/pppoed.c =================================================================== RCS file: /cvs/src/usr.sbin/npppd/pppoe/pppoed.c,v retrieving revision 1.7 diff -u -p -r1.7 pppoed.c --- pppoe/pppoed.c 28 Feb 2011 02:31:55 -0000 1.7 +++ pppoe/pppoed.c 15 Oct 2011 07:19:39 -0000 @@ -153,7 +153,8 @@ pppoed_init(pppoed *_this) id = (i + off) % 0xffff; if (id == 0) id = (off - 1) % 0xffff; - if (slist_add(&_this->session_free_list, (void *)id) == NULL) { + if (slist_add(&_this->session_free_list, (void *)(intptr_t)id) + == NULL) { pppoed_log(_this, LOG_ERR, "slist_add() failed on %s(): %m", __func__); goto fail; @@ -448,13 +449,15 @@ pppoed_uninit(pppoed *_this) void pppoed_pppoe_session_close_notify(pppoed *_this, pppoe_session *session) { - slist_add(&_this->session_free_list, (void *)session->session_id); + slist_add(&_this->session_free_list, + (void *)(intptr_t)session->session_id); if (_this->acookie_hash != NULL) - hash_delete(_this->acookie_hash, (void *)session->acookie, 0); + hash_delete(_this->acookie_hash, + (void *)(intptr_t)session->acookie, 0); if (_this->session_hash != NULL) - hash_delete(_this->session_hash, (void *)session->session_id, - 0); + hash_delete(_this->session_hash, + (void *)(intptr_t)session->session_id, 0); pppoe_session_fini(session); free(session); @@ -776,7 +779,8 @@ pppoed_input(pppoed_listener *_this, uin } if (session_id != 0) { - hl = hash_lookup(_this->self->session_hash, (void *)session_id); + hl = hash_lookup(_this->self->session_hash, + (void *)(intptr_t)session_id); if (hl != NULL) session = (pppoe_session *)hl->item; } @@ -916,7 +920,7 @@ pppoed_recv_PADR(pppoed_listener *_this, /* create session_id */ shuffle_cnt = 0; do { - session_id = (int)slist_remove_first( + session_id = (intptr_t)slist_remove_first( &_pppoed->session_free_list); if (session_id != PPPOED_SESSION_SHUFFLE_MARK) break; @@ -938,7 +942,8 @@ pppoed_recv_PADR(pppoed_listener *_this, shost) != 0) goto fail; - hash_insert(_pppoed->session_hash, (void *)session_id, session); + hash_insert(_pppoed->session_hash, (void *)(intptr_t)session_id, + session); if (pppoe_session_recv_PADR(session, tag_list) != 0) goto fail; @@ -1070,7 +1075,7 @@ pppoed_recv_PADI(pppoed_listener *_this, _this->self->acookie_next += 1; } while(hash_lookup(_this->self->acookie_hash, - (void *)_this->self->acookie_next) != NULL); + (void *)(intptr_t)_this->self->acookie_next) != NULL); tlv.type = htons(PPPOE_TAG_AC_COOKIE); tlv.length = ntohs(sizeof(uint32_t)); @@ -1201,8 +1206,8 @@ session_id_cmp(void *a, void *b) { int ia, ib; - ia = (int)a; - ib = (int)b; + ia = (intptr_t)a; + ib = (intptr_t)b; return ib - ia; } @@ -1212,7 +1217,7 @@ session_id_hash(void *a, size_t siz) { int ia; - ia = (int)a; + ia = (intptr_t)a; return ia % siz; } Index: pptp/pptpd.c =================================================================== RCS file: /cvs/src/usr.sbin/npppd/pptp/pptpd.c,v retrieving revision 1.8 diff -u -p -r1.8 pptpd.c --- pptp/pptpd.c 20 Jan 2011 23:12:33 -0000 1.8 +++ pptp/pptpd.c 15 Oct 2011 07:19:39 -0000 @@ -245,20 +245,21 @@ pptpd_uninit(pptpd *_this) _this->config = NULL; } -#define CALL_MAP_KEY(call) \ - (void *)(call->id | (call->ctrl->listener_index << 16)) -#define CALL_ID(item) ((uint32_t)item & 0xffff) - +#define CALL_ID_KEY(call_id, listener_idx) \ + ((void *)((uintptr_t)(call_id) | (listener_idx) << 16)) +#define CALL_KEY(call) \ + CALL_ID_KEY((call)->id, (call)->ctrl->listener_index) int pptpd_assign_call(pptpd *_this, pptp_call *call) { - int shuffle_cnt = 0, call_id; + int shuffle_cnt = 0; + u_int call_id; shuffle_cnt = 0; slist_itr_first(&_this->call_free_list); while (slist_length(&_this->call_free_list) > 1 && slist_itr_has_next(&_this->call_free_list)) { - call_id = (int)slist_itr_next(&_this->call_free_list); + call_id = (uintptr_t)slist_itr_next(&_this->call_free_list); if (call_id == 0) break; slist_itr_remove(&_this->call_free_list); @@ -272,7 +273,7 @@ pptpd_assign_call(pptpd *_this, pptp_cal continue; } call->id = call_id; - hash_insert(_this->call_id_map, CALL_MAP_KEY(call), call); + hash_insert(_this->call_id_map, CALL_KEY(call), call); return 0; } @@ -286,8 +287,8 @@ void pptpd_release_call(pptpd *_this, pptp_call *call) { if (call->id != 0) - slist_add(&_this->call_free_list, (void *)call->id); - hash_delete(_this->call_id_map, CALL_MAP_KEY(call), 0); + slist_add(&_this->call_free_list, (void *)(uintptr_t)call->id); + hash_delete(_this->call_id_map, CALL_KEY(call), 0); call->id = 0; } @@ -951,8 +952,7 @@ pptpd_gre_input(pptpd_listener *listener /* route to pptp_call */ call_id = grehdr->call_id; - hl = hash_lookup(_this->call_id_map, - (void *)(call_id | (listener->index << 16))); + hl = hash_lookup(_this->call_id_map, CALL_ID_KEY(call_id, listener->index)); if (hl == NULL) { reason = "Received GRE packet has unknown call_id"; goto bad_gre; @@ -1095,13 +1095,13 @@ pptpd_log(pptpd *_this, int prio, const static int pptp_call_cmp(const void *a0, const void *b0) { - return ((uint32_t)a0 - (uint32_t)b0); + return ((intptr_t)a0 - (intptr_t)b0); } static uint32_t pptp_call_hash(const void *ctx, int size) { - return (uint32_t)ctx % size; + return (uintptr_t)ctx % size; } /* convert GRE packet header to strings */