Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Nov 2008 12:13:10 +0000 (UTC)
From:      Dag-Erling Smorgrav <des@FreeBSD.org>
To:        cvs-src-old@freebsd.org
Subject:   cvs commit: src/lib/libutil realhostname.c
Message-ID:  <200811051213.mA5CDF4s084244@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
des         2008-11-05 12:13:10 UTC

  FreeBSD src repository

  Modified files:
    lib/libutil          realhostname.c 
  Log:
  SVN rev 184683 on 2008-11-05 12:13:10Z by des
  
  Like many other functions that handle sockaddrs, realhostname_sa() takes a
  struct sockaddr * that it casts internally to the appropriate type based on
  sa_family.  However, struct sockaddr has very lax alignment requirements,
  which causes the compiler to complain when you cast a struct sockaddr * to,
  say, a struct sockaddr_in6 *.
  
  I find it reasonable to assume that the pointer we received is in fact
  correctly aligned.  Therefore, we can work around the compiler warnings by
  casting to void * before casting to the desired type.  For readability's
  sake, this is done with macros.
  
  The same technique should prove useful in other parts of the tree that
  deal with socket addresses.
  
  MFC after:      3 weeks
  
  Revision  Changes    Path
  1.20      +18 -5     src/lib/libutil/realhostname.c



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811051213.mA5CDF4s084244>