diff options
author | Michael Brown | 2009-02-15 09:41:46 +0100 |
---|---|---|
committer | Michael Brown | 2009-02-15 09:44:22 +0100 |
commit | 8ae1cac0502c2a4d946f7bafa15a944bb1ef48a2 (patch) | |
tree | e271a28b9cb1ecb3749df8fc33e0d6f54eee8c8e /src/net/udp.c | |
parent | [umalloc] Avoid problems when _textdata_memsz is a multiple of 4kB (diff) | |
download | ipxe-8ae1cac0502c2a4d946f7bafa15a944bb1ef48a2.tar.gz ipxe-8ae1cac0502c2a4d946f7bafa15a944bb1ef48a2.tar.xz ipxe-8ae1cac0502c2a4d946f7bafa15a944bb1ef48a2.zip |
[xfer] Make consistent assumptions that xfer metadata can never be NULL
The documentation in xfer.h and xfer.c does not say that the metadata
parameter is optional in calls such as xfer_deliver_iob_meta() and the
deliver_iob() method. However, some code in net/ is prepared to
accept a NULL pointer, and xfer_deliver_as_iob() passes a NULL pointer
directly to the deliver_iob() method.
Fix this mess of conflicting assumptions by making everything assume
that the metadata parameter is mandatory, and fixing
xfer_deliver_as_iob() to pass in a dummy metadata structure (as is
already done in xfer_deliver_iob()).
Diffstat (limited to 'src/net/udp.c')
-rw-r--r-- | src/net/udp.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/net/udp.c b/src/net/udp.c index 57edb9c6..c3a1eba3 100644 --- a/src/net/udp.c +++ b/src/net/udp.c @@ -390,7 +390,7 @@ static struct io_buffer * udp_alloc_iob ( struct xfer_interface *xfer, * * @v xfer Data transfer interface * @v iobuf Datagram I/O buffer - * @v meta Data transfer metadata, or NULL + * @v meta Data transfer metadata * @ret rc Return status code */ static int udp_xfer_deliver_iob ( struct xfer_interface *xfer, @@ -398,19 +398,10 @@ static int udp_xfer_deliver_iob ( struct xfer_interface *xfer, struct xfer_metadata *meta ) { struct udp_connection *udp = container_of ( xfer, struct udp_connection, xfer ); - struct sockaddr_tcpip *src = NULL; - struct sockaddr_tcpip *dest = NULL; - struct net_device *netdev = NULL; - - /* Apply xfer metadata */ - if ( meta ) { - src = ( struct sockaddr_tcpip * ) meta->src; - dest = ( struct sockaddr_tcpip * ) meta->dest; - netdev = meta->netdev; - } /* Transmit data, if possible */ - udp_tx ( udp, iobuf, src, dest, netdev ); + udp_tx ( udp, iobuf, ( ( struct sockaddr_tcpip * ) meta->src ), + ( ( struct sockaddr_tcpip * ) meta->dest ), meta->netdev ); return 0; } |