mirror of
https://github.com/ipxe/ipxe
synced 2025-12-19 11:00:27 +03:00
[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:
@@ -27,6 +27,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dummy transfer metadata
|
||||
*
|
||||
* This gets passed to xfer_interface::deliver_iob() and equivalents
|
||||
* when no metadata is available.
|
||||
*/
|
||||
static struct xfer_metadata dummy_metadata;
|
||||
|
||||
/**
|
||||
* Close data transfer interface
|
||||
*
|
||||
@@ -159,7 +167,6 @@ int xfer_deliver_iob_meta ( struct xfer_interface *xfer,
|
||||
*/
|
||||
int xfer_deliver_iob ( struct xfer_interface *xfer,
|
||||
struct io_buffer *iobuf ) {
|
||||
static struct xfer_metadata dummy_metadata;
|
||||
return xfer_deliver_iob_meta ( xfer, iobuf, &dummy_metadata );
|
||||
}
|
||||
|
||||
@@ -366,7 +373,7 @@ int xfer_deliver_as_iob ( struct xfer_interface *xfer,
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy ( iob_put ( iobuf, len ), data, len );
|
||||
return xfer->op->deliver_iob ( xfer, iobuf, NULL );
|
||||
return xfer->op->deliver_iob ( xfer, iobuf, &dummy_metadata );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user