diff --git a/fs/fs_poll.c b/fs/fs_poll.c index f5aa9dcf0f1..b81a4d3c643 100644 --- a/fs/fs_poll.c +++ b/fs/fs_poll.c @@ -1,8 +1,8 @@ /**************************************************************************** * fs/fs_poll.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/sys/socket.h b/include/sys/socket.h index 68888eaa7ab..7613d00cdb9 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -52,7 +52,8 @@ /* Protocol families */ -#define PF_UNIX 0 /* Local communication */ +#define PF_UNSPEC 0 /* Protocol family unspecified */ +#define PF_UNIX 1 /* Local communication */ #define PF_LOCAL 1 /* Local communication */ #define PF_INET 2 /* IPv4 Internet protocols */ #define PF_INET6 3 /* IPv6 Internet protocols */ @@ -66,6 +67,7 @@ /* Address families */ +#define AF_UNSPEC PF_UNSPEC #define AF_UNIX PF_UNIX #define AF_LOCAL PF_LOCAL #define AF_INET PF_INET diff --git a/lib/net/lib_inetntop.c b/lib/net/lib_inetntop.c index b48cd5d115d..3c8eb936ac7 100644 --- a/lib/net/lib_inetntop.c +++ b/lib/net/lib_inetntop.c @@ -5,7 +5,10 @@ * Author: Gregory Nutt * * Includes some logic extracted from hwport_ftpd, written by Jaehyuk Cho - * which has a BSD license (but no file headers). + * which was released under the BSD license. + * + * Copyright (C) HWPORT.COM. All rights reserved. + * Author: JAEHYUK CHO * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/lib/net/lib_inetpton.c b/lib/net/lib_inetpton.c index 195e96b60c0..281d03d4047 100644 --- a/lib/net/lib_inetpton.c +++ b/lib/net/lib_inetpton.c @@ -5,7 +5,10 @@ * Author: Gregory Nutt * * Includes some logic extracted from hwport_ftpd, written by Jaehyuk Cho - * which has a BSD license (but no file headers). + * which was released under the BSD license. + * + * Copyright (C) HWPORT.COM. All rights reserved. + * Author: JAEHYUK CHO * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -123,6 +126,8 @@ int inet_pton(int af, FAR const char *src, FAR void *dst) return -1; } + (void)memset(dst, 0, sizeof(struct in_addr)); + ip = (uint8_t *)dst; srcoffset = 0; numoffset = 0; @@ -199,6 +204,17 @@ int inet_pton(int af, FAR const char *src, FAR void *dst) return 0; #else + size_t srcoffset; + size_t numoffset; + long value; + int nsep; + int nrsep; + uint8_t ch; + char numstr[5]; + uint8_t ip[sizeof(struct in6_addr)]; + uint8_t rip[sizeof(struct in6_addr)]; + bool rtime; + DEBUGASSERT(src && dst); if (af != AF_INET6) @@ -207,29 +223,19 @@ int inet_pton(int af, FAR const char *src, FAR void *dst) return -1; } - size_t srcoffset; - size_t numoffset; - long value; - int nsep; - int nrsep; - uint8_t ch; - char numstr[5]; - uint8_t ip[sizeof(in_addr)]; - uint8_t rip[sizeof(in_addr)]; - bool rtime; + (void)memset(dst, 0, sizeof(struct in6_addr)); - (void)memset(dst, 0, sizeof(in_addr)); - srcoffset = 0; - numoffset = 0; - nsep = 0; - nrsep = 0; - rtime = false; + srcoffset = 0; + numoffset = 0; + nsep = 0; + nrsep = 0; + rtime = false; for(;;) { ch = (uint8_t)src[srcoffset++]; - if (ch == ':' || ch == '\0' /* || ch == '/' */ ) + if (ch == ':' || ch == '\0') { if (ch == ':' && (nsep + nrsep) >= 8) { @@ -242,7 +248,7 @@ int inet_pton(int af, FAR const char *src, FAR void *dst) { /* Empty numeric string */ - if (rtime != 0 && nrsep > 1) + if (rtime && nrsep > 1) { /* dup simple */ @@ -251,7 +257,6 @@ int inet_pton(int af, FAR const char *src, FAR void *dst) numoffset = 0; rtime = true; - continue; } @@ -281,7 +286,9 @@ int inet_pton(int af, FAR const char *src, FAR void *dst) if (ch == '\0' /* || ch == '/' */) { - if ((nsep <= 1 && nrsep <= 0) || (nsep + nrsep) < 1 || (nsep + nrsep) > 8) + if ((nsep <= 1 && nrsep <= 0) || + (nsep + nrsep) < 1 || + (nsep + nrsep) > 8) { /* Separator count problem */ @@ -303,7 +310,9 @@ int inet_pton(int af, FAR const char *src, FAR void *dst) return 0; } } - else if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F')) + else if ((ch >= '0' && ch <= '9') || + (ch >= 'a' && ch <= 'f') || + (ch >= 'A' && ch <= 'F')) { numstr[numoffset++] = ch; if (numoffset >= 5)