[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

re: sys/socket.h and source defines



   On Mon, Feb 18, 2002 at 04:51:17PM -0700, Joel Baker wrote:
   > 
   > This is a fix I had considered... but really should happen upstream. I
   > guess perhaps I'll check the CVS version of things, and file a bug if it's
   > still got this problem...
   
   Teach me to check upstream first. PR 10791 under NetBSD. Of course, the
   only way to get the fix natively is to run -current... and I'm not sure
   what the consequences of backporting only that file would be (need to get
   it and diff it against current).

hmm... i vaguely remember this :-)

revision 1.60
date: 2001/05/05 12:47:58;  author: kleink;  state: Exp;  lines: +7 -7
branches:  1.60.2;
* Replace a couple of cases of u_char and u_short with uint8_t and uint16_t,
  respectively.
* Simplify sockaddr_storage calculations a bit by the fact that, per defintion,
  sizeof (char) == 1.
Fixes PR standards/10791.



i'm not sure that NetBSD 1.5 has the "uintN_t" family of types or not.
it would probably be safest to used an explicit "unsigned char" for
this is guess, and "unsigned short" for the final delta...



Index: socket.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/socket.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -p -c -r1.59 -r1.60
*** socket.h	2000/10/04 08:59:16	1.59
--- socket.h	2001/05/05 12:47:58	1.60
***************
*** 1,4 ****
! /*	$NetBSD: socket.h,v 1.59 2000/10/04 08:59:16 toshii Exp $	*/
  
  /*
   * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
--- 1,4 ----
! /*	$NetBSD: socket.h,v 1.60 2001/05/05 12:47:58 kleink Exp $	*/
  
  /*
   * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
*************** struct	linger {
*** 189,195 ****
   * addresses.
   */
  struct sockaddr {
! 	u_char		sa_len;		/* total length */
  	sa_family_t	sa_family;	/* address family */
  	char		sa_data[14];	/* actually longer; address value */
  };
--- 189,195 ----
   * addresses.
   */
  struct sockaddr {
! 	uint8_t		sa_len;		/* total length */
  	sa_family_t	sa_family;	/* address family */
  	char		sa_data[14];	/* actually longer; address value */
  };
*************** struct sockproto {
*** 211,223 ****
   */
  #define _SS_MAXSIZE	128
  #define _SS_ALIGNSIZE	(sizeof(int64_t))
! #define _SS_PAD1SIZE	(_SS_ALIGNSIZE - sizeof(u_char) * 2)
! #define _SS_PAD2SIZE	(_SS_MAXSIZE - sizeof(u_char) * 2 - \
  				_SS_PAD1SIZE - _SS_ALIGNSIZE)
  
  #if !defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE - 0) >= 500
  struct sockaddr_storage {
! 	u_char		ss_len;		/* address length */
  	sa_family_t	ss_family;	/* address family */
  	char		__ss_pad1[_SS_PAD1SIZE];
  	int64_t      __ss_align;/* force desired structure storage alignment */
--- 211,223 ----
   */
  #define _SS_MAXSIZE	128
  #define _SS_ALIGNSIZE	(sizeof(int64_t))
! #define _SS_PAD1SIZE	(_SS_ALIGNSIZE - 2)
! #define _SS_PAD2SIZE	(_SS_MAXSIZE - 2 - \
  				_SS_PAD1SIZE - _SS_ALIGNSIZE)
  
  #if !defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE - 0) >= 500
  struct sockaddr_storage {
! 	uint8_t		ss_len;		/* address length */
  	sa_family_t	ss_family;	/* address family */
  	char		__ss_pad1[_SS_PAD1SIZE];
  	int64_t      __ss_align;/* force desired structure storage alignment */
*************** struct cmsghdr {
*** 455,462 ****
   * 4.3 compat sockaddr, move to compat file later
   */
  struct osockaddr {
! 	u_short	sa_family;		/* address family */
! 	char	sa_data[14];		/* up to 14 bytes of direct address */
  };
  
  /*
--- 455,462 ----
   * 4.3 compat sockaddr, move to compat file later
   */
  struct osockaddr {
! 	uint16_t	sa_family;	/* address family */
! 	char		sa_data[14];	/* up to 14 bytes of direct address */
  };
  
  /*



Reply to: