From f633c09a7a2976069b1dfd98d9979349e92c38b5 Mon Sep 17 00:00:00 2001 From: Lee Duncan Date: Thu, 22 Sep 2022 09:43:50 -0700 Subject: libopeniscsiusr: cleanup recent reallocarray->realloc change (#369) Just adding more comment, and removing the check to see if a pointer to a structure is zero. --- libopeniscsiusr/session.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libopeniscsiusr/session.c b/libopeniscsiusr/session.c index 489cea7..4d47592 100644 --- a/libopeniscsiusr/session.c +++ b/libopeniscsiusr/session.c @@ -289,11 +289,15 @@ int iscsi_sessions_get(struct iscsi_context *ctx, rc = LIBISCSI_OK; } } - /* reset session count and sessions array length to what we were able to read from sysfs */ + /* + * reset session count and sessions array length to what we were able to read from sysfs + * + * do not use reallocarray() for the sessions array, since not all platforms + * have that function call + */ *session_count = j; - /* XXX: asserts that there is no integer overflow */ - assert(!(sizeof(struct iscsi_session *) && - *session_count > UINT_MAX / sizeof(struct iscsi_session *))); + /* assert that there is no integer overflow in the realloc call */ + assert(!(*session_count > (UINT_MAX / sizeof(struct iscsi_session *)))); *sessions = realloc(*sessions, *session_count * sizeof(struct iscsi_session *)); -- cgit v1.2.1