Remove the discard_const() macro

Declare dynamically allocated strings as 'char *' instead of 'const char *'.
Remove the discard_const() macro. Do not test whether or not a pointer is
NULL before calling free() because it is allowed to pass NULL to free().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
This commit is contained in:
Bart Van Assche
2020-02-28 21:32:30 -08:00
parent aff4b7600b
commit 3804f3c2e0
18 changed files with 50 additions and 141 deletions

View File

@@ -89,14 +89,14 @@ iscsi_free_discovery_addresses(struct iscsi_context *iscsi, struct iscsi_discove
while (addresses != NULL) {
struct iscsi_discovery_address *next = addresses->next;
iscsi_free(iscsi, discard_const(addresses->target_name));
iscsi_free(iscsi, addresses->target_name);
addresses->target_name = NULL;
while (addresses->portals != NULL) {
struct iscsi_target_portal *next_portal = addresses->portals->next;
iscsi_free(iscsi, discard_const(addresses->portals->portal));
iscsi_free(iscsi, discard_const(addresses->portals));
iscsi_free(iscsi, addresses->portals->portal);
iscsi_free(iscsi, addresses->portals);
addresses->portals = next_portal;
}

View File

@@ -1828,11 +1828,12 @@ void iscsi_free_discovery_data(struct iscsi_context *iscsi _U_,
while (da->portals) {
struct iscsi_target_portal *ponext = da->portals->next;
free(discard_const(da->portals->portal));
free(da->portals->portal);
free(da->portals);
da->portals = ponext;
}
free(discard_const(da->target_name));
free(da->target_name);
free(da);
da = danext;
}