From 4de36794f2ce2b443f6d32838717bb260a9c6abe Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 11 Nov 2012 08:03:44 -0800 Subject: [PATCH] Make scsi_allocated_memory private to scsi-lowlevel and remove the ptr pointer Change the list-head structure for in-task scsi memory allocations to be private to scsi-lowlevel since is is never accessed from anyehwere else and it is private to this function. Remove the pointer to the user data in the list head and replace it with a zero length buffer at the end of the header. Signed-off-by: Ronnie Sahlberg --- include/scsi-lowlevel.h | 5 ----- lib/scsi-lowlevel.c | 7 +++++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/scsi-lowlevel.h b/include/scsi-lowlevel.h index 9d25b47..53b4118 100644 --- a/include/scsi-lowlevel.h +++ b/include/scsi-lowlevel.h @@ -299,11 +299,6 @@ struct scsi_data { unsigned char *data; }; -struct scsi_allocated_memory { - struct scsi_allocated_memory *next; - void *ptr; -}; - enum scsi_residual { SCSI_RESIDUAL_NO_RESIDUAL = 0, SCSI_RESIDUAL_UNDERFLOW, diff --git a/lib/scsi-lowlevel.c b/lib/scsi-lowlevel.c index 3f8020e..45d516e 100644 --- a/lib/scsi-lowlevel.c +++ b/lib/scsi-lowlevel.c @@ -39,6 +39,10 @@ #include "scsi-lowlevel.h" #include "iscsi-private.h" +struct scsi_allocated_memory { + struct scsi_allocated_memory *next; + char buf[0]; +}; void scsi_free_scsi_task(struct scsi_task *task) @@ -64,9 +68,8 @@ scsi_malloc(struct scsi_task *task, size_t size) return NULL; } memset(mem, 0, sizeof(struct scsi_allocated_memory) + size); - mem->ptr = (void *) ((uintptr_t)mem + sizeof(struct scsi_allocated_memory)); SLIST_ADD(&task->mem, mem); - return mem->ptr; + return &mem->buf[0]; } struct value_string {