diff options
| author | H. Peter Anvin <hpa@zytor.com> | 2009-05-29 15:10:27 -0700 |
|---|---|---|
| committer | H. Peter Anvin <hpa@zytor.com> | 2009-05-29 15:10:27 -0700 |
| commit | dfc6a45461f2f5c8aad79e825f2f10036f6584d4 (patch) | |
| tree | 80e3a5cefd1cc21122a69de814f128bca658e114 /com32/lib/syslinux | |
| parent | 5e20a158f0ff52026ea843a698058e39f138530f (diff) | |
| download | syslinux-dfc6a45461f2f5c8aad79e825f2f10036f6584d4.tar.gz | |
Run Nindent on com32/lib/syslinux/setadv.c
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>
Diffstat (limited to 'com32/lib/syslinux')
| -rw-r--r-- | com32/lib/syslinux/setadv.c | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/com32/lib/syslinux/setadv.c b/com32/lib/syslinux/setadv.c index 5993df6d..40f00a4e 100644 --- a/com32/lib/syslinux/setadv.c +++ b/com32/lib/syslinux/setadv.c @@ -47,70 +47,70 @@ 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; } |
