Those checks are there for a reason. Did you test your patch? Often those data sets are NULL.
Regards -steve On Mon, 2009-04-20 at 16:49 +0200, Jim Meyering wrote: > Same thing, but for openais: > > > From 41a09aa652374e5dc89729517d031303f90b1990 Mon Sep 17 00:00:00 2001 > From: Jim Meyering <[email protected]> > Date: Mon, 20 Apr 2009 16:45:13 +0200 > Subject: [PATCH] remove useless if-before-free tests > > * lib/amf.c (saAmfDispatch): Remove useless if. > * lib/evt.c (eventHandleInstanceDestructor): Likewise. > (saEvtEventAttributesSet): Likewise. > * services/amfsg.c (acsm_enter_idle): Likewise. > * services/ckpt.c (checkpoint_section_release): Likewise. > * services/evt.c (delete_channel, free_event_data): Likewise. > * services/msg.c (message_handler_req_exec_msg_messagesend): Likewise. > (message_handler_req_exec_msg_messagesendasync): Likewise. > (message_handler_req_exec_msg_messageget): Likewise. > (message_handler_req_exec_msg_messagesendreceive): Likewise. > --- > lib/amf.c | 4 +--- > lib/evt.c | 8 ++------ > services/amfsg.c | 8 ++------ > services/ckpt.c | 8 ++------ > services/evt.c | 8 ++------ > services/msg.c | 16 ++++------------ > 6 files changed, 13 insertions(+), 39 deletions(-) > > diff --git a/lib/amf.c b/lib/amf.c > index fc55aa6..36bf14e 100644 > --- a/lib/amf.c > +++ b/lib/amf.c > @@ -296,9 +296,7 @@ saAmfDispatch ( > res_lib_amf_csisetcallback->haState, > &csi_descriptor); > > - if (csi_attribute_array != NULL) { > - free(csi_attribute_array); > - } > + free(csi_attribute_array); > break; > } > case MESSAGE_RES_AMF_CSIREMOVECALLBACK: > diff --git a/lib/evt.c b/lib/evt.c > index 0f253e4..10747fd 100644 > --- a/lib/evt.c > +++ b/lib/evt.c > @@ -296,9 +296,7 @@ static void eventHandleInstanceDestructor(void *instance) > } > free(edi->edi_patterns.patterns); > } > - if (edi->edi_event_data) { > - free(edi->edi_event_data); > - } > + free(edi->edi_event_data); > > pthread_mutex_destroy(&edi->edi_mutex); > } > @@ -1445,9 +1443,7 @@ saEvtEventAttributesSet( > */ > if (oldpatterns) { > for (i = 0; i < oldnumber; i++) { > - if (oldpatterns[i].pattern) { > - free(oldpatterns[i].pattern); > - } > + free(oldpatterns[i].pattern); > } > free (oldpatterns); > } > diff --git a/services/amfsg.c b/services/amfsg.c > index d8ce0e8..69e639c 100644 > --- a/services/amfsg.c > +++ b/services/amfsg.c > @@ -513,12 +513,8 @@ static void acsm_enter_idle (amf_sg_t *sg) > } > } > > - if (sg->recovery_scope.sus != NULL) { > - free ((void *)sg->recovery_scope.sus); > - } > - if (sg->recovery_scope.sis != NULL) { > - free ((void *)sg->recovery_scope.sis); > - } > + free ((void *)sg->recovery_scope.sus); > + free ((void *)sg->recovery_scope.sis); > memset (&sg->recovery_scope, 0, sizeof (struct sg_recovery_scope)); > sg->node_to_start = NULL; > > diff --git a/services/ckpt.c b/services/ckpt.c > index 7077f8b..89713f0 100644 > --- a/services/ckpt.c > +++ b/services/ckpt.c > @@ -988,12 +988,8 @@ static void checkpoint_section_release (struct > checkpoint_section *section) > list_del (§ion->list); > > api->timer_delete (section->expiration_timer); > - if (section->section_descriptor.section_id.id) { > - free (section->section_descriptor.section_id.id); > - } > - if (section->section_data) { > - free (section->section_data); > - } > + free (section->section_descriptor.section_id.id); > + free (section->section_data); > free (section); > } > > diff --git a/services/evt.c b/services/evt.c > index e6115f7..c6bfedb 100644 > --- a/services/evt.c > +++ b/services/evt.c > @@ -1112,9 +1112,7 @@ static void delete_channel(struct > event_svr_channel_instance *eci) > } > > list_del(&eci->esc_entry); > - if (eci->esc_node_opens) { > - free(eci->esc_node_opens); > - } > + free(eci->esc_node_opens); > free(eci); > } > } > @@ -1130,9 +1128,7 @@ free_event_data(struct event_data *edp) > } > log_printf(LOGSYS_LEVEL_DEBUG, "Freeing event ID: 0x%llx\n", > (unsigned long long)edp->ed_event.led_event_id); > - if (edp->ed_delivered) { > - free(edp->ed_delivered); > - } > + free(edp->ed_delivered); > > free(edp); > } > diff --git a/services/msg.c b/services/msg.c > index 6d52785..3ab58fd 100644 > --- a/services/msg.c > +++ b/services/msg.c > @@ -3335,9 +3335,7 @@ error_exit: > > /* ? */ > if ((error != SA_AIS_OK) && (msg != NULL)) { > - if (msg->message.data != NULL) { > - free (msg->message.data); > - } > + free (msg->message.data); > free (msg); > } > } > @@ -3506,9 +3504,7 @@ error_exit: > > /* ? */ > if ((error != SA_AIS_OK) && (msg != NULL)) { > - if (msg->message.data != NULL) { > - free (msg->message.data); > - } > + free (msg->message.data); > free (msg); > } > } > @@ -3597,9 +3593,7 @@ error_exit: > } > } > > - if (msg != NULL) { > - free (msg); > - } > + free (msg); > } > > static void message_handler_req_exec_msg_messagedatafree ( > @@ -3789,9 +3783,7 @@ error_exit: > > /* ? */ > if ((error != SA_AIS_OK) && (msg != NULL)) { > - if (msg->message.data != NULL) { > - free (msg->message.data); > - } > + free (msg->message.data); > free (msg); > } > } > -- > 1.6.3.rc0.230.g3edd6 > _______________________________________________ > Openais mailing list > [email protected] > https://lists.linux-foundation.org/mailman/listinfo/openais _______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
