summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Duncan <lduncan@suse.com>2022-09-22 09:43:50 -0700
committerGitHub <noreply@github.com>2022-09-22 09:43:50 -0700
commitf633c09a7a2976069b1dfd98d9979349e92c38b5 (patch)
tree24a2b5113ce4aa0a00ebb7c72fb63e3b788365c5
parentd03dfb4e9523b4f8537a673727d252695c241745 (diff)
downloadopen-iscsi-f633c09a7a2976069b1dfd98d9979349e92c38b5.tar.gz
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.
-rw-r--r--libopeniscsiusr/session.c12
1 files 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 *));