Re: diff: fix compiler warnings of npppd

2012-01-17 Thread Sebastian Reitenbach
On Thursday, January 12, 2012 14:30 CET, YASUOKA Masahiko  
wrote: 
 
> This fixes many compiler warnings and some styles. 
> 
> ok?

since I'm testing npppd to get mobile phone to run, I tested this diff.

The hunk to npppd/npppd_radius.c doesn't apply, seems to be already in the tree:

Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--
|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 -   1.1
|+++ npppd/npppd_radius.c   15 Oct 2011 07:19:38 -
--
Patching file npppd/npppd_radius.c using Plan A...
Reversed (or previously applied) patch detected!  Assume -R? [y] n
Apply anyway? [n] 
Hunk #1 ignored at 120.
Hunk #2 ignored at 151.
Hunk #3 ignored at 198.
3 out of 3 hunks ignored--saving rejects to npppd/npppd_radius.c.rej

So ignoring this part, the rest applies well, and then compiling is also 
working like a charm, no warnings anymore.
tested on amd63

My OK may probably not count much here but you get it:  
OK sebastia@

cheers,
Sebastian

> 
> 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 -  1.5
> +++ l2tp/l2tp.h   15 Oct 2011 07:19:35 -
> @@ -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 */
> - unsignedid;
> + 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 -  1.7
> +++ l2tp/l2tp_ctrl.c  15 Oct 2011 07:19:36 -
> @@ -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 -   1.3
> +++ l2tp/l2tp_subr.h  15 Oct 2011 07:19:36 -
> @@ -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 -  1.6
> +++ l2tp/l2tpd.c  15 Oct 2011 07:19:36 -
> @@ -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  

diff: fix compiler warnings of npppd

2012-01-12 Thread YASUOKA Masahiko
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 -  1.5
+++ l2tp/l2tp.h 15 Oct 2011 07:19:35 -
@@ -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 */
-   unsignedid;
+   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.c15 Oct 2011 03:24:11 -  1.7
+++ l2tp/l2tp_ctrl.c15 Oct 2011 07:19:36 -
@@ -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.h2 Jul 2010 21:20:57 -   1.3
+++ l2tp/l2tp_subr.h15 Oct 2011 07:19:36 -
@@ -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.c16 Mar 2011 09:49:11 -  1.6
+++ l2tp/l2tpd.c15 Oct 2011 07:19:36 -
@@ -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;
+   intshuffle_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