Move sizeof to second argument in calloc calls

Clears -Wcalloc-transposed-args warnings from gcc 14.1, such as:

../dix/main.c:165:42: warning: ‘calloc’ sizes specified with ‘sizeof’ in the
 earlier argument and not in the later argument [-Wcalloc-transposed-args]
  165 |             serverClient = calloc(sizeof(ClientRec), 1);
      |                                          ^~~~~~~~~
../dix/main.c:165:42: note: earlier argument should specify number of
 elements, later size of each element

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1606>
This commit is contained in:
Alan Coopersmith 2024-07-14 11:24:00 -07:00
parent 6a1d730006
commit 522f469fe9
37 changed files with 65 additions and 65 deletions

View File

@ -350,7 +350,7 @@ ProcXListInputDevices(ClientPtr client)
}; };
/* allocate space for saving skip value */ /* allocate space for saving skip value */
skip = calloc(sizeof(Bool), inputInfo.numDevices); skip = calloc(inputInfo.numDevices, sizeof(Bool));
if (!skip) if (!skip)
return BadAlloc; return BadAlloc;

View File

@ -88,7 +88,7 @@ ProcXIQueryDevice(ClientPtr client)
len += SizeDeviceInfo(dev); len += SizeDeviceInfo(dev);
} }
else { else {
skip = calloc(sizeof(Bool), inputInfo.numDevices); skip = calloc(inputInfo.numDevices, sizeof(Bool));
if (!skip) if (!skip)
return BadAlloc; return BadAlloc;

View File

@ -102,7 +102,7 @@ get_prop_string_array(LibHalContext * hal_ctx, const char *udi,
for (i = 0; props[i]; i++) for (i = 0; props[i]; i++)
len += strlen(props[i]); len += strlen(props[i]);
ret = calloc(sizeof(char), len + i); /* i - 1 commas, 1 NULL */ ret = calloc(len + i, sizeof(char)); /* i - 1 commas, 1 NULL */
if (!ret) { if (!ret) {
libhal_free_string_array(props); libhal_free_string_array(props);
return NULL; return NULL;

View File

@ -89,7 +89,7 @@ AddExtension(const char *name, int NumEvents, int NumErrors,
return ((ExtensionEntry *) NULL); return ((ExtensionEntry *) NULL);
} }
ext = calloc(sizeof(ExtensionEntry), 1); ext = calloc(1, sizeof(ExtensionEntry));
if (!ext) if (!ext)
return NULL; return NULL;
if (!dixAllocatePrivates(&ext->devPrivates, PRIVATE_EXTENSION)) { if (!dixAllocatePrivates(&ext->devPrivates, PRIVATE_EXTENSION)) {

View File

@ -162,7 +162,7 @@ dix_main(int argc, char *argv[], char *envp[])
CreateWellKnownSockets(); CreateWellKnownSockets();
for (i = 1; i < LimitClients; i++) for (i = 1; i < LimitClients; i++)
clients[i] = NullClient; clients[i] = NullClient;
serverClient = calloc(sizeof(ClientRec), 1); serverClient = calloc(1, sizeof(ClientRec));
if (!serverClient) if (!serverClient)
FatalError("couldn't create server client"); FatalError("couldn't create server client");
InitClient(serverClient, 0, (void *) NULL); InitClient(serverClient, 0, (void *) NULL);

View File

@ -413,7 +413,7 @@ dixRegisterScreenPrivateKey(DevScreenPrivateKey screenKey, ScreenPtr pScreen,
assert(key->type == type); assert(key->type == type);
return TRUE; return TRUE;
} }
key = calloc(sizeof(DevPrivateKeyRec), 1); key = calloc(1, sizeof(DevPrivateKeyRec));
if (!key) if (!key)
return FALSE; return FALSE;
if (!dixRegisterPrivateKey(key, type, size)) { if (!dixRegisterPrivateKey(key, type, size)) {

View File

@ -883,7 +883,7 @@ exaDriverInit(ScreenPtr pScreen, ExaDriverPtr pScreenInfo)
return FALSE; return FALSE;
} }
pExaScr = calloc(sizeof(ExaScreenPrivRec), 1); pExaScr = calloc(1, sizeof(ExaScreenPrivRec));
if (!pExaScr) { if (!pExaScr) {
LogMessage(X_WARNING, "EXA(%d): Failed to allocate screen private\n", LogMessage(X_WARNING, "EXA(%d): Failed to allocate screen private\n",
pScreen->myNum); pScreen->myNum);

View File

@ -1089,7 +1089,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
Bool force_es = FALSE; Bool force_es = FALSE;
const char *glvnd_vendor = NULL; const char *glvnd_vendor = NULL;
glamor_egl = calloc(sizeof(*glamor_egl), 1); glamor_egl = calloc(1, sizeof(*glamor_egl));
if (glamor_egl == NULL) if (glamor_egl == NULL)
return FALSE; return FALSE;
if (xf86GlamorEGLPrivateIndex == -1) if (xf86GlamorEGLPrivateIndex == -1)

View File

@ -1265,7 +1265,7 @@ static Status
MouseInit(KdPointerInfo * pi) MouseInit(KdPointerInfo * pi)
{ {
pi->driverPrivate = (EphyrPointerPrivate *) pi->driverPrivate = (EphyrPointerPrivate *)
calloc(sizeof(EphyrPointerPrivate), 1); calloc(1, sizeof(EphyrPointerPrivate));
((EphyrPointerPrivate *) pi->driverPrivate)->enabled = FALSE; ((EphyrPointerPrivate *) pi->driverPrivate)->enabled = FALSE;
pi->nAxes = 3; pi->nAxes = 3;
pi->nButtons = 32; pi->nButtons = 32;
@ -1326,7 +1326,7 @@ EphyrKeyboardInit(KdKeyboardInfo * ki)
XkbControlsRec controls; XkbControlsRec controls;
ki->driverPrivate = (EphyrKbdPrivate *) ki->driverPrivate = (EphyrKbdPrivate *)
calloc(sizeof(EphyrKbdPrivate), 1); calloc(1, sizeof(EphyrKbdPrivate));
if (hostx_load_keymap(&keySyms, modmap, &controls)) { if (hostx_load_keymap(&keySyms, modmap, &controls)) {
XkbApplyMappingChange(ki->dixdev, &keySyms, XkbApplyMappingChange(ki->dixdev, &keySyms,

View File

@ -677,7 +677,7 @@ KdRemoveKeyboardDriver(KdKeyboardDriver * driver)
KdKeyboardInfo * KdKeyboardInfo *
KdNewKeyboard(void) KdNewKeyboard(void)
{ {
KdKeyboardInfo *ki = calloc(sizeof(KdKeyboardInfo), 1); KdKeyboardInfo *ki = calloc(1, sizeof(KdKeyboardInfo));
if (!ki) if (!ki)
return NULL; return NULL;
@ -708,7 +708,7 @@ KdAddConfigKeyboard(char *keyboard)
if (!keyboard) if (!keyboard)
return Success; return Success;
new = (struct KdConfigDevice *) calloc(sizeof(struct KdConfigDevice), 1); new = (struct KdConfigDevice *) calloc(1, sizeof(struct KdConfigDevice));
if (!new) if (!new)
return BadAlloc; return BadAlloc;
@ -772,7 +772,7 @@ KdAddConfigPointer(char *pointer)
if (!pointer) if (!pointer)
return Success; return Success;
new = (struct KdConfigDevice *) calloc(sizeof(struct KdConfigDevice), 1); new = (struct KdConfigDevice *) calloc(1, sizeof(struct KdConfigDevice));
if (!new) if (!new)
return BadAlloc; return BadAlloc;

View File

@ -544,7 +544,7 @@ addInputHandler(int fd, InputHandlerProc proc, void *data)
if (fd < 0 || !proc) if (fd < 0 || !proc)
return NULL; return NULL;
ih = calloc(sizeof(*ih), 1); ih = calloc(1, sizeof(*ih));
if (!ih) if (!ih)
return NULL; return NULL;

View File

@ -172,7 +172,7 @@ xf86AllocateScreen(DriverPtr drv, int flags)
i = xf86NumGPUScreens++; i = xf86NumGPUScreens++;
xf86GPUScreens = xnfreallocarray(xf86GPUScreens, xf86NumGPUScreens, xf86GPUScreens = xnfreallocarray(xf86GPUScreens, xf86NumGPUScreens,
sizeof(ScrnInfoPtr)); sizeof(ScrnInfoPtr));
xf86GPUScreens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1); xf86GPUScreens[i] = xnfcalloc(1, sizeof(ScrnInfoRec));
pScrn = xf86GPUScreens[i]; pScrn = xf86GPUScreens[i];
pScrn->scrnIndex = i + GPU_SCREEN_OFFSET; /* Changes when a screen is removed */ pScrn->scrnIndex = i + GPU_SCREEN_OFFSET; /* Changes when a screen is removed */
pScrn->is_gpu = TRUE; pScrn->is_gpu = TRUE;
@ -183,14 +183,14 @@ xf86AllocateScreen(DriverPtr drv, int flags)
i = xf86NumScreens++; i = xf86NumScreens++;
xf86Screens = xnfreallocarray(xf86Screens, xf86NumScreens, xf86Screens = xnfreallocarray(xf86Screens, xf86NumScreens,
sizeof(ScrnInfoPtr)); sizeof(ScrnInfoPtr));
xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1); xf86Screens[i] = xnfcalloc(1, sizeof(ScrnInfoRec));
pScrn = xf86Screens[i]; pScrn = xf86Screens[i];
pScrn->scrnIndex = i; /* Changes when a screen is removed */ pScrn->scrnIndex = i; /* Changes when a screen is removed */
} }
pScrn->origIndex = pScrn->scrnIndex; /* This never changes */ pScrn->origIndex = pScrn->scrnIndex; /* This never changes */
pScrn->privates = xnfcalloc(sizeof(DevUnion), xf86ScrnInfoPrivateCount); pScrn->privates = xnfcalloc(xf86ScrnInfoPrivateCount, sizeof(DevUnion));
/* /*
* EnableDisableFBAccess now gets initialized in InitOutput() * EnableDisableFBAccess now gets initialized in InitOutput()
* pScrn->EnableDisableFBAccess = xf86EnableDisableFBAccess; * pScrn->EnableDisableFBAccess = xf86EnableDisableFBAccess;

View File

@ -769,7 +769,7 @@ xf86AllocateInput(void)
{ {
InputInfoPtr pInfo; InputInfoPtr pInfo;
pInfo = calloc(sizeof(*pInfo), 1); pInfo = calloc(1, sizeof(*pInfo));
if (!pInfo) if (!pInfo)
return NULL; return NULL;

View File

@ -70,7 +70,7 @@ CheckSbusDevice(const char *device, int fbNum)
xf86SbusInfo = xf86SbusInfo =
xnfreallocarray(xf86SbusInfo, ++xf86nSbusInfo + 1, sizeof(psdp)); xnfreallocarray(xf86SbusInfo, ++xf86nSbusInfo + 1, sizeof(psdp));
xf86SbusInfo[xf86nSbusInfo] = NULL; xf86SbusInfo[xf86nSbusInfo] = NULL;
xf86SbusInfo[xf86nSbusInfo - 1] = psdp = xnfcalloc(sizeof(sbusDevice), 1); xf86SbusInfo[xf86nSbusInfo - 1] = psdp = xnfcalloc(1, sizeof(sbusDevice));
psdp->devId = sbusDeviceTable[i].devId; psdp->devId = sbusDeviceTable[i].devId;
psdp->fbNum = fbNum; psdp->fbNum = fbNum;
psdp->device = xnfstrdup(device); psdp->device = xnfstrdup(device);

View File

@ -171,7 +171,7 @@ xf86InterpretEDID(int scrnIndex, Uchar * block)
if (!block) if (!block)
return NULL; return NULL;
if (!(m = xnfcalloc(sizeof(xf86Monitor), 1))) if (!(m = xnfcalloc(1, sizeof(xf86Monitor))))
return NULL; return NULL;
m->scrnIndex = scrnIndex; m->scrnIndex = scrnIndex;
m->rawData = block; m->rawData = block;

View File

@ -7837,7 +7837,7 @@ ZZZGetRec(ScrnInfoPtr pScrn)
{ {
if (pScrn-&gt;driverPrivate != NULL) if (pScrn-&gt;driverPrivate != NULL)
return TRUE; return TRUE;
pScrn-&gt;driverPrivate = xnfcalloc(sizeof(ZZZRec), 1); pScrn-&gt;driverPrivate = xnfcalloc(1, sizeof(ZZZRec));
/* Initialise as required */ /* Initialise as required */
... ...
return TRUE; return TRUE;

View File

@ -258,7 +258,7 @@ DRIOpenDRMMaster(ScrnInfoPtr pScrn,
tmp.resOwner = NULL; tmp.resOwner = NULL;
if (!pDRIEntPriv) if (!pDRIEntPriv)
pDRIEntPriv = xnfcalloc(sizeof(*pDRIEntPriv), 1); pDRIEntPriv = xnfcalloc(1, sizeof(*pDRIEntPriv));
if (!pDRIEntPriv) { if (!pDRIEntPriv) {
DRIDrvMsg(-1, X_INFO, "[drm] Failed to allocate memory for " DRIDrvMsg(-1, X_INFO, "[drm] Failed to allocate memory for "
@ -1209,7 +1209,7 @@ DRIDriverClipNotify(ScreenPtr pScreen)
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
if (pDRIPriv->pDriverInfo->ClipNotify) { if (pDRIPriv->pDriverInfo->ClipNotify) {
WindowPtr *pDRIWindows = calloc(sizeof(WindowPtr), pDRIPriv->nrWindows); WindowPtr *pDRIWindows = calloc(pDRIPriv->nrWindows, sizeof(WindowPtr));
DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
if (pDRIPriv->nrWindows > 0) { if (pDRIPriv->nrWindows > 0) {

View File

@ -940,7 +940,7 @@ get_type_name(InputInfoPtr pInfo, xf86ITDevicePtr driver_data)
static xf86ITDevicePtr static xf86ITDevicePtr
device_alloc(void) device_alloc(void)
{ {
xf86ITDevicePtr driver_data = calloc(sizeof(xf86ITDevice), 1); xf86ITDevicePtr driver_data = calloc(1, sizeof(xf86ITDevice));
if (!driver_data) if (!driver_data)
return NULL; return NULL;

View File

@ -396,7 +396,7 @@ ms_setup_entity(ScrnInfoPtr scrn, int entity_num)
xf86SetEntityInstanceForScreen(scrn, entity_num, xf86GetNumEntityInstances(entity_num) - 1); xf86SetEntityInstanceForScreen(scrn, entity_num, xf86GetNumEntityInstances(entity_num) - 1);
if (!pPriv->ptr) if (!pPriv->ptr)
pPriv->ptr = xnfcalloc(sizeof(modesettingEntRec), 1); pPriv->ptr = xnfcalloc(1, sizeof(modesettingEntRec));
} }
#ifdef XSERVER_LIBPCIACCESS #ifdef XSERVER_LIBPCIACCESS
@ -515,7 +515,7 @@ GetRec(ScrnInfoPtr pScrn)
if (pScrn->driverPrivate) if (pScrn->driverPrivate)
return TRUE; return TRUE;
pScrn->driverPrivate = xnfcalloc(sizeof(modesettingRec), 1); pScrn->driverPrivate = xnfcalloc(1, sizeof(modesettingRec));
return TRUE; return TRUE;
} }

View File

@ -536,7 +536,7 @@ drm_mode_ensure_blob(xf86CrtcPtr crtc, const drmModeModeInfo* mode_info)
drmmode_CompareKModes(&drmmode_crtc->current_mode->mode_info, mode_info) == 0) drmmode_CompareKModes(&drmmode_crtc->current_mode->mode_info, mode_info) == 0)
return 0; return 0;
mode = calloc(sizeof(drmmode_mode_rec), 1); mode = calloc(1, sizeof(drmmode_mode_rec));
if (!mode) if (!mode)
return -1; return -1;
@ -904,7 +904,7 @@ drmmode_crtc_set_mode(xf86CrtcPtr crtc, Bool test_only)
return ret; return ret;
} }
output_ids = calloc(sizeof(uint32_t), xf86_config->num_output); output_ids = calloc(xf86_config->num_output, sizeof(uint32_t));
if (!output_ids) if (!output_ids)
return -1; return -1;
@ -2495,8 +2495,8 @@ drmmode_crtc_create_planes(xf86CrtcPtr crtc, int num)
drmmode_crtc->plane_id = best_plane; drmmode_crtc->plane_id = best_plane;
if (best_kplane) { if (best_kplane) {
drmmode_crtc->num_formats = best_kplane->count_formats; drmmode_crtc->num_formats = best_kplane->count_formats;
drmmode_crtc->formats = calloc(sizeof(drmmode_format_rec), drmmode_crtc->formats = calloc(best_kplane->count_formats,
best_kplane->count_formats); sizeof(drmmode_format_rec));
if (!populate_format_modifiers(crtc, best_kplane, blob_id)) { if (!populate_format_modifiers(crtc, best_kplane, blob_id)) {
for (i = 0; i < best_kplane->count_formats; i++) for (i = 0; i < best_kplane->count_formats; i++)
drmmode_crtc->formats[i].format = best_kplane->formats[i]; drmmode_crtc->formats[i].format = best_kplane->formats[i];
@ -2573,7 +2573,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res
crtc = xf86CrtcCreate(pScrn, &drmmode_crtc_funcs); crtc = xf86CrtcCreate(pScrn, &drmmode_crtc_funcs);
if (crtc == NULL) if (crtc == NULL)
return 0; return 0;
drmmode_crtc = xnfcalloc(sizeof(drmmode_crtc_private_rec), 1); drmmode_crtc = xnfcalloc(1, sizeof(drmmode_crtc_private_rec));
crtc->driver_private = drmmode_crtc; crtc->driver_private = drmmode_crtc;
drmmode_crtc->mode_crtc = drmmode_crtc->mode_crtc =
drmModeGetCrtc(drmmode->fd, mode_res->crtcs[num]); drmModeGetCrtc(drmmode->fd, mode_res->crtcs[num]);
@ -3442,7 +3442,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
} }
} }
kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders); kencoders = calloc(koutput->count_encoders, sizeof(drmModeEncoderPtr));
if (!kencoders) { if (!kencoders) {
goto out_free_encoders; goto out_free_encoders;
} }
@ -3471,7 +3471,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
goto out_free_encoders; goto out_free_encoders;
} }
drmmode_output = calloc(sizeof(drmmode_output_private_rec), 1); drmmode_output = calloc(1, sizeof(drmmode_output_private_rec));
if (!drmmode_output) { if (!drmmode_output) {
xf86OutputDestroy(output); xf86OutputDestroy(output);
goto out_free_encoders; goto out_free_encoders;

View File

@ -127,7 +127,7 @@ ms_present_queue_vblank(RRCrtcPtr crtc,
struct ms_present_vblank_event *event; struct ms_present_vblank_event *event;
uint32_t seq; uint32_t seq;
event = calloc(sizeof(struct ms_present_vblank_event), 1); event = calloc(1, sizeof(struct ms_present_vblank_event));
if (!event) if (!event)
return BadAlloc; return BadAlloc;
event->event_id = event_id; event->event_id = event_id;

View File

@ -94,7 +94,7 @@ fbdevHWGetRec(ScrnInfoPtr pScrn)
if (FBDEVHWPTR(pScrn) != NULL) if (FBDEVHWPTR(pScrn) != NULL)
return TRUE; return TRUE;
FBDEVHWPTRLVAL(pScrn) = xnfcalloc(sizeof(fbdevHWRec), 1); FBDEVHWPTRLVAL(pScrn) = xnfcalloc(1, sizeof(fbdevHWRec));
return TRUE; return TRUE;
} }

View File

@ -374,7 +374,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe)
if (R16(pVbe->pInt10->ax) != 0x4f) if (R16(pVbe->pInt10->ax) != 0x4f)
return NULL; return NULL;
block = calloc(sizeof(VbeInfoBlock), 1); block = calloc(1, sizeof(VbeInfoBlock));
block->VESASignature[0] = ((char *) pVbe->memory)[0]; block->VESASignature[0] = ((char *) pVbe->memory)[0];
block->VESASignature[1] = ((char *) pVbe->memory)[1]; block->VESASignature[1] = ((char *) pVbe->memory)[1];
block->VESASignature[2] = ((char *) pVbe->memory)[2]; block->VESASignature[2] = ((char *) pVbe->memory)[2];
@ -886,7 +886,7 @@ VBEBuildVbeModeList(vbeInfoPtr pVbe, VbeInfoBlock * vbe)
bpp = mode->BitsPerPixel; bpp = mode->BitsPerPixel;
m = xnfcalloc(sizeof(vbeModeInfoRec), 1); m = xnfcalloc(1, sizeof(vbeModeInfoRec));
m->width = mode->XResolution; m->width = mode->XResolution;
m->height = mode->YResolution; m->height = mode->YResolution;
m->bpp = bpp; m->bpp = bpp;

View File

@ -240,7 +240,7 @@ CheckMode(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock * vbe, int id,
VBEFreeModeInfo(mode); VBEFreeModeInfo(mode);
return NULL; return NULL;
} }
pMode = xnfcalloc(sizeof(DisplayModeRec), 1); pMode = xnfcalloc(1, sizeof(DisplayModeRec));
pMode->status = MODE_OK; pMode->status = MODE_OK;
pMode->type = M_T_BUILTIN; pMode->type = M_T_BUILTIN;
@ -249,7 +249,7 @@ CheckMode(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock * vbe, int id,
pMode->HDisplay = mode->XResolution; pMode->HDisplay = mode->XResolution;
pMode->VDisplay = mode->YResolution; pMode->VDisplay = mode->YResolution;
data = xnfcalloc(sizeof(VbeModeInfoData), 1); data = xnfcalloc(1, sizeof(VbeModeInfoData));
data->mode = id; data->mode = id;
data->data = mode; data->data = mode;
pMode->PrivSize = sizeof(VbeModeInfoData); pMode->PrivSize = sizeof(VbeModeInfoData);
@ -404,7 +404,7 @@ VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"Attempting to use %dHz refresh for mode \"%s\" (%x)\n", "Attempting to use %dHz refresh for mode \"%s\" (%x)\n",
(int) pMode->VRefresh, pMode->name, data->mode); (int) pMode->VRefresh, pMode->name, data->mode);
data->block = calloc(sizeof(VbeCRTCInfoBlock), 1); data->block = calloc(1, sizeof(VbeCRTCInfoBlock));
data->block->HorizontalTotal = best->HTotal; data->block->HorizontalTotal = best->HTotal;
data->block->HorizontalSyncStart = best->HSyncStart; data->block->HorizontalSyncStart = best->HSyncStart;
data->block->HorizontalSyncEnd = best->HSyncEnd; data->block->HorizontalSyncEnd = best->HSyncEnd;

View File

@ -88,7 +88,7 @@ xf86CrtcCreate(ScrnInfoPtr scrn, const xf86CrtcFuncsRec * funcs)
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
xf86CrtcPtr crtc, *crtcs; xf86CrtcPtr crtc, *crtcs;
crtc = calloc(sizeof(xf86CrtcRec), 1); crtc = calloc(1, sizeof(xf86CrtcRec));
if (!crtc) if (!crtc)
return NULL; return NULL;
crtc->version = XF86_CRTC_VERSION; crtc->version = XF86_CRTC_VERSION;
@ -640,7 +640,7 @@ xf86OutputCreate(ScrnInfoPtr scrn,
else else
len = 0; len = 0;
output = calloc(sizeof(xf86OutputRec) + len, 1); output = calloc(1, sizeof(xf86OutputRec) + len);
if (!output) if (!output)
return NULL; return NULL;
output->scrn = scrn; output->scrn = scrn;

View File

@ -427,7 +427,7 @@ sparcPromAssignNodes(void)
xf86ErrorF("Inconsistent /proc/fb with FBIOGATTR\n"); xf86ErrorF("Inconsistent /proc/fb with FBIOGATTR\n");
} }
else if (!devicePtrs[fbNum]) { else if (!devicePtrs[fbNum]) {
devicePtrs[fbNum] = psdp = xnfcalloc(sizeof(sbusDevice), 1); devicePtrs[fbNum] = psdp = xnfcalloc(1, sizeof(sbusDevice));
psdp->devId = devId; psdp->devId = devId;
psdp->fbNum = fbNum; psdp->fbNum = fbNum;
psdp->fd = -2; psdp->fd = -2;

View File

@ -133,7 +133,7 @@ xf86GetAGPInfo(int screenNum)
if (!GARTInit(screenNum)) if (!GARTInit(screenNum))
return NULL; return NULL;
if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) { if ((info = calloc(1, sizeof(AgpInfo))) == NULL) {
xf86DrvMsg(screenNum, X_ERROR, xf86DrvMsg(screenNum, X_ERROR,
"xf86GetAGPInfo: Failed to allocate AgpInfo\n"); "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
return NULL; return NULL;

View File

@ -126,7 +126,7 @@ xf86GetAGPInfo(int screenNum)
return NULL; return NULL;
} }
if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) { if ((info = calloc(1, sizeof(AgpInfo))) == NULL) {
xf86DrvMsg(screenNum, X_ERROR, xf86DrvMsg(screenNum, X_ERROR,
"xf86GetAGPInfo: Failed to allocate AgpInfo\n"); "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
return NULL; return NULL;

View File

@ -1627,7 +1627,7 @@ vgaHWGetHWRec(ScrnInfoPtr scrp)
*/ */
if (VGAHWPTR(scrp)) if (VGAHWPTR(scrp))
return TRUE; return TRUE;
hwp = VGAHWPTRLVAL(scrp) = xnfcalloc(sizeof(vgaHWRec), 1); hwp = VGAHWPTRLVAL(scrp) = xnfcalloc(1, sizeof(vgaHWRec));
regp = &VGAHWPTR(scrp)->ModeReg; regp = &VGAHWPTR(scrp)->ModeReg;
if ((!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->SavedReg)) || if ((!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->SavedReg)) ||
@ -1921,7 +1921,7 @@ vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed)
if (hwp->ddc != NULL) if (hwp->ddc != NULL)
break; break;
hwp->ddc = xnfcalloc(sizeof(struct _vgaDdcSave), 1); hwp->ddc = xnfcalloc(1, sizeof(struct _vgaDdcSave));
save = (struct _vgaDdcSave *) hwp->ddc; save = (struct _vgaDdcSave *) hwp->ddc;
/* Lightpen register disable - allow access to cr10 & 11; just in case */ /* Lightpen register disable - allow access to cr10 & 11; just in case */
save->cr03 = hwp->readCrtc(hwp, 0x03); save->cr03 = hwp->readCrtc(hwp, 0x03);

View File

@ -117,7 +117,7 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
* __glXScreenDestroy now walks all the fbconfigs and frees them one at a time. * __glXScreenDestroy now walks all the fbconfigs and frees them one at a time.
* See 4b0a3cbab131eb453e2b3fc0337121969258a7be. * See 4b0a3cbab131eb453e2b3fc0337121969258a7be.
*/ */
visualConfigs = calloc(sizeof(*visualConfigs), 1); visualConfigs = calloc(1, sizeof(*visualConfigs));
l = NULL; l = NULL;
c = visualConfigs; /* current buffer */ c = visualConfigs; /* current buffer */
@ -136,7 +136,7 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
// Global // Global
c->visualID = -1; c->visualID = -1;
c->visualType = GLX_TRUE_COLOR; c->visualType = GLX_TRUE_COLOR;
c->next = calloc(sizeof(*visualConfigs), 1); c->next = calloc(1, sizeof(*visualConfigs));
assert(c->next); assert(c->next);
c->level = 0; c->level = 0;

View File

@ -117,7 +117,7 @@ QuartzAddScreen(int index,
// The clang static analyzer thinks we leak displayInfo here // The clang static analyzer thinks we leak displayInfo here
#ifndef __clang_analyzer__ #ifndef __clang_analyzer__
// allocate space for private per screen Quartz specific storage // allocate space for private per screen Quartz specific storage
QuartzScreenPtr displayInfo = calloc(sizeof(QuartzScreenRec), 1); QuartzScreenPtr displayInfo = calloc(1, sizeof(QuartzScreenRec));
// QUARTZ_PRIV(pScreen) = displayInfo; // QUARTZ_PRIV(pScreen) = displayInfo;
dixSetPrivate(&pScreen->devPrivates, quartzScreenKey, displayInfo); dixSetPrivate(&pScreen->devPrivates, quartzScreenKey, displayInfo);

View File

@ -1850,7 +1850,7 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
if (!dixRegisterPrivateKey(&xwl_gbm_private_key, PRIVATE_SCREEN, 0)) if (!dixRegisterPrivateKey(&xwl_gbm_private_key, PRIVATE_SCREEN, 0))
return FALSE; return FALSE;
xwl_gbm = calloc(sizeof(*xwl_gbm), 1); xwl_gbm = calloc(1, sizeof(*xwl_gbm));
if (!xwl_gbm) { if (!xwl_gbm) {
ErrorF("glamor: Not enough memory to setup GBM, disabling\n"); ErrorF("glamor: Not enough memory to setup GBM, disabling\n");
return FALSE; return FALSE;

View File

@ -2872,7 +2872,7 @@ tablet_seat_handle_add_tablet(void *data, struct zwp_tablet_seat_v2 *tablet_seat
struct xwl_seat *xwl_seat = data; struct xwl_seat *xwl_seat = data;
struct xwl_tablet *xwl_tablet; struct xwl_tablet *xwl_tablet;
xwl_tablet = calloc(sizeof *xwl_tablet, 1); xwl_tablet = calloc(1, sizeof *xwl_tablet);
if (xwl_tablet == NULL) { if (xwl_tablet == NULL) {
ErrorF("%s ENOMEM\n", __func__); ErrorF("%s ENOMEM\n", __func__);
return; return;
@ -2903,7 +2903,7 @@ tablet_seat_handle_add_tool(void *data, struct zwp_tablet_seat_v2 *tablet_seat,
struct xwl_screen *xwl_screen = xwl_seat->xwl_screen; struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
struct xwl_tablet_tool *xwl_tablet_tool; struct xwl_tablet_tool *xwl_tablet_tool;
xwl_tablet_tool = calloc(sizeof *xwl_tablet_tool, 1); xwl_tablet_tool = calloc(1, sizeof *xwl_tablet_tool);
if (xwl_tablet_tool == NULL) { if (xwl_tablet_tool == NULL) {
ErrorF("%s ENOMEM\n", __func__); ErrorF("%s ENOMEM\n", __func__);
return; return;
@ -2926,7 +2926,7 @@ tablet_seat_handle_add_pad(void *data, struct zwp_tablet_seat_v2 *tablet_seat,
struct xwl_seat *xwl_seat = data; struct xwl_seat *xwl_seat = data;
struct xwl_tablet_pad *xwl_tablet_pad; struct xwl_tablet_pad *xwl_tablet_pad;
xwl_tablet_pad = calloc(sizeof *xwl_tablet_pad, 1); xwl_tablet_pad = calloc(1, sizeof *xwl_tablet_pad);
if (xwl_tablet_pad == NULL) { if (xwl_tablet_pad == NULL) {
ErrorF("%s ENOMEM\n", __func__); ErrorF("%s ENOMEM\n", __func__);
return; return;

View File

@ -58,7 +58,7 @@ winAllocatePrivates(ScreenPtr pScreen)
} }
/* Allocate memory for the screen private structure */ /* Allocate memory for the screen private structure */
pScreenPriv = calloc(sizeof(winPrivScreenRec), 1); pScreenPriv = calloc(1, sizeof(winPrivScreenRec));
if (!pScreenPriv) { if (!pScreenPriv) {
ErrorF("winAllocateScreenPrivates - malloc () failed\n"); ErrorF("winAllocateScreenPrivates - malloc () failed\n");
return FALSE; return FALSE;
@ -140,7 +140,7 @@ winAllocateCmapPrivates(ColormapPtr pCmap)
} }
/* Allocate memory for our private structure */ /* Allocate memory for our private structure */
pCmapPriv = calloc(sizeof(winPrivCmapRec), 1); pCmapPriv = calloc(1, sizeof(winPrivCmapRec));
if (!pCmapPriv) { if (!pCmapPriv) {
ErrorF("winAllocateCmapPrivates - malloc () failed\n"); ErrorF("winAllocateCmapPrivates - malloc () failed\n");
return FALSE; return FALSE;

View File

@ -1395,9 +1395,9 @@ winInitWM(void **ppWMInfo,
pthread_mutex_t * ppmServerStarted, pthread_mutex_t * ppmServerStarted,
int dwScreen, HWND hwndScreen, Bool compositeWM) int dwScreen, HWND hwndScreen, Bool compositeWM)
{ {
WMProcArgPtr pArg = calloc(sizeof(WMProcArgRec), 1); WMProcArgPtr pArg = calloc(1, sizeof(WMProcArgRec));
WMInfoPtr pWMInfo = calloc(sizeof(WMInfoRec), 1); WMInfoPtr pWMInfo = calloc(1, sizeof(WMInfoRec));
XMsgProcArgPtr pXMsgArg = calloc(sizeof(XMsgProcArgRec), 1); XMsgProcArgPtr pXMsgArg = calloc(1, sizeof(XMsgProcArgRec));
/* Bail if the input parameters are bad */ /* Bail if the input parameters are bad */
if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) { if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) {

View File

@ -1162,8 +1162,8 @@ winCreateColormapShadowGDI(ColormapPtr pColormap)
dwEntriesMax = pVisual->ColormapEntries; dwEntriesMax = pVisual->ColormapEntries;
/* Allocate a Windows logical color palette with max entries */ /* Allocate a Windows logical color palette with max entries */
lpPaletteNew = calloc(sizeof(LOGPALETTE) lpPaletteNew = calloc(1, sizeof(LOGPALETTE)
+ (dwEntriesMax - 1) * sizeof(PALETTEENTRY), 1); + (dwEntriesMax - 1) * sizeof(PALETTEENTRY));
if (lpPaletteNew == NULL) { if (lpPaletteNew == NULL) {
ErrorF("winCreateColormapShadowGDI - Couldn't allocate palette " ErrorF("winCreateColormapShadowGDI - Couldn't allocate palette "
"with %d entries\n", (int) dwEntriesMax); "with %d entries\n", (int) dwEntriesMax);

View File

@ -381,8 +381,8 @@ ProcXFixesGetCursorImage(ClientPtr client)
width = pCursor->bits->width; width = pCursor->bits->width;
height = pCursor->bits->height; height = pCursor->bits->height;
npixels = width * height; npixels = width * height;
rep = calloc(sizeof(xXFixesGetCursorImageReply) + npixels * sizeof(CARD32), rep = calloc(1,
1); sizeof(xXFixesGetCursorImageReply) + npixels * sizeof(CARD32));
if (!rep) if (!rep)
return BadAlloc; return BadAlloc;
@ -533,8 +533,8 @@ ProcXFixesGetCursorImageAndName(ClientPtr client)
name = pCursor->name ? NameForAtom(pCursor->name) : ""; name = pCursor->name ? NameForAtom(pCursor->name) : "";
nbytes = strlen(name); nbytes = strlen(name);
nbytesRound = pad_to_int32(nbytes); nbytesRound = pad_to_int32(nbytes);
rep = calloc(sizeof(xXFixesGetCursorImageAndNameReply) + rep = calloc(1, sizeof(xXFixesGetCursorImageAndNameReply) +
npixels * sizeof(CARD32) + nbytesRound, 1); npixels * sizeof(CARD32) + nbytesRound);
if (!rep) if (!rep)
return BadAlloc; return BadAlloc;