summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-06-10 15:44:45 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-06-10 15:44:45 -0700
commitace42fef753c1444cfc208da6bb282abbbc279ab (patch)
treec1770abaaf8997a097a3d8ce88ef980706fe640b
parentf12be5ac59a48249c77b8e61e78bceb9ad782542 (diff)
downloadxorg-lib-libXext-ace42fef753c1444cfc208da6bb282abbbc279ab.tar.gz
Remove unnecessary casts of malloc/calloc results
These aren't needed in C89 and later, but can hide missing prototypes that generate broken code on platforms where pointers are larger than ints. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/XEVI.c4
-rw-r--r--src/XMultibuf.c4
-rw-r--r--src/XSecurity.c2
-rw-r--r--src/XShm.c2
-rw-r--r--src/Xcup.c2
-rw-r--r--src/Xdbe.c3
-rw-r--r--src/Xge.c6
-rw-r--r--src/extutil.c5
8 files changed, 13 insertions, 15 deletions
diff --git a/src/XEVI.c b/src/XEVI.c
index c9b172c..2d88b35 100644
--- a/src/XEVI.c
+++ b/src/XEVI.c
@@ -126,7 +126,7 @@ Status XeviGetVisualInfo(
return BadValue;
}
if (!n_visual || !visual) { /* copy the all visual */
- temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * sz_info);
+ temp_visual = Xmalloc(sz_VisualID32 * sz_info);
n_visual = 0;
for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++)
if (notInList(temp_visual, n_visual, vinfo[vinfoIndex].visualid))
@@ -146,7 +146,7 @@ Status XeviGetVisualInfo(
return BadValue;
}
}
- temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * n_visual);
+ temp_visual = Xmalloc(sz_VisualID32 * n_visual);
for (visualIndex = 0; visualIndex < n_visual; visualIndex++)
temp_visual[visualIndex] = visual[visualIndex];
}
diff --git a/src/XMultibuf.c b/src/XMultibuf.c
index 79034da..b2cab33 100644
--- a/src/XMultibuf.c
+++ b/src/XMultibuf.c
@@ -177,7 +177,7 @@ static Status event_to_wire (Display *dpy, XEvent *libevent, xEvent *netevent)
* read_buffer_info - read Buffer Info descriptors from the net; if unable
* to allocate memory, read junk to make sure that stream is clear.
*/
-#define TALLOC(type,count) ((type *) Xmalloc ((unsigned) count * sizeof(type)))
+#define TALLOC(type,count) Xmalloc ((unsigned) count * sizeof(type))
static XmbufBufferInfo *read_buffer_info (Display *dpy, int nbufs)
{
@@ -405,7 +405,7 @@ Status XmbufGetWindowAttributes (
attr->buffers = (Multibuffer *) NULL;
if ((attr->nbuffers = rep.length)) {
int nbytes = rep.length * sizeof(Multibuffer);
- attr->buffers = (Multibuffer *) Xmalloc((unsigned) nbytes);
+ attr->buffers = Xmalloc((unsigned) nbytes);
nbytes = rep.length << 2;
if (! attr->buffers) {
_XEatDataWords(dpy, rep.length);
diff --git a/src/XSecurity.c b/src/XSecurity.c
index 56b37fc..2554502 100644
--- a/src/XSecurity.c
+++ b/src/XSecurity.c
@@ -283,7 +283,7 @@ XSecurityGenerateAuthorization(
* XSecurityAllocXauth; in both cases, you just free one pointer.
*/
- if ((auth_return = (Xauth *)Xcalloc(1,
+ if ((auth_return = Xcalloc(1,
(sizeof(Xauth) + auth_in->name_length + rep.dataLength))))
{
auth_return->data_length = rep.dataLength;
diff --git a/src/XShm.c b/src/XShm.c
index f82455c..d9426c2 100644
--- a/src/XShm.c
+++ b/src/XShm.c
@@ -280,7 +280,7 @@ XImage *XShmCreateImage (
{
register XImage *image;
- image = (XImage *)Xcalloc(1, (unsigned)sizeof(XImage));
+ image = Xcalloc(1, sizeof(XImage));
if (!image)
return image;
image->data = data;
diff --git a/src/Xcup.c b/src/Xcup.c
index fd6850e..c520522 100644
--- a/src/Xcup.c
+++ b/src/Xcup.c
@@ -156,7 +156,7 @@ XcupGetReservedColormapEntries(
}
_XRead (dpy, (char*) rbufp, nbytes);
- *colors_out = (XColor*) Xmalloc (nentries * sizeof (XColor));
+ *colors_out = Xmalloc (nentries * sizeof (XColor));
if (*colors_out) {
xColorItem* cs = (xColorItem *) rbufp;
XColor* cd = *colors_out;
diff --git a/src/Xdbe.c b/src/Xdbe.c
index 13ec347..71d41af 100644
--- a/src/Xdbe.c
+++ b/src/Xdbe.c
@@ -443,8 +443,7 @@ XdbeBackBufferAttributes *XdbeGetBackBufferAttributes(
DbeCheckExtension(dpy, info, (XdbeBackBufferAttributes *)NULL);
- if (!(attr =
- (XdbeBackBufferAttributes *)Xmalloc(sizeof(XdbeBackBufferAttributes)))) {
+ if (!(attr = Xmalloc(sizeof(XdbeBackBufferAttributes)))) {
return NULL;
}
diff --git a/src/Xge.c b/src/Xge.c
index 2b97743..7beb391 100644
--- a/src/Xge.c
+++ b/src/Xge.c
@@ -143,7 +143,7 @@ _xgeCheckExtInit(Display* dpy, XExtDisplayInfo* info)
if (!info->data)
{
- XGEData* data = (XGEData*)Xmalloc(sizeof(XGEData));
+ XGEData* data = Xmalloc(sizeof(XGEData));
if (!data) {
goto cleanup;
}
@@ -192,7 +192,7 @@ _xgeGetExtensionVersion(Display* dpy,
return NULL;
}
- vers = (XGEVersionRec*)Xmalloc(sizeof(XGEVersionRec));
+ vers = Xmalloc(sizeof(XGEVersionRec));
vers->major_version = rep.majorVersion;
vers->minor_version = rep.minorVersion;
return vers;
@@ -315,7 +315,7 @@ _X_HIDDEN xgeExtRegister(Display* dpy, int offset, XExtensionHooks* callbacks)
xge_data = (XGEData*)info->data;
- newExt = (XGEExtNode*)Xmalloc(sizeof(XGEExtNode));
+ newExt = Xmalloc(sizeof(XGEExtNode));
if (!newExt)
{
fprintf(stderr, "xgeExtRegister: Failed to alloc memory.\n");
diff --git a/src/extutil.c b/src/extutil.c
index e9d293f..26f90b2 100644
--- a/src/extutil.c
+++ b/src/extutil.c
@@ -63,8 +63,7 @@ in this Software without prior written authorization from The Open Group.
*/
XExtensionInfo *XextCreateExtension (void)
{
- register XExtensionInfo *info =
- (XExtensionInfo *) Xmalloc (sizeof (XExtensionInfo));
+ register XExtensionInfo *info = Xmalloc (sizeof (XExtensionInfo));
if (info) {
info->head = NULL;
@@ -101,7 +100,7 @@ XExtDisplayInfo *XextAddDisplay (
{
XExtDisplayInfo *dpyinfo;
- dpyinfo = (XExtDisplayInfo *) Xmalloc (sizeof (XExtDisplayInfo));
+ dpyinfo = Xmalloc (sizeof (XExtDisplayInfo));
if (!dpyinfo) return NULL;
dpyinfo->display = dpy;
dpyinfo->data = data;