Run Nindent on com32/lib/syslinux/setadv.c
authorH. Peter Anvin <hpa@zytor.com>
Fri, 29 May 2009 22:10:27 +0000 (15:10 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Fri, 29 May 2009 22:10:27 +0000 (15:10 -0700)
Automatically reformat com32/lib/syslinux/setadv.c using Nindent.

Do this for all files except HDT, gPXE and externally maintained
libraries (zlib, tinyjpeg, libpng).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
com32/lib/syslinux/setadv.c

index 5993df6..40f00a4 100644 (file)
 
 int syslinux_setadv(int tag, size_t size, const void *data)
 {
-  uint8_t *p, *advtmp;
-  size_t rleft, left;
-
-  if ((unsigned)tag-1 > 254) {
-    errno = EINVAL;
-    return -1;                 /* Impossible tag value */
-  }
-
-  if (size > 255) {
-    errno = ENOSPC;            /* Max 255 bytes for a data item */
-    return -1;
-  }
-
-  rleft = left = syslinux_adv_size();
-  p = advtmp = alloca(left);
-  memcpy(p, syslinux_adv_ptr(), left); /* Make working copy */
-
-  while (rleft >= 2) {
-    uint8_t ptag = p[0];
-    size_t  plen = p[1]+2;
-
-    if (ptag == ADV_END)
-      break;
-
-    if (ptag == tag) {
-      /* Found our tag.  Delete it. */
-
-      if (plen >= rleft) {
-       /* Entire remainder is our tag */
-       break;
-      }
-      memmove(p, p+plen, rleft-plen);
-      rleft -= plen;           /* Fewer bytes to read, but not to write */
-    } else {
-      /* Not our tag */
-      if (plen > rleft)
-       break;                  /* Corrupt tag (overrun) - overwrite it */
-
-      left -= plen;
-      rleft -= plen;
-      p += plen;
+    uint8_t *p, *advtmp;
+    size_t rleft, left;
+
+    if ((unsigned)tag - 1 > 254) {
+       errno = EINVAL;
+       return -1;              /* Impossible tag value */
     }
-  }
 
-  /* Now (p, left) reflects the position to write in and how much space
-     we have for our data. */
+    if (size > 255) {
+       errno = ENOSPC;         /* Max 255 bytes for a data item */
+       return -1;
+    }
 
-  if (size) {
-    if (left < size+2) {
-      errno = ENOSPC;          /* Not enough space for data */
-      return -1;
+    rleft = left = syslinux_adv_size();
+    p = advtmp = alloca(left);
+    memcpy(p, syslinux_adv_ptr(), left);       /* Make working copy */
+
+    while (rleft >= 2) {
+       uint8_t ptag = p[0];
+       size_t plen = p[1] + 2;
+
+       if (ptag == ADV_END)
+           break;
+
+       if (ptag == tag) {
+           /* Found our tag.  Delete it. */
+
+           if (plen >= rleft) {
+               /* Entire remainder is our tag */
+               break;
+           }
+           memmove(p, p + plen, rleft - plen);
+           rleft -= plen;      /* Fewer bytes to read, but not to write */
+       } else {
+           /* Not our tag */
+           if (plen > rleft)
+               break;          /* Corrupt tag (overrun) - overwrite it */
+
+           left -= plen;
+           rleft -= plen;
+           p += plen;
+       }
     }
 
-    *p++ = tag;
-    *p++ = size;
-    memcpy(p, data, size);
-    p += size;
-    left -= size+2;
-  }
+    /* Now (p, left) reflects the position to write in and how much space
+       we have for our data. */
+
+    if (size) {
+       if (left < size + 2) {
+           errno = ENOSPC;     /* Not enough space for data */
+           return -1;
+       }
+
+       *p++ = tag;
+       *p++ = size;
+       memcpy(p, data, size);
+       p += size;
+       left -= size + 2;
+    }
 
-  memset(p, 0, left);
+    memset(p, 0, left);
 
-  /* If we got here, everything went OK, commit the write to low memory */
-  memcpy(syslinux_adv_ptr(), advtmp, syslinux_adv_size());
+    /* If we got here, everything went OK, commit the write to low memory */
+    memcpy(syslinux_adv_ptr(), advtmp, syslinux_adv_size());
 
-  return 0;
+    return 0;
 }