qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block/iscsi: Document why we use raw malloc()
@ 2023-07-27 15:07 Peter Maydell
  2023-07-27 15:15 ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2023-07-27 15:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Ronnie Sahlberg, Paolo Bonzini, Peter Lieven,
	Kevin Wolf, Hanna Reitz

In block/iscsi.c we use a raw malloc() call, which is unusual
given the project standard is to use the glib memory allocation
functions. Document why we do so, to avoid it being converted
to g_malloc() by mistake.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
There aren't many uses of raw malloc() in the codebase
other than third-party library sourcecode. Mostly we have
a comment noting when we're doing it deliberately.
---
 block/iscsi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block/iscsi.c b/block/iscsi.c
index 34f97ab6460..5640c8b5657 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1058,6 +1058,7 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs,
         return NULL;
     }
 
+    /* Must use malloc(): this is freed via scsi_free_scsi_task() */
     acb->task = malloc(sizeof(struct scsi_task));
     if (acb->task == NULL) {
         error_report("iSCSI: Failed to allocate task for scsi command. %s",
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-18 16:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-27 15:07 [PATCH] block/iscsi: Document why we use raw malloc() Peter Maydell
2023-07-27 15:15 ` Peter Maydell
2023-08-18 15:56   ` Kevin Wolf
2023-08-18 16:00     ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).