StdLib: Fix GCC warnings/errors caused by variables being set but not used.

Removed variables that had no effect on code behavior.

Fifo.c::FIFO_Dequeue: Replaced instances of "Self->ElementSize" with preexisting variable "SizeOfElement".

IIOutilities.c::IIO_GetInChar: Fixed variable of wrong, but compatible, type and made updating of housekeeping variables dependent upon successful completion of reading from the buffer.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
Reviewed by: Daryl McDaniel <daryl.mcdaniel@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16276 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Olivier Martin 2014-10-30 01:05:22 +00:00 committed by darylm503
parent b07ae3d607
commit 0e565888ee
11 changed files with 449 additions and 426 deletions

View File

@ -1,5 +1,15 @@
/* $NetBSD: getnameinfo.c,v 1.45 2006/10/15 16:14:46 christos Exp $ */ /** @file
/* $KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $ */ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
/* $NetBSD: getnameinfo.c,v 1.45 2006/10/15 16:14:46 christos Exp $ */
/* $KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $ */
/* /*
* Copyright (c) 2000 Ben Harris. * Copyright (c) 2000 Ben Harris.
@ -89,33 +99,33 @@ hexname(
); );
static const struct afd { static const struct afd {
int a_af; int a_af;
socklen_t a_addrlen; socklen_t a_addrlen;
socklen_t a_socklen; socklen_t a_socklen;
int a_off; int a_off;
} afdl [] = { } afdl [] = {
#ifdef INET6 #ifdef INET6
{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6), {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
offsetof(struct sockaddr_in6, sin6_addr)}, offsetof(struct sockaddr_in6, sin6_addr)},
#endif #endif
{PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
offsetof(struct sockaddr_in, sin_addr)}, offsetof(struct sockaddr_in, sin_addr)},
{0, 0, 0, 0}, {0, 0, 0, 0},
}; };
struct sockinet { struct sockinet {
u_char si_len; u_char si_len;
u_char si_family; u_char si_family;
u_short si_port; u_short si_port;
}; };
static int getnameinfo_inet __P((const struct sockaddr *, socklen_t, char *, static int getnameinfo_inet __P((const struct sockaddr *, socklen_t, char *,
socklen_t, char *, socklen_t, int)); socklen_t, char *, socklen_t, int));
#ifdef INET6 #ifdef INET6
static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *, static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *,
socklen_t, int)); socklen_t, int));
static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t,
int)); int));
#endif #endif
static int getnameinfo_link __P((const struct sockaddr *, socklen_t, char *, static int getnameinfo_link __P((const struct sockaddr *, socklen_t, char *,
socklen_t, char *, socklen_t, int)); socklen_t, char *, socklen_t, int));
@ -137,17 +147,17 @@ getnameinfo(
) )
{ {
switch (sa->sa_family) { switch (sa->sa_family) {
case AF_INET: case AF_INET:
case AF_INET6: case AF_INET6:
return getnameinfo_inet(sa, salen, host, hostlen, return getnameinfo_inet(sa, salen, host, hostlen,
serv, servlen, flags); serv, servlen, flags);
case AF_LINK: case AF_LINK:
return getnameinfo_link(sa, salen, host, hostlen, return getnameinfo_link(sa, salen, host, hostlen,
serv, servlen, flags); serv, servlen, flags);
default: default:
return EAI_FAMILY; return EAI_FAMILY;
} }
} }
@ -167,193 +177,193 @@ getnameinfo_inet(
int flags int flags
) )
{ {
const struct afd *afd; const struct afd *afd;
struct servent *sp; struct servent *sp;
struct hostent *hp; struct hostent *hp;
u_short port; u_short port;
int family, i; int family, i;
const char *addr; const char *addr;
u_int32_t v4a; u_int32_t v4a;
char numserv[512]; char numserv[512];
char numaddr[512]; char numaddr[512];
/* sa is checked below */ /* sa is checked below */
/* host may be NULL */ /* host may be NULL */
/* serv may be NULL */ /* serv may be NULL */
if (sa == NULL) if (sa == NULL)
return EAI_FAIL; return EAI_FAIL;
#ifdef BSD4_4 #ifdef BSD4_4
if (sa->sa_len != salen) if (sa->sa_len != salen)
return EAI_FAIL; return EAI_FAIL;
#endif #endif
family = sa->sa_family; family = sa->sa_family;
for (i = 0; afdl[i].a_af; i++) for (i = 0; afdl[i].a_af; i++)
if (afdl[i].a_af == family) { if (afdl[i].a_af == family) {
afd = &afdl[i]; afd = &afdl[i];
goto found; goto found;
} }
return EAI_FAMILY; return EAI_FAMILY;
found: found:
if (salen != afd->a_socklen) if (salen != afd->a_socklen)
return EAI_FAIL; return EAI_FAIL;
/* network byte order */ /* network byte order */
port = ((const struct sockinet *)(const void *)sa)->si_port; port = ((const struct sockinet *)(const void *)sa)->si_port;
addr = (const char *)(const void *)sa + afd->a_off; addr = (const char *)(const void *)sa + afd->a_off;
if (serv == NULL || servlen == 0) { if (serv == NULL || servlen == 0) {
/* /*
* do nothing in this case. * do nothing in this case.
* in case you are wondering if "&&" is more correct than * in case you are wondering if "&&" is more correct than
* "||" here: rfc2553bis-03 says that serv == NULL OR * "||" here: rfc2553bis-03 says that serv == NULL OR
* servlen == 0 means that the caller does not want the result. * servlen == 0 means that the caller does not want the result.
*/ */
} else { } else {
if (flags & NI_NUMERICSERV) if (flags & NI_NUMERICSERV)
sp = NULL; sp = NULL;
else { else {
struct servent_data svd; struct servent_data svd;
// struct servent sv; // struct servent sv;
(void)memset(&svd, 0, sizeof(svd)); (void)memset(&svd, 0, sizeof(svd));
sp = getservbyport_r(port, sp = getservbyport_r(port,
(flags & NI_DGRAM) ? "udp" : "tcp", &sv, &svd); (flags & NI_DGRAM) ? "udp" : "tcp", &sv, &svd);
endservent_r(&svd); endservent_r(&svd);
} }
if (sp) { if (sp) {
if (strlen(sp->s_name) + 1 > servlen) if (strlen(sp->s_name) + 1 > servlen)
return EAI_MEMORY; return EAI_MEMORY;
strlcpy(serv, sp->s_name, servlen); strlcpy(serv, sp->s_name, servlen);
} else { } else {
snprintf(numserv, sizeof(numserv), "%u", ntohs(port)); snprintf(numserv, sizeof(numserv), "%u", ntohs(port));
if (strlen(numserv) + 1 > servlen) if (strlen(numserv) + 1 > servlen)
return EAI_MEMORY; return EAI_MEMORY;
strlcpy(serv, numserv, servlen); strlcpy(serv, numserv, servlen);
} }
} }
switch (sa->sa_family) { switch (sa->sa_family) {
case AF_INET: case AF_INET:
v4a = (u_int32_t) v4a = (u_int32_t)
ntohl(((const struct sockaddr_in *) ntohl(((const struct sockaddr_in *)
(const void *)sa)->sin_addr.s_addr); (const void *)sa)->sin_addr.s_addr);
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
flags |= NI_NUMERICHOST; flags |= NI_NUMERICHOST;
v4a >>= IN_CLASSA_NSHIFT; v4a >>= IN_CLASSA_NSHIFT;
if (v4a == 0) if (v4a == 0)
flags |= NI_NUMERICHOST; flags |= NI_NUMERICHOST;
break; break;
#ifdef INET6 #ifdef INET6
case AF_INET6: case AF_INET6:
{ {
const struct sockaddr_in6 *sin6; const struct sockaddr_in6 *sin6;
sin6 = (const struct sockaddr_in6 *)(const void *)sa; sin6 = (const struct sockaddr_in6 *)(const void *)sa;
switch (sin6->sin6_addr.s6_addr[0]) { switch (sin6->sin6_addr.s6_addr[0]) {
case 0x00: case 0x00:
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
; ;
else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr)) else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
; ;
else else
flags |= NI_NUMERICHOST; flags |= NI_NUMERICHOST;
break; break;
default: default:
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
flags |= NI_NUMERICHOST; flags |= NI_NUMERICHOST;
} }
else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
flags |= NI_NUMERICHOST; flags |= NI_NUMERICHOST;
break; break;
} }
} }
break; break;
#endif #endif
} }
if (host == NULL || hostlen == 0) { if (host == NULL || hostlen == 0) {
/* /*
* do nothing in this case. * do nothing in this case.
* in case you are wondering if "&&" is more correct than * in case you are wondering if "&&" is more correct than
* "||" here: rfc2553bis-03 says that host == NULL or * "||" here: rfc2553bis-03 says that host == NULL or
* hostlen == 0 means that the caller does not want the result. * hostlen == 0 means that the caller does not want the result.
*/ */
} else if (flags & NI_NUMERICHOST) { } else if (flags & NI_NUMERICHOST) {
size_t numaddrlen; size_t numaddrlen;
/* NUMERICHOST and NAMEREQD conflicts with each other */ /* NUMERICHOST and NAMEREQD conflicts with each other */
if (flags & NI_NAMEREQD) if (flags & NI_NAMEREQD)
return EAI_NONAME; return EAI_NONAME;
switch(afd->a_af) { switch(afd->a_af) {
#ifdef INET6 #ifdef INET6
case AF_INET6: case AF_INET6:
{ {
int error; int error;
if ((error = ip6_parsenumeric(sa, addr, host, if ((error = ip6_parsenumeric(sa, addr, host,
hostlen, flags)) != 0) hostlen, flags)) != 0)
return(error); return(error);
break; break;
} }
#endif #endif
default: default:
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
== NULL) == NULL)
return EAI_SYSTEM; return EAI_SYSTEM;
numaddrlen = strlen(numaddr); numaddrlen = strlen(numaddr);
if (numaddrlen + 1 > hostlen) /* don't forget terminator */ if (numaddrlen + 1 > hostlen) /* don't forget terminator */
return EAI_MEMORY; return EAI_MEMORY;
strlcpy(host, numaddr, hostlen); strlcpy(host, numaddr, hostlen);
break; break;
} }
} else { } else {
hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af); hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
if (hp) { if (hp) {
#if 0 #if 0
/* /*
* commented out, since "for local host" is not * commented out, since "for local host" is not
* implemented here - see RFC2553 p30 * implemented here - see RFC2553 p30
*/ */
if (flags & NI_NOFQDN) { if (flags & NI_NOFQDN) {
char *p; char *p;
p = strchr(hp->h_name, '.'); p = strchr(hp->h_name, '.');
if (p) if (p)
*p = '\0'; *p = '\0';
} }
#endif #endif
if (strlen(hp->h_name) + 1 > hostlen) { if (strlen(hp->h_name) + 1 > hostlen) {
return EAI_MEMORY; return EAI_MEMORY;
} }
strlcpy(host, hp->h_name, hostlen); strlcpy(host, hp->h_name, hostlen);
} else { } else {
if (flags & NI_NAMEREQD) if (flags & NI_NAMEREQD)
return EAI_NONAME; return EAI_NONAME;
switch(afd->a_af) { switch(afd->a_af) {
#ifdef INET6 #ifdef INET6
case AF_INET6: case AF_INET6:
{ {
int error; int error;
if ((error = ip6_parsenumeric(sa, addr, host, if ((error = ip6_parsenumeric(sa, addr, host,
hostlen, hostlen,
flags)) != 0) flags)) != 0)
return(error); return(error);
break; break;
} }
#endif #endif
default: default:
if (inet_ntop(afd->a_af, addr, host, if (inet_ntop(afd->a_af, addr, host,
hostlen) == NULL) hostlen) == NULL)
return EAI_SYSTEM; return EAI_SYSTEM;
break; break;
} }
} }
} }
return(0); return(0);
} }
#ifdef INET6 #ifdef INET6
@ -366,40 +376,40 @@ ip6_parsenumeric(
int flags int flags
) )
{ {
size_t numaddrlen; size_t numaddrlen;
char numaddr[512]; char numaddr[512];
_DIAGASSERT(sa != NULL); _DIAGASSERT(sa != NULL);
_DIAGASSERT(addr != NULL); _DIAGASSERT(addr != NULL);
_DIAGASSERT(host != NULL); _DIAGASSERT(host != NULL);
if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL) if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL)
return EAI_SYSTEM; return EAI_SYSTEM;
numaddrlen = strlen(numaddr); numaddrlen = strlen(numaddr);
if (numaddrlen + 1 > hostlen) /* don't forget terminator */ if (numaddrlen + 1 > hostlen) /* don't forget terminator */
return EAI_OVERFLOW; return EAI_OVERFLOW;
strlcpy(host, numaddr, hostlen); strlcpy(host, numaddr, hostlen);
if (((const struct sockaddr_in6 *)(const void *)sa)->sin6_scope_id) { if (((const struct sockaddr_in6 *)(const void *)sa)->sin6_scope_id) {
char zonebuf[MAXHOSTNAMELEN]; char zonebuf[MAXHOSTNAMELEN];
int zonelen; int zonelen;
zonelen = ip6_sa2str( zonelen = ip6_sa2str(
(const struct sockaddr_in6 *)(const void *)sa, (const struct sockaddr_in6 *)(const void *)sa,
zonebuf, sizeof(zonebuf), flags); zonebuf, sizeof(zonebuf), flags);
if (zonelen < 0) if (zonelen < 0)
return EAI_OVERFLOW; return EAI_OVERFLOW;
if ((size_t) zonelen + 1 + numaddrlen + 1 > hostlen) if ((size_t) zonelen + 1 + numaddrlen + 1 > hostlen)
return EAI_OVERFLOW; return EAI_OVERFLOW;
/* construct <numeric-addr><delim><zoneid> */ /* construct <numeric-addr><delim><zoneid> */
memcpy(host + numaddrlen + 1, zonebuf, memcpy(host + numaddrlen + 1, zonebuf,
(size_t)zonelen); (size_t)zonelen);
host[numaddrlen] = SCOPE_DELIMITER; host[numaddrlen] = SCOPE_DELIMITER;
host[numaddrlen + 1 + zonelen] = '\0'; host[numaddrlen + 1 + zonelen] = '\0';
} }
return 0; return 0;
} }
/* ARGSUSED */ /* ARGSUSED */
@ -411,43 +421,47 @@ ip6_sa2str(
int flags int flags
) )
{ {
unsigned int ifindex; #if 0
const struct in6_addr *a6; unsigned int ifindex;
int n; const struct in6_addr *a6;
#endif
int n;
_DIAGASSERT(sa6 != NULL); _DIAGASSERT(sa6 != NULL);
_DIAGASSERT(buf != NULL); _DIAGASSERT(buf != NULL);
ifindex = (unsigned int)sa6->sin6_scope_id; #if 0
a6 = &sa6->sin6_addr; ifindex = (unsigned int)sa6->sin6_scope_id;
a6 = &sa6->sin6_addr;
#endif
#ifdef NI_NUMERICSCOPE #ifdef NI_NUMERICSCOPE
if ((flags & NI_NUMERICSCOPE) != 0) { if ((flags & NI_NUMERICSCOPE) != 0) {
n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id); n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
if ((n < 0) || ((size_t)n >= bufsiz)) if ((n < 0) || ((size_t)n >= bufsiz))
return -1; return -1;
else else
return n; return n;
} }
#endif #endif
#if 0 #if 0
/* if_indextoname() does not take buffer size. not a good api... */ /* if_indextoname() does not take buffer size. not a good api... */
if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) && if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) &&
bufsiz >= IF_NAMESIZE) { bufsiz >= IF_NAMESIZE) {
char *p = if_indextoname(ifindex, buf); char *p = if_indextoname(ifindex, buf);
if (p) { if (p) {
return(strlen(p)); return(strlen(p));
} }
} }
#endif // 0 #endif // 0
/* last resort */ /* last resort */
n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id); n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
if (n < 0 || (size_t) n >= bufsiz) if (n < 0 || (size_t) n >= bufsiz)
return -1; return -1;
else else
return n; return n;
} }
#endif /* INET6 */ #endif /* INET6 */
@ -470,73 +484,73 @@ getnameinfo_link (
int flags int flags
) )
{ {
const struct sockaddr_dl *sdl = const struct sockaddr_dl *sdl =
(const struct sockaddr_dl *)(const void *)sa; (const struct sockaddr_dl *)(const void *)sa;
// const struct ieee1394_hwaddr *iha; // const struct ieee1394_hwaddr *iha;
int n; int n;
if (serv != NULL && servlen > 0) if (serv != NULL && servlen > 0)
*serv = '\0'; *serv = '\0';
if (sdl->sdl_nlen == 0 && sdl->sdl_alen == 0 && sdl->sdl_slen == 0) { if (sdl->sdl_nlen == 0 && sdl->sdl_alen == 0 && sdl->sdl_slen == 0) {
n = snprintf(host, hostlen, "link#%u", sdl->sdl_index); n = snprintf(host, hostlen, "link#%u", sdl->sdl_index);
if (n < 0 || (socklen_t) n > hostlen) { if (n < 0 || (socklen_t) n > hostlen) {
*host = '\0'; *host = '\0';
return EAI_MEMORY; return EAI_MEMORY;
} }
return 0; return 0;
} }
#if 0 #if 0
switch (sdl->sdl_type) { switch (sdl->sdl_type) {
#ifdef IFT_ECONET #ifdef IFT_ECONET
case IFT_ECONET: case IFT_ECONET:
if (sdl->sdl_alen < 2) if (sdl->sdl_alen < 2)
return EAI_FAMILY; return EAI_FAMILY;
if (CLLADDR(sdl)[1] == 0) if (CLLADDR(sdl)[1] == 0)
n = snprintf(host, hostlen, "%u", CLLADDR(sdl)[0]); n = snprintf(host, hostlen, "%u", CLLADDR(sdl)[0]);
else else
n = snprintf(host, hostlen, "%u.%u", n = snprintf(host, hostlen, "%u.%u",
CLLADDR(sdl)[1], CLLADDR(sdl)[0]); CLLADDR(sdl)[1], CLLADDR(sdl)[0]);
if (n < 0 || (socklen_t) n >= hostlen) { if (n < 0 || (socklen_t) n >= hostlen) {
*host = '\0'; *host = '\0';
return EAI_MEMORY; return EAI_MEMORY;
} else } else
return 0; return 0;
#endif #endif
case IFT_IEEE1394: case IFT_IEEE1394:
if (sdl->sdl_alen < sizeof(iha->iha_uid)) if (sdl->sdl_alen < sizeof(iha->iha_uid))
return EAI_FAMILY; return EAI_FAMILY;
iha = iha =
(const struct ieee1394_hwaddr *)(const void *)CLLADDR(sdl); (const struct ieee1394_hwaddr *)(const void *)CLLADDR(sdl);
return hexname(iha->iha_uid, sizeof(iha->iha_uid), return hexname(iha->iha_uid, sizeof(iha->iha_uid),
host, hostlen); host, hostlen);
/* /*
* The following have zero-length addresses. * The following have zero-length addresses.
* IFT_ATM (net/if_atmsubr.c) * IFT_ATM (net/if_atmsubr.c)
* IFT_FAITH (net/if_faith.c) * IFT_FAITH (net/if_faith.c)
* IFT_GIF (net/if_gif.c) * IFT_GIF (net/if_gif.c)
* IFT_LOOP (net/if_loop.c) * IFT_LOOP (net/if_loop.c)
* IFT_PPP (net/if_ppp.c, net/if_spppsubr.c) * IFT_PPP (net/if_ppp.c, net/if_spppsubr.c)
* IFT_SLIP (net/if_sl.c, net/if_strip.c) * IFT_SLIP (net/if_sl.c, net/if_strip.c)
* IFT_STF (net/if_stf.c) * IFT_STF (net/if_stf.c)
* IFT_L2VLAN (net/if_vlan.c) * IFT_L2VLAN (net/if_vlan.c)
* IFT_PROPVIRTUAL (net/if_bridge.h> * IFT_PROPVIRTUAL (net/if_bridge.h>
*/ */
/* /*
* The following use IPv4 addresses as link-layer addresses: * The following use IPv4 addresses as link-layer addresses:
* IFT_OTHER (net/if_gre.c) * IFT_OTHER (net/if_gre.c)
*/ */
case IFT_ARCNET: /* default below is believed correct for all these. */ case IFT_ARCNET: /* default below is believed correct for all these. */
case IFT_ETHER: case IFT_ETHER:
case IFT_FDDI: case IFT_FDDI:
case IFT_HIPPI: case IFT_HIPPI:
case IFT_ISO88025: case IFT_ISO88025:
default: default:
#endif // 0 #endif // 0
return hexname((const u_int8_t *)CLLADDR(sdl), return hexname((const u_int8_t *)CLLADDR(sdl),
(size_t)sdl->sdl_alen, host, hostlen); (size_t)sdl->sdl_alen, host, hostlen);
// } // }
} }
static static
@ -548,20 +562,20 @@ hexname(
socklen_t hostlen socklen_t hostlen
) )
{ {
int n; int n;
size_t i; size_t i;
char *outp = host; char *outp = host;
*outp = '\0'; *outp = '\0';
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
n = snprintf(outp, hostlen, "%s%02x", n = snprintf(outp, hostlen, "%s%02x",
i ? ":" : "", cp[i]); i ? ":" : "", cp[i]);
if (n < 0 || (socklen_t) n >= hostlen) { if (n < 0 || (socklen_t) n >= hostlen) {
*host = '\0'; *host = '\0';
return EAI_MEMORY; return EAI_MEMORY;
} }
outp += n; outp += n;
hostlen -= n; hostlen -= n;
} }
return 0; return 0;
} }

View File

@ -1,3 +1,13 @@
/** @file
Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
/* /*
* Copyright (c) 1985, 1993 * Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -168,7 +178,7 @@ res_hnok(
const char *dn const char *dn
) )
{ {
int ppch = '\0', pch = PERIOD, ch = *dn++; int pch = PERIOD, ch = *dn++;
while (ch != '\0') { while (ch != '\0') {
int nch = *dn++; int nch = *dn++;
@ -185,7 +195,8 @@ res_hnok(
if (!middlechar(ch)) if (!middlechar(ch))
return (0); return (0);
} }
ppch = pch, pch = ch, ch = nch; pch = ch;
ch = nch;
} }
return (1); return (1);
} }

View File

@ -1,3 +1,13 @@
/** @file
Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
/* /*
* Copyright (c) 1996 by Internet Software Consortium. * Copyright (c) 1996 by Internet Software Consortium.
* *
@ -100,7 +110,7 @@ int
res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) { res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
ns_updrec *rrecp_start = rrecp_in; ns_updrec *rrecp_start = rrecp_in;
HEADER *hp; HEADER *hp;
u_char *cp, *sp1, *sp2, *startp, *endp; u_char *cp, *sp2, *startp, *endp;
int n, i, soanum, multiline; int n, i, soanum, multiline;
ns_updrec *rrecp; ns_updrec *rrecp;
struct in_addr ina; struct in_addr ina;
@ -125,7 +135,6 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
hp->id = htons(++_res.id); hp->id = htons(++_res.id);
hp->opcode = ns_o_update; hp->opcode = ns_o_update;
hp->rcode = NOERROR; hp->rcode = NOERROR;
sp1 = buf + 2*INT16SZ; /* save pointer to zocount */
cp = buf + HFIXEDSZ; cp = buf + HFIXEDSZ;
buflen -= HFIXEDSZ; buflen -= HFIXEDSZ;
dpp = dnptrs; dpp = dnptrs;

View File

@ -1,11 +1,11 @@
/** @file /** @file
Implement the IP4 driver support for the socket layer. Implement the IP4 driver support for the socket layer.
Copyright (c) 2011, Intel Corporation Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
All rights reserved. This program and the accompanying materials This program and the accompanying materials are licensed and made available
are licensed and made available under the terms and conditions of the BSD License under the terms and conditions of the BSD License which accompanies this
which accompanies this distribution. The full text of the license may be found at distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@ -653,7 +653,6 @@ EslIp4RxComplete (
) )
{ {
size_t LengthInBytes; size_t LengthInBytes;
ESL_PORT * pPort;
ESL_PACKET * pPacket; ESL_PACKET * pPacket;
EFI_IP4_RECEIVE_DATA * pRxData; EFI_IP4_RECEIVE_DATA * pRxData;
EFI_STATUS Status; EFI_STATUS Status;
@ -663,7 +662,6 @@ EslIp4RxComplete (
// //
// Get the operation status. // Get the operation status.
// //
pPort = pIo->pPort;
Status = pIo->Token.Ip4Rx.Status; Status = pIo->Token.Ip4Rx.Status;
// //
@ -672,7 +670,7 @@ EslIp4RxComplete (
pRxData = pIo->Token.Ip4Rx.Packet.RxData; pRxData = pIo->Token.Ip4Rx.Packet.RxData;
LengthInBytes = pRxData->HeaderLength + pRxData->DataLength; LengthInBytes = pRxData->HeaderLength + pRxData->DataLength;
// //{{
// +--------------------+ +----------------------+ // +--------------------+ +----------------------+
// | ESL_IO_MGMT | | Data Buffer | // | ESL_IO_MGMT | | Data Buffer |
// | | | (Driver owned) | // | | | (Driver owned) |
@ -692,7 +690,7 @@ EslIp4RxComplete (
// //
// //
// Save the data in the packet // Save the data in the packet
// //}}
pPacket = pIo->pPacket; pPacket = pIo->pPacket;
pPacket->Op.Ip4Rx.pRxData = pRxData; pPacket->Op.Ip4Rx.pRxData = pRxData;

View File

@ -1,11 +1,11 @@
/** @file /** @file
Implement the TCP4 driver support for the socket layer. Implement the TCP4 driver support for the socket layer.
Copyright (c) 2011, Intel Corporation Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
All rights reserved. This program and the accompanying materials This program and the accompanying materials are licensed and made available
are licensed and made available under the terms and conditions of the BSD License under the terms and conditions of the BSD License which accompanies this
which accompanies this distribution. The full text of the license may be found at distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@ -840,7 +840,6 @@ EslTcp4ListenComplete (
EFI_HANDLE ChildHandle; EFI_HANDLE ChildHandle;
struct sockaddr_in LocalAddress; struct sockaddr_in LocalAddress;
EFI_TCP4_CONFIG_DATA * pConfigData; EFI_TCP4_CONFIG_DATA * pConfigData;
ESL_LAYER * pLayer;
ESL_PORT * pNewPort; ESL_PORT * pNewPort;
ESL_SOCKET * pNewSocket; ESL_SOCKET * pNewSocket;
ESL_SOCKET * pSocket; ESL_SOCKET * pSocket;
@ -869,7 +868,6 @@ EslTcp4ListenComplete (
// Allocate a socket for this connection // Allocate a socket for this connection
// //
ChildHandle = NULL; ChildHandle = NULL;
pLayer = &mEslLayer;
Status = EslSocketAllocate ( &ChildHandle, Status = EslSocketAllocate ( &ChildHandle,
DEBUG_CONNECTION, DEBUG_CONNECTION,
&pNewSocket ); &pNewSocket );
@ -1924,7 +1922,6 @@ EslTcp4TxBuffer (
ESL_PACKET ** ppQueueHead; ESL_PACKET ** ppQueueHead;
ESL_PACKET ** ppQueueTail; ESL_PACKET ** ppQueueTail;
ESL_PACKET * pPreviousPacket; ESL_PACKET * pPreviousPacket;
ESL_TCP4_CONTEXT * pTcp4;
size_t * pTxBytes; size_t * pTxBytes;
EFI_TCP4_TRANSMIT_DATA * pTxData; EFI_TCP4_TRANSMIT_DATA * pTxData;
EFI_STATUS Status; EFI_STATUS Status;
@ -1951,7 +1948,6 @@ EslTcp4TxBuffer (
// //
// Determine the queue head // Determine the queue head
// //
pTcp4 = &pPort->Context.Tcp4;
bUrgent = (BOOLEAN)( 0 != ( Flags & MSG_OOB )); bUrgent = (BOOLEAN)( 0 != ( Flags & MSG_OOB ));
bUrgentQueue = bUrgent bUrgentQueue = bUrgent
&& ( !pSocket->bOobInLine ) && ( !pSocket->bOobInLine )

View File

@ -1,11 +1,11 @@
/** @file /** @file
Implement the TCP6 driver support for the socket layer. Implement the TCP6 driver support for the socket layer.
Copyright (c) 2011, Intel Corporation Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
All rights reserved. This program and the accompanying materials This program and the accompanying materials are licensed and made available
are licensed and made available under the terms and conditions of the BSD License under the terms and conditions of the BSD License which accompanies this
which accompanies this distribution. The full text of the license may be found at distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@ -871,7 +871,6 @@ EslTcp6ListenComplete (
EFI_HANDLE ChildHandle; EFI_HANDLE ChildHandle;
struct sockaddr_in6 LocalAddress; struct sockaddr_in6 LocalAddress;
EFI_TCP6_CONFIG_DATA * pConfigData; EFI_TCP6_CONFIG_DATA * pConfigData;
ESL_LAYER * pLayer;
ESL_PORT * pNewPort; ESL_PORT * pNewPort;
ESL_SOCKET * pNewSocket; ESL_SOCKET * pNewSocket;
ESL_SOCKET * pSocket; ESL_SOCKET * pSocket;
@ -900,7 +899,6 @@ EslTcp6ListenComplete (
// Allocate a socket for this connection // Allocate a socket for this connection
// //
ChildHandle = NULL; ChildHandle = NULL;
pLayer = &mEslLayer;
Status = EslSocketAllocate ( &ChildHandle, Status = EslSocketAllocate ( &ChildHandle,
DEBUG_CONNECTION, DEBUG_CONNECTION,
&pNewSocket ); &pNewSocket );
@ -1993,7 +1991,6 @@ EslTcp6TxBuffer (
ESL_PACKET ** ppQueueHead; ESL_PACKET ** ppQueueHead;
ESL_PACKET ** ppQueueTail; ESL_PACKET ** ppQueueTail;
ESL_PACKET * pPreviousPacket; ESL_PACKET * pPreviousPacket;
ESL_TCP6_CONTEXT * pTcp6;
size_t * pTxBytes; size_t * pTxBytes;
EFI_TCP6_TRANSMIT_DATA * pTxData; EFI_TCP6_TRANSMIT_DATA * pTxData;
EFI_STATUS Status; EFI_STATUS Status;
@ -2020,7 +2017,6 @@ EslTcp6TxBuffer (
// //
// Determine the queue head // Determine the queue head
// //
pTcp6 = &pPort->Context.Tcp6;
bUrgent = (BOOLEAN)( 0 != ( Flags & MSG_OOB )); bUrgent = (BOOLEAN)( 0 != ( Flags & MSG_OOB ));
bUrgentQueue = bUrgent bUrgentQueue = bUrgent
&& ( !pSocket->bOobInLine ) && ( !pSocket->bOobInLine )

View File

@ -292,17 +292,17 @@ FIFO_Dequeue (
SizeOfElement = Self->ElementSize; // Get size of this FIFO's elements SizeOfElement = Self->ElementSize; // Get size of this FIFO's elements
Count = MIN(Count, Self->Count(Self, AsElements)); // Lesser of requested or actual Count = MIN(Count, Self->Count(Self, AsElements)); // Lesser of requested or actual
QPtr = (UINTN)Self->Queue + (RDex * Self->ElementSize); // Point to Read location in FIFO QPtr = (UINTN)Self->Queue + (RDex * SizeOfElement); // Point to Read location in FIFO
for(i = 0; i < Count; ++i) { // Iterate Count times... for(i = 0; i < Count; ++i) { // Iterate Count times...
(void)CopyMem(pElement, (const void *)QPtr, Self->ElementSize); // Copy element from FIFO to caller's buffer (void)CopyMem(pElement, (const void *)QPtr, SizeOfElement); // Copy element from FIFO to caller's buffer
RDex = (UINT32)ModuloIncrement(RDex, Self->NumElements); // Increment Read Index RDex = (UINT32)ModuloIncrement(RDex, Self->NumElements); // Increment Read Index
if(RDex == 0) { // If the index wrapped if(RDex == 0) { // If the index wrapped
QPtr = (UINTN)Self->Queue; // Point back to beginning of data QPtr = (UINTN)Self->Queue; // Point back to beginning of data
} }
else { // Otherwise else { // Otherwise
QPtr += Self->ElementSize; // Point to the next element in FIFO QPtr += SizeOfElement; // Point to the next element in FIFO
} }
pElement = (char*)pElement + Self->ElementSize; // Point to next element in caller's buffer pElement = (char*)pElement + SizeOfElement; // Point to next element in caller's buffer
} // Iterate: for loop } // Iterate: for loop
if(Consume) { // If caller requests data consumption if(Consume) { // If caller requests data consumption
Self->ReadIndex = RDex; // Set FIFO's Read Index to new Index Self->ReadIndex = RDex; // Set FIFO's Read Index to new Index

View File

@ -75,7 +75,7 @@ IIO_GetInChar (
{ {
cIIO *This; cIIO *This;
cFIFO *InBuf; cFIFO *InBuf;
EFI_STATUS Status; size_t Status;
ssize_t NumRead; ssize_t NumRead;
wint_t RetVal; wint_t RetVal;
wchar_t InChar; wchar_t InChar;
@ -92,8 +92,10 @@ IIO_GetInChar (
} }
if(BufCnt > 0) { if(BufCnt > 0) {
Status = InBuf->Read(InBuf, &InChar, 1); Status = InBuf->Read(InBuf, &InChar, 1);
--BufCnt; if (Status > 0) {
NumRead = 1; --BufCnt;
NumRead = 1;
}
} }
else { else {
NumRead = filp->f_ops->fo_read(filp, &filp->f_offset, sizeof(wchar_t), &InChar); NumRead = filp->f_ops->fo_read(filp, &filp->f_offset, sizeof(wchar_t), &InChar);

View File

@ -8,7 +8,7 @@
It is the responsibility of the caller, or higher level function, to perform It is the responsibility of the caller, or higher level function, to perform
any necessary translation between wide and narrow characters. any necessary translation between wide and narrow characters.
Copyright (c) 2012, Intel Corporation. All rights reserved.<BR> Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this under the terms and conditions of the BSD License which accompanies this
distribution. The full text of the license may be found at distribution. The full text of the license may be found at
@ -63,7 +63,6 @@ IIO_WriteOne(struct __filedes *filp, cFIFO *OBuf, wchar_t InCh)
UINT32 CurRow; // Current cursor row on the screen UINT32 CurRow; // Current cursor row on the screen
UINT32 PrevColumn; // Previous column. Used to detect wrapping. UINT32 PrevColumn; // Previous column. Used to detect wrapping.
UINT32 AdjColumn; // Current cursor column on the screen UINT32 AdjColumn; // Current cursor column on the screen
UINT32 AdjRow; // Current cursor row on the screen
RetVal = -1; RetVal = -1;
wcb = wc; wcb = wc;
@ -79,7 +78,6 @@ IIO_WriteOne(struct __filedes *filp, cFIFO *OBuf, wchar_t InCh)
CurRow = This->CurrentXY.Row; CurRow = This->CurrentXY.Row;
numW = 1; // The majority of characters buffer one character numW = 1; // The majority of characters buffer one character
AdjRow = 0; // Most characters just cause horizontal movement
AdjColumn = 0; AdjColumn = 0;
if(OFlag & OPOST) { if(OFlag & OPOST) {
/* Perform output processing */ /* Perform output processing */
@ -127,7 +125,6 @@ IIO_WriteOne(struct __filedes *filp, cFIFO *OBuf, wchar_t InCh)
numW = 2; numW = 2;
CurColumn = 0; CurColumn = 0;
} }
AdjRow = 1;
break; //}} break; //}}
case CHAR_BACKSPACE: //{{ case CHAR_BACKSPACE: //{{

View File

@ -37,7 +37,6 @@ IIO_NonCanonRead (
cIIO *This; cIIO *This;
cFIFO *InBuf; cFIFO *InBuf;
struct termios *Termio; struct termios *Termio;
EFI_STATUS Status;
ssize_t NumRead; ssize_t NumRead;
cc_t tioMin; cc_t tioMin;
cc_t tioTime; cc_t tioTime;
@ -74,7 +73,7 @@ IIO_NonCanonRead (
if(InBuf->IsEmpty(InBuf)) { if(InBuf->IsEmpty(InBuf)) {
NumRead = filp->f_ops->fo_read(filp, &filp->f_offset, sizeof(wchar_t), &InChar); NumRead = filp->f_ops->fo_read(filp, &filp->f_offset, sizeof(wchar_t), &InChar);
if(NumRead > 0) { if(NumRead > 0) {
Status = InBuf->Write(InBuf, &InChar, 1); // Buffer the character (void) InBuf->Write(InBuf, &InChar, 1); // Buffer the character
} }
} }
// break; // break;

View File

@ -1,7 +1,6 @@
/* /** @file
* Copyright (c) 1999, 2000 *
* Intel Corporation. * Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -100,9 +99,11 @@ writev(
int iovcnt int iovcnt
) )
{ {
const struct iovec *pVecTmp; const struct iovec *pVecTmp;
char *pBuf, *pBufTmp; char *pBuf;
size_t TotalBytes, i, ret; size_t TotalBytes;
size_t i;
size_t ret;
// //
// See how much memory we'll need // See how much memory we'll need
@ -126,7 +127,7 @@ writev(
// Copy vectors to the buffer // Copy vectors to the buffer
// //
for (pBufTmp = pBuf; iovcnt; iovcnt--) { for (; iovcnt; iovcnt--) {
bcopy(iov->iov_base, pBuf, iov->iov_len); bcopy(iov->iov_base, pBuf, iov->iov_len);
pBuf += iov->iov_len; pBuf += iov->iov_len;
iov++; iov++;