]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - inet/inet6_option.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / inet / inet6_option.c
index b34eb22b7dc98629c50b9f3ed90e7c403d29a669..643ea3d3d0437b9401fee395cf74b0f6d9be4f9c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
 
@@ -13,9 +13,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
 
 #include <assert.h>
 #include <string.h>
@@ -25,7 +24,6 @@
 
 
 static void
-internal_function
 add_pad (struct cmsghdr *cmsg, int len)
 {
   unsigned char *p = CMSG_DATA (cmsg) + cmsg->cmsg_len - CMSG_LEN (0);
@@ -89,8 +87,7 @@ static uint8_t *option_alloc (struct cmsghdr *cmsg, int datalen, int multx,
    beginning (the value y in the alignment term "xn + y"), the type
    byte, the length byte, and the option data.  */
 int
-inet6_option_space (nbytes)
-     int nbytes;
+inet6_option_space (int nbytes)
 {
   /* Add room for the extension header.  */
   nbytes += sizeof (struct ip6_ext);
@@ -107,10 +104,7 @@ link_warning (inet6_option_space,
    contain either Hop-by-Hop or Destination options.  It returns 0 on
    success or -1 on an error.  */
 int
-inet6_option_init (bp, cmsgp, type)
-     void *bp;
-     struct cmsghdr **cmsgp;
-     int type;
+inet6_option_init (void *bp, struct cmsghdr **cmsgp, int type)
 {
   /* Only Hop-by-Hop or Destination options allowed.  */
   if (type != IPV6_HOPOPTS && type != IPV6_DSTOPTS)
@@ -144,11 +138,8 @@ link_warning (inet6_option_init,
    inet6_option_init().  This function returns 0 if it succeeds or -1 on
    an error.  */
 int
-inet6_option_append (cmsg, typep, multx, plusy)
-     struct cmsghdr *cmsg;
-     const uint8_t *typep;
-     int multx;
-     int plusy;
+inet6_option_append (struct cmsghdr *cmsg, const uint8_t *typep, int multx,
+                    int plusy)
 {
   /* typep is a pointer to the 8-bit option type.  It is assumed that this
      field is immediately followed by the 8-bit option data length field,
@@ -191,7 +182,7 @@ option_alloc (struct cmsghdr *cmsg, int datalen, int multx, int plusy)
   int dsize = cmsg->cmsg_len - CMSG_LEN (0);
 
   /* The first two bytes of the option are for the extended header.  */
-  if (__builtin_expect (dsize == 0, 0))
+  if (__glibc_unlikely (dsize == 0))
     {
       cmsg->cmsg_len += sizeof (struct ip6_ext);
       dsize = sizeof (struct ip6_ext);
@@ -216,18 +207,15 @@ option_alloc (struct cmsghdr *cmsg, int datalen, int multx, int plusy)
     /* Too long.  */
     return NULL;
 
-  ((struct ip6_ext *) CMSG_DATA (cmsg))->ip6e_len = len8b;
+  struct ip6_ext *ie = (void *) CMSG_DATA (cmsg);
+  ie->ip6e_len = len8b;
 
   return result;
 }
 
 
 uint8_t *
-inet6_option_alloc (cmsg, datalen, multx, plusy)
-     struct cmsghdr *cmsg;
-     int datalen;
-     int multx;
-     int plusy;
+inet6_option_alloc (struct cmsghdr *cmsg, int datalen, int multx, int plusy)
 {
   return option_alloc (cmsg, datalen, multx, plusy);
 }
@@ -245,9 +233,7 @@ link_warning (inet6_option_alloc,
    to be processed, the return value is -1 and *tptrp is NULL.  If an
    error occurs, the return value is -1 and *tptrp is not NULL.  */
 int
-inet6_option_next (cmsg, tptrp)
-     const struct cmsghdr *cmsg;
-     uint8_t **tptrp;
+inet6_option_next (const struct cmsghdr *cmsg, uint8_t **tptrp)
 {
   /* Make sure it is an option of the right type.  */
   if (cmsg->cmsg_level != IPPROTO_IPV6
@@ -303,10 +289,7 @@ link_warning (inet6_option_next,
    pointer to cmsghdr structure of which cmsg_level equals IPPROTO_IPV6
    and cmsg_type equals either IPV6_HOPOPTS or IPV6_DSTOPTS.  */
 int
-inet6_option_find (cmsg, tptrp, type)
-     const struct cmsghdr *cmsg;
-     uint8_t **tptrp;
-     int type;
+inet6_option_find (const struct cmsghdr *cmsg, uint8_t **tptrp, int type)
 {
   /* Make sure it is an option of the right type.  */
   if (cmsg->cmsg_level != IPPROTO_IPV6