summaryrefslogtreecommitdiffstats
path: root/addrtostr.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:52:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:52:31 +0000
commit31cd589d20ba8d3d6b3fc4fccacc40d38a163c5d (patch)
tree99d6c086833d530e5d1d33a8128961f8149843f0 /addrtostr.c
parentAdding upstream version 4.99.4. (diff)
downloadtcpdump-31cd589d20ba8d3d6b3fc4fccacc40d38a163c5d.tar.xz
tcpdump-31cd589d20ba8d3d6b3fc4fccacc40d38a163c5d.zip
Adding upstream version 4.99.5.upstream/4.99.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'addrtostr.c')
-rw-r--r--addrtostr.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/addrtostr.c b/addrtostr.c
index c3bdb8a..1fd2cf0 100644
--- a/addrtostr.c
+++ b/addrtostr.c
@@ -36,9 +36,7 @@
* SUCH DAMAGE.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include "netdissect-stdinc.h"
#include "addrtostr.h"
@@ -127,16 +125,12 @@ addrtostr6 (const void *src, char *dst, size_t size)
best.base = -1;
cur.len = 0;
cur.base = -1;
- for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
- {
- if (words[i] == 0)
- {
+ for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
+ if (words[i] == 0) {
if (cur.base == -1)
cur.base = i, cur.len = 1;
else cur.len++;
- }
- else if (cur.base != -1)
- {
+ } else if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
@@ -160,12 +154,10 @@ addrtostr6 (const void *src, char *dst, size_t size)
*dp++ = c; \
space_left--; \
}
- for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
- {
+ for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
/* Are we inside the best run of 0x00's?
*/
- if (best.base != -1 && i >= best.base && i < (best.base + best.len))
- {
+ if (best.base != -1 && i >= best.base && i < (best.base + best.len)) {
if (i == best.base)
APPEND_CHAR(':');
continue;
@@ -181,8 +173,7 @@ addrtostr6 (const void *src, char *dst, size_t size)
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{
- if (!addrtostr(srcaddr+12, dp, space_left))
- {
+ if (!addrtostr(srcaddr+12, dp, space_left)) {
errno = ENOSPC;
return (NULL);
}
@@ -194,8 +185,7 @@ addrtostr6 (const void *src, char *dst, size_t size)
snprintfed = snprintf (dp, space_left, "%x", words[i]);
if (snprintfed < 0)
return (NULL);
- if ((size_t) snprintfed >= space_left)
- {
+ if ((size_t) snprintfed >= space_left) {
errno = ENOSPC;
return (NULL);
}