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

Removed variables that had no effect on code behavior.
Normalized comment formatting.

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@16284 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Olivier Martin 2014-10-31 17:50:33 +00:00 committed by darylm503
parent 4d5b818c78
commit beaaa3b715
8 changed files with 285 additions and 550 deletions

View File

@ -1,22 +1,19 @@
/** @file
Implement the bind API.
Copyright (c) 2011, Intel Corporation
All rights reserved. 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
Copyright (c) 2011 - 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 that 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.
**/
#include <SocketInternals.h>
/**
Bind a name to a socket.
/** Bind a name to a socket.
The bind routine connects a name (network address) to a socket on the local machine.
@ -40,7 +37,6 @@
@return The bind routine returns zero (0) if successful and -1 upon failure.
In the case of an error, ::errno contains more information.
**/
int
bind (
@ -51,25 +47,19 @@ bind (
{
int BindStatus;
EFI_SOCKET_PROTOCOL * pSocketProtocol;
EFI_STATUS Status;
//
// Locate the context for this socket
//
pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );
if ( NULL != pSocketProtocol ) {
//
// Bind the socket
//
Status = pSocketProtocol->pfnBind ( pSocketProtocol,
(void) pSocketProtocol->pfnBind ( pSocketProtocol,
name,
namelen,
&errno );
}
//
// Return the operation stauts
//
BindStatus = ( 0 == errno ) ? 0 : -1;
return BindStatus;
}

View File

@ -1,22 +1,19 @@
/** @file
Implement the getsockopt API.
Copyright (c) 2011, Intel Corporation
All rights reserved. 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
Copyright (c) 2011 - 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 that 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.
**/
#include <SocketInternals.h>
/**
Get the socket options
/** Get the socket options
The
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html#">POSIX</a>
@ -31,7 +28,6 @@
@return This routine returns zero (0) if successful or -1 when an error occurs.
In the case of an error, ::errno contains more details.
**/
int
getsockopt (
@ -44,27 +40,19 @@ getsockopt (
{
int OptionStatus;
EFI_SOCKET_PROTOCOL * pSocketProtocol;
EFI_STATUS Status;
//
// Locate the context for this socket
//
pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );
if ( NULL != pSocketProtocol ) {
//
// Get the socket option
//
Status = pSocketProtocol->pfnOptionGet ( pSocketProtocol,
(void) pSocketProtocol->pfnOptionGet ( pSocketProtocol,
level,
option_name,
option_value,
option_len,
&errno );
}
//
// Return the operation stauts
//
OptionStatus = ( 0 == errno ) ? 0 : -1;
return OptionStatus;
}

View File

@ -1,22 +1,19 @@
/** @file
Implement the listen API.
Copyright (c) 2011, Intel Corporation
All rights reserved. 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
Copyright (c) 2011 - 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 that 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.
**/
#include <SocketInternals.h>
/**
Establish the known port to listen for network connections.
/** Establish the known port to listen for network connections.
The listen routine places the port into a state that enables connection
attempts. Connections are placed into FIFO order in a queue to be serviced
@ -35,7 +32,6 @@
@return This routine returns zero (0) if successful or -1 when an error occurs.
In the case of an error, ::errno contains more details.
**/
int
listen (
@ -45,24 +41,16 @@ listen (
{
int ListenStatus;
EFI_SOCKET_PROTOCOL * pSocketProtocol;
EFI_STATUS Status;
//
// Locate the context for this socket
//
pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );
if ( NULL != pSocketProtocol ) {
//
// Enable connections on the known port
//
Status = pSocketProtocol->pfnListen ( pSocketProtocol,
(void) pSocketProtocol->pfnListen ( pSocketProtocol,
backlog,
&errno );
}
//
// Return the operation stauts
//
ListenStatus = ( 0 == errno ) ? 0 : -1;
return ListenStatus;
}

View File

@ -1,29 +1,24 @@
/** @file
Implement the poll API.
Copyright (c) 2011, Intel Corporation
All rights reserved. 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
Copyright (c) 2011 - 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 that 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.
**/
#include <SocketInternals.h>
/**
Poll the socket for activity
/** Poll the socket for activity
@param [in] pDescriptor Descriptor address for the file
@param [in] Events Mask of events to detect
@return Detected events for the socket
**/
short
EFIAPI
@ -32,27 +27,19 @@ BslSocketPoll (
IN short Events
)
{
short DetectedEvents;
short DetectedEvents;
EFI_SOCKET_PROTOCOL * pSocketProtocol;
EFI_STATUS Status;
//
// Locate the socket protocol
//
DetectedEvents = 0;
pSocketProtocol = BslValidateSocketFd ( pDescriptor, &errno );
if ( NULL != pSocketProtocol ) {
//
// Poll the socket
//
Status = pSocketProtocol->pfnPoll ( pSocketProtocol,
Events,
&DetectedEvents,
&errno );
(void) pSocketProtocol->pfnPoll ( pSocketProtocol,
Events,
&DetectedEvents,
&errno );
}
//
// Return the detected events
//
return DetectedEvents;
}

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.
*
@ -476,9 +486,9 @@ ans=%d, auth=%d, add=%d, rcode=%d\n",
dname = zptr->z_ns[k].nsname;
qtype = T_A;
}
} /* while */
}
--ttl; // Suppress the "Set but not used" warning/error for ttl.
_res.options |= RES_DEBUG;
for (zptr = zgrp_start; zptr; zptr = zptr->z_next) {
@ -502,8 +512,7 @@ ans=%d, auth=%d, add=%d, rcode=%d\n",
} else
fprintf(stdout, "res_mkupdate: packet size = %d\n", n);
/*
* Override the list of NS records from res_init() with
/* Override the list of NS records from res_init() with
* the authoritative nameservers for the zone being updated.
* Sort primary to be the first in the list of nameservers.
*/

View File

@ -1,22 +1,19 @@
/** @file
Implement the setsockopt API.
Copyright (c) 2011, Intel Corporation
All rights reserved. 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
Copyright (c) 2011 - 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 that 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.
**/
#include <SocketInternals.h>
/**
Set the socket options
/** Set the socket options
The
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html">POSIX</a>
@ -30,7 +27,6 @@
@return This routine returns zero (0) upon success and -1 when an error occurs.
In the case of an error, ::errno contains more details.
**/
int
setsockopt (
@ -43,27 +39,19 @@ setsockopt (
{
int OptionStatus;
EFI_SOCKET_PROTOCOL * pSocketProtocol;
EFI_STATUS Status;
//
// Locate the context for this socket
//
pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );
if ( NULL != pSocketProtocol ) {
//
// Set the socket option
//
Status = pSocketProtocol->pfnOptionSet ( pSocketProtocol,
level,
option_name,
option_value,
option_len,
&errno );
(void) pSocketProtocol->pfnOptionSet (pSocketProtocol,
level,
option_name,
option_value,
option_len,
&errno );
}
//
// Return the operation stauts
//
OptionStatus = ( 0 == errno ) ? 0 : -1;
return OptionStatus;
}

View File

@ -9,14 +9,11 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "Socket.h"
/**
Get the local socket address
/** Get the local socket address.
This routine returns the IPv4 address associated with the local
socket.
@ -25,9 +22,7 @@
network address for the SOCK_RAW socket.
@param [in] pPort Address of an ::ESL_PORT structure.
@param [out] pAddress Network address to receive the local system address
**/
VOID
EslIp4LocalAddressGet (
@ -40,9 +35,7 @@ EslIp4LocalAddressGet (
DBG_ENTER ( );
//
// Return the local address
//
pIp4 = &pPort->Context.Ip4;
pLocalAddress = (struct sockaddr_in *)pAddress;
pLocalAddress->sin_family = AF_INET;
@ -54,8 +47,7 @@ EslIp4LocalAddressGet (
}
/**
Set the local port address.
/** Set the local port address.
This routine sets the local port address.
@ -75,7 +67,6 @@ EslIp4LocalAddressGet (
@param [in] bBindTest TRUE = run bind testing
@retval EFI_SUCCESS The operation was successful
**/
EFI_STATUS
EslIp4LocalAddressSet (
@ -91,23 +82,17 @@ EslIp4LocalAddressSet (
DBG_ENTER ( );
//
// Validate the address
//
pIpAddress = (struct sockaddr_in *)pSockAddr;
if ( INADDR_BROADCAST == pIpAddress->sin_addr.s_addr ) {
//
// The local address must not be the broadcast address
//
Status = EFI_INVALID_PARAMETER;
pPort->pSocket->errno = EADDRNOTAVAIL;
}
else {
Status = EFI_SUCCESS;
//
// Set the local address
//
pIpAddress = (struct sockaddr_in *)pSockAddr;
pIpv4Address = (UINT8 *)&pIpAddress->sin_addr.s_addr;
pConfig = &pPort->Context.Ip4.ModeData.ConfigData;
@ -116,14 +101,10 @@ EslIp4LocalAddressSet (
pConfig->StationAddress.Addr[2] = pIpv4Address[2];
pConfig->StationAddress.Addr[3] = pIpv4Address[3];
//
// Determine if the default address is used
//
pConfig->UseDefaultAddress = (BOOLEAN)( 0 == pIpAddress->sin_addr.s_addr );
//
// Display the local address
//
DEBUG (( DEBUG_BIND,
"0x%08x: Port, Local IP4 Address: %d.%d.%d.%d\r\n",
pPort,
@ -132,9 +113,7 @@ EslIp4LocalAddressSet (
pConfig->StationAddress.Addr[2],
pConfig->StationAddress.Addr[3]));
//
// Set the subnet mask
//
if ( pConfig->UseDefaultAddress ) {
pConfig->SubnetMask.Addr[0] = 0;
pConfig->SubnetMask.Addr[1] = 0;
@ -148,17 +127,13 @@ EslIp4LocalAddressSet (
pConfig->SubnetMask.Addr[3] = ( 224 <= pConfig->StationAddress.Addr[0]) ? 0xff : 0;
}
}
//
// Return the operation status
//
DBG_EXIT_STATUS ( Status );
return Status;
}
/**
Get the option value
/** Get the option value.
This routine handles the IPv4 level options.
@ -171,7 +146,6 @@ EslIp4LocalAddressSet (
@param [out] pOptionLength Buffer to receive the option length
@retval EFI_SUCCESS - Socket data successfully received
**/
EFI_STATUS
EslIp4OptionGet (
@ -185,20 +159,14 @@ EslIp4OptionGet (
DBG_ENTER ( );
//
// Assume success
//
pSocket->errno = 0;
Status = EFI_SUCCESS;
//
// Attempt to get the option
//
switch ( OptionName ) {
default:
//
// Option not supported
//
pSocket->errno = ENOPROTOOPT;
Status = EFI_INVALID_PARAMETER;
break;
@ -208,17 +176,13 @@ EslIp4OptionGet (
*pOptionLength = sizeof ( pSocket->bIncludeHeader );
break;
}
//
// Return the operation status
//
DBG_EXIT_STATUS ( Status );
return Status;
}
/**
Set the option value
/** Set the option value.
This routine handles the IPv4 level options.
@ -231,7 +195,6 @@ EslIp4OptionGet (
@param [in] OptionLength Length of the buffer in bytes
@retval EFI_SUCCESS - Option successfully set
**/
EFI_STATUS
EslIp4OptionSet (
@ -242,28 +205,22 @@ EslIp4OptionSet (
)
{
BOOLEAN bTrueFalse;
socklen_t LengthInBytes;
UINT8 * pOptionData;
//socklen_t LengthInBytes;
//UINT8 * pOptionData;
EFI_STATUS Status;
DBG_ENTER ( );
//
// Assume success
//
pSocket->errno = 0;
Status = EFI_SUCCESS;
//
// Determine if the option protocol matches
//
LengthInBytes = 0;
pOptionData = NULL;
//LengthInBytes = 0;
//pOptionData = NULL;
switch ( OptionName ) {
default:
//
// Protocol level not supported
//
DEBUG (( DEBUG_INFO | DEBUG_OPTION, "ERROR - Invalid protocol option\r\n" ));
pSocket->errno = ENOTSUP;
Status = EFI_UNSUPPORTED;
@ -271,31 +228,22 @@ EslIp4OptionSet (
case IP_HDRINCL:
//
// Validate the option length
//
if ( sizeof ( UINT32 ) == OptionLength ) {
//
// Restrict the input to TRUE or FALSE
//
bTrueFalse = TRUE;
if ( 0 == *(UINT32 *)pOptionValue ) {
bTrueFalse = FALSE;
}
pOptionValue = &bTrueFalse;
//
// Set the option value
//
pOptionData = (UINT8 *)&pSocket->bIncludeHeader;
LengthInBytes = sizeof ( pSocket->bIncludeHeader );
//pOptionData = (UINT8 *)&pSocket->bIncludeHeader;
//LengthInBytes = sizeof ( pSocket->bIncludeHeader );
}
break;
}
//
// Return the operation status
//
DBG_EXIT_STATUS ( Status );
return Status;
}

File diff suppressed because it is too large Load Diff