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,3 +1,13 @@
/** @file
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 $ */ /* $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 $ */ /* $KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $ */
@ -411,15 +421,19 @@ ip6_sa2str(
int flags int flags
) )
{ {
#if 0
unsigned int ifindex; unsigned int ifindex;
const struct in6_addr *a6; const struct in6_addr *a6;
#endif
int n; int n;
_DIAGASSERT(sa6 != NULL); _DIAGASSERT(sa6 != NULL);
_DIAGASSERT(buf != NULL); _DIAGASSERT(buf != NULL);
#if 0
ifindex = (unsigned int)sa6->sin6_scope_id; ifindex = (unsigned int)sa6->sin6_scope_id;
a6 = &sa6->sin6_addr; a6 = &sa6->sin6_addr;
#endif
#ifdef NI_NUMERICSCOPE #ifdef NI_NUMERICSCOPE
if ((flags & NI_NUMERICSCOPE) != 0) { if ((flags & NI_NUMERICSCOPE) != 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,9 +92,11 @@ IIO_GetInChar (
} }
if(BufCnt > 0) { if(BufCnt > 0) {
Status = InBuf->Read(InBuf, &InChar, 1); Status = InBuf->Read(InBuf, &InChar, 1);
if (Status > 0) {
--BufCnt; --BufCnt;
NumRead = 1; 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:
@ -101,8 +100,10 @@ writev(
) )
{ {
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++;