about summary refs log tree commit diff
path: root/inet/inet6_opt.c
diff options
context:
space:
mode:
Diffstat (limited to 'inet/inet6_opt.c')
-rw-r--r--inet/inet6_opt.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/inet/inet6_opt.c b/inet/inet6_opt.c
index 17d3fee213..bddb85182b 100644
--- a/inet/inet6_opt.c
+++ b/inet/inet6_opt.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2006.
 
@@ -51,7 +51,7 @@ add_padding (uint8_t *extbuf, int offset, int npad)
 {
   if (npad == 1)
     extbuf[offset] = IP6OPT_PAD1;
-  else if (npad > 0)
+  else
     {
       struct ip6_opt *pad_opt = (struct ip6_opt *) (extbuf + offset);
 
@@ -102,17 +102,21 @@ inet6_opt_append (void *extbuf, socklen_t extlen, int offset, uint8_t type,
   int data_offset = offset + sizeof (struct ip6_opt);
   int npad = (align - data_offset % align) & (align - 1);
 
-  if (extbuf != NULL)
-    {
-      /* Now we can check whether the buffer is large enough.  */
-      if (data_offset + npad + len > extlen)
-	return -1;
+  /* Now we can check whether the buffer is large enough.  */
+  if (data_offset + npad + len > extlen)
+    return -1;
 
-      add_padding (extbuf, offset, npad);
+  if (npad != 0)
+    {
+      if (extbuf != NULL)
+	add_padding (extbuf, offset, npad);
 
       offset += npad;
+    }
 
-      /* Now prepare the option itself.  */
+  /* Now prepare the option itself.  */
+  if (extbuf != NULL)
+    {
       struct ip6_opt *opt = (struct ip6_opt *) ((uint8_t *) extbuf + offset);
 
       opt->ip6o_type = type;
@@ -120,8 +124,6 @@ inet6_opt_append (void *extbuf, socklen_t extlen, int offset, uint8_t type,
 
       *databufp = opt + 1;
     }
-  else
-    offset += npad;
 
   return offset + sizeof (struct ip6_opt) + len;
 }
@@ -143,14 +145,12 @@ inet6_opt_finish (void *extbuf, socklen_t extlen, int offset)
   /* Required padding at the end.  */
   int npad = (8 - (offset & 7)) & 7;
 
-  if (extbuf != NULL)
-    {
-      /* Make sure the buffer is large enough.  */
-      if (offset + npad > extlen)
-	return -1;
+  /* Make sure the buffer is large enough.  */
+  if (offset + npad > extlen)
+    return -1;
 
-      add_padding (extbuf, offset, npad);
-    }
+  if (extbuf != NULL)
+    add_padding (extbuf, offset, npad);
 
   return offset + npad;
 }