[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()).
This commit is contained in:
Michael Brown
2009-02-15 08:41:46 +00:00
parent 46da51703a
commit 8ae1cac050
7 changed files with 18 additions and 32 deletions

View File

@@ -1052,12 +1052,6 @@ static int dhcp_deliver_iob ( struct xfer_interface *xfer,
int rc = 0;
/* Sanity checks */
if ( ! meta ) {
DBGC ( dhcp, "DHCP %p received packet without metadata\n",
dhcp );
rc = -EINVAL;
goto err_no_meta;
}
if ( ! meta->src ) {
DBGC ( dhcp, "DHCP %p received packet without source port\n",
dhcp );
@@ -1106,7 +1100,6 @@ static int dhcp_deliver_iob ( struct xfer_interface *xfer,
dhcppkt_put ( dhcppkt );
err_alloc_dhcppkt:
err_no_src:
err_no_meta:
free_iob ( iobuf );
return rc;
}

View File

@@ -839,7 +839,7 @@ static int tftp_rx_error ( struct tftp_request *tftp, void *buf, size_t len ) {
*
* @v tftp TFTP connection
* @v iobuf I/O buffer
* @v meta Transfer metadata, or NULL
* @v meta Transfer metadata
* @ret rc Return status code
*/
static int tftp_rx ( struct tftp_request *tftp,
@@ -856,11 +856,6 @@ static int tftp_rx ( struct tftp_request *tftp,
"%zd\n", tftp, len );
goto done;
}
if ( ! meta ) {
DBGC ( tftp, "TFTP %p received packet without metadata\n",
tftp );
goto done;
}
if ( ! meta->src ) {
DBGC ( tftp, "TFTP %p received packet without source port\n",
tftp );
@@ -907,7 +902,7 @@ static int tftp_rx ( struct tftp_request *tftp,
*
* @v socket Transport layer interface
* @v iobuf I/O buffer
* @v meta Transfer metadata, or NULL
* @v meta Transfer metadata
* @ret rc Return status code
*/
static int tftp_socket_deliver_iob ( struct xfer_interface *socket,
@@ -951,7 +946,7 @@ static struct xfer_interface_operations tftp_socket_operations = {
*
* @v mc_socket Multicast transport layer interface
* @v iobuf I/O buffer
* @v meta Transfer metadata, or NULL
* @v meta Transfer metadata
* @ret rc Return status code
*/
static int tftp_mc_socket_deliver_iob ( struct xfer_interface *mc_socket,