summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-11-19 10:33:15 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-12-09 17:37:09 -0800
commite77dd2e4bc8227ebdab70b4233cb33ed690fa264 (patch)
treec40965b2ffd7dc02afac66aca8ce05b6086d8446
parent46f3ef4460aa2c1c2cba22897694a1cea572d506 (diff)
Remove a bunch of unnecessary casts with malloc & free calls
With modern compilers and headers, they cause more problems than they solve and just hide real issues. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Mark Kettenis <kettenis@openbsd.org> Reviewed-by: James Cloos <cloos@jhcloos.com>
-rw-r--r--src/SMlibint.h10
-rw-r--r--src/sm_client.c21
-rw-r--r--src/sm_manager.c4
-rw-r--r--src/sm_misc.c8
-rw-r--r--src/sm_process.c10
5 files changed, 25 insertions, 28 deletions
diff --git a/src/SMlibint.h b/src/SMlibint.h
index a478b48..c788739 100644
--- a/src/SMlibint.h
+++ b/src/SMlibint.h
@@ -236,7 +236,7 @@ in this Software without prior written authorization from The Open Group.
#define EXTRACT_ARRAY8(_pBuf, _swap, _len, _array8) \
{ \
EXTRACT_CARD32 (_pBuf, _swap, _len); \
- _array8 = (char *) malloc (_len + 1); \
+ _array8 = malloc (_len + 1); \
memcpy (_array8, _pBuf, _len); \
_array8[_len] = '\0'; \
_pBuf += _len + PAD64 (4 + _len); \
@@ -246,7 +246,7 @@ in this Software without prior written authorization from The Open Group.
{ \
CARD32 _len; \
EXTRACT_CARD32 (_pBuf, _swap, _len); \
- _string = (char *) malloc (_len + 1); \
+ _string = malloc (_len + 1); \
memcpy (_string, _pBuf, _len); \
_string[_len] = '\0'; \
_pBuf += _len + PAD64 (4 + _len); \
@@ -257,15 +257,15 @@ in this Software without prior written authorization from The Open Group.
int _i, _j; \
EXTRACT_CARD32 (_pBuf, _swap, _count); \
_pBuf += 4; \
- _props = (SmProp **) malloc (_count * sizeof (SmProp *)); \
+ _props = malloc (_count * sizeof (SmProp *)); \
for (_i = 0; _i < _count; _i++) \
{ \
- _props[_i] = (SmProp *) malloc (sizeof (SmProp)); \
+ _props[_i] = malloc (sizeof (SmProp)); \
EXTRACT_ARRAY8_AS_STRING (_pBuf, _swap, _props[_i]->name); \
EXTRACT_ARRAY8_AS_STRING (_pBuf, _swap, _props[_i]->type); \
EXTRACT_CARD32 (_pBuf, _swap, _props[_i]->num_vals); \
_pBuf += 4; \
- _props[_i]->vals = (SmPropValue *) malloc ( \
+ _props[_i]->vals = malloc ( \
_props[_i]->num_vals * sizeof (SmPropValue)); \
for (_j = 0; _j < _props[_i]->num_vals; _j++) \
{ \
diff --git a/src/sm_client.c b/src/sm_client.c
index faf2b9f..23d8e32 100644
--- a/src/sm_client.c
+++ b/src/sm_client.c
@@ -138,7 +138,7 @@ SmcOpenConnection(char *networkIdsList, SmPointer context,
return (NULL);
}
- if ((smcConn = (SmcConn) malloc (sizeof (struct _SmcConn))) == NULL)
+ if ((smcConn = malloc (sizeof (struct _SmcConn))) == NULL)
{
if (errorStringRet && errorLength > 0) {
strncpy (errorStringRet, "Can't malloc", errorLength);
@@ -158,7 +158,7 @@ SmcOpenConnection(char *networkIdsList, SmPointer context,
setupstat == IceProtocolSetupIOError)
{
IceCloseConnection (iceConn);
- free ((char *) smcConn);
+ free (smcConn);
return (NULL);
}
else if (setupstat == IceProtocolAlreadyActive)
@@ -169,7 +169,7 @@ SmcOpenConnection(char *networkIdsList, SmPointer context,
* may not already have XSMP active on it.
*/
- free ((char *) smcConn);
+ free (smcConn);
if (errorStringRet && errorLength > 0) {
strncpy (errorStringRet, "Internal error in IceOpenConnection",
errorLength);
@@ -235,7 +235,7 @@ SmcOpenConnection(char *networkIdsList, SmPointer context,
}
free (smcConn->vendor);
free (smcConn->release);
- free ((char *) smcConn);
+ free (smcConn);
return (NULL);
}
@@ -330,13 +330,13 @@ SmcCloseConnection(SmcConn smcConn, int count, char **reasonMsgs)
while (ptr)
{
next = ptr->next;
- free ((char *) ptr);
+ free (ptr);
ptr = next;
}
}
- free ((char *) smcConn);
+ free (smcConn);
if (closeStatus == IceClosedNow)
statusRet = SmcClosedNow;
@@ -419,8 +419,7 @@ SmcGetProperties(SmcConn smcConn, SmcPropReplyProc propReplyProc,
IceConn iceConn = smcConn->iceConn;
_SmcPropReplyWait *wait, *ptr;
- if ((wait = (_SmcPropReplyWait *) malloc (
- sizeof (_SmcPropReplyWait))) == NULL)
+ if ((wait = malloc (sizeof (_SmcPropReplyWait))) == NULL)
{
return (0);
}
@@ -454,8 +453,7 @@ SmcInteractRequest(SmcConn smcConn, int dialogType,
smInteractRequestMsg *pMsg;
_SmcInteractWait *wait, *ptr;
- if ((wait = (_SmcInteractWait *) malloc (
- sizeof (_SmcInteractWait))) == NULL)
+ if ((wait = malloc (sizeof (_SmcInteractWait))) == NULL)
{
return (0);
}
@@ -534,8 +532,7 @@ SmcRequestSaveYourselfPhase2(SmcConn smcConn,
wait = smcConn->phase2_wait;
else
{
- if ((wait = (_SmcPhase2Wait *) malloc (
- sizeof (_SmcPhase2Wait))) == NULL)
+ if ((wait = malloc (sizeof (_SmcPhase2Wait))) == NULL)
{
return (0);
}
diff --git a/src/sm_manager.c b/src/sm_manager.c
index 9e0d187..d28c0c5 100644
--- a/src/sm_manager.c
+++ b/src/sm_manager.c
@@ -68,7 +68,7 @@ _SmsProtocolSetupProc (IceConn iceConn,
* Allocate new SmsConn.
*/
- if ((smsConn = (SmsConn) malloc (sizeof (struct _SmsConn))) == NULL)
+ if ((smsConn = malloc (sizeof (struct _SmsConn))) == NULL)
{
const char *str = "Memory allocation failed";
@@ -335,5 +335,5 @@ SmsCleanUp(SmsConn smsConn)
if (smsConn->client_id)
free (smsConn->client_id);
- free ((char *) smsConn);
+ free (smsConn);
}
diff --git a/src/sm_misc.c b/src/sm_misc.c
index c081611..83d1259 100644
--- a/src/sm_misc.c
+++ b/src/sm_misc.c
@@ -54,11 +54,11 @@ SmFreeProperty(SmProp *prop)
{
for (i = 0; i < prop->num_vals; i++)
if (prop->vals[i].value)
- free ((char *) prop->vals[i].value);
- free ((char *) prop->vals);
+ free (prop->vals[i].value);
+ free (prop->vals);
}
- free ((char *) prop);
+ free (prop);
}
}
@@ -77,7 +77,7 @@ SmFreeReasons(int count, char **reasonMsgs)
for (i = 0; i < count; i++)
free (reasonMsgs[i]);
- free ((char *) reasonMsgs);
+ free (reasonMsgs);
}
}
diff --git a/src/sm_process.c b/src/sm_process.c
index b8f1b2c..651ddef 100644
--- a/src/sm_process.c
+++ b/src/sm_process.c
@@ -267,7 +267,7 @@ _SmcProcessMessage(IceConn iceConn, IcePointer clientData, int opcode,
(*smcConn->phase2_wait->phase2_proc) (smcConn,
smcConn->phase2_wait->client_data);
- free ((char *) smcConn->phase2_wait);
+ free (smcConn->phase2_wait);
smcConn->phase2_wait = NULL;
}
break;
@@ -290,7 +290,7 @@ _SmcProcessMessage(IceConn iceConn, IcePointer clientData, int opcode,
(*smcConn->interact_waits->interact_proc) (smcConn,
smcConn->interact_waits->client_data);
- free ((char *) smcConn->interact_waits);
+ free (smcConn->interact_waits);
smcConn->interact_waits = next;
}
break;
@@ -393,7 +393,7 @@ _SmcProcessMessage(IceConn iceConn, IcePointer clientData, int opcode,
(*smcConn->prop_reply_waits->prop_reply_proc) (smcConn,
smcConn->prop_reply_waits->client_data, numProps, props);
- free ((char *) smcConn->prop_reply_waits);
+ free (smcConn->prop_reply_waits);
smcConn->prop_reply_waits = next;
IceDisposeCompleteMessage (iceConn, pStart);
@@ -752,7 +752,7 @@ _SmsProcessMessage(IceConn iceConn, IcePointer clientData, int opcode,
pData = pStart + 8;
- reasonMsgs = (char **) malloc (count * sizeof (char *));
+ reasonMsgs = malloc (count * sizeof (char *));
for (i = 0; i < count; i++)
EXTRACT_ARRAY8_AS_STRING (pData, swap, reasonMsgs[i]);
@@ -839,7 +839,7 @@ _SmsProcessMessage(IceConn iceConn, IcePointer clientData, int opcode,
pData = pStart + 8;
- propNames = (char **) malloc (count * sizeof (char *));
+ propNames = malloc (count * sizeof (char *));
for (i = 0; i < count; i++)
EXTRACT_ARRAY8_AS_STRING (pData, swap, propNames[i]);