From a57b7d8f05287d486df0382e250c3fac4a00a955 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 31 Jan 2024 23:18:45 +0100 Subject: [PATCH] Revert "Fix -Wcalloc-transposed-args warnings" This reverts commit f97c27efe9f1d50d31879657569405808099b54e. --- camlibs/canon/library.c | 2 +- camlibs/kodak/ez200/ez200.c | 2 +- camlibs/lumix/lumix.c | 2 +- camlibs/pentax/library.c | 2 +- camlibs/ptp2/library.c | 4 ++-- camlibs/ptp2/ptp-pack.c | 16 ++++++++-------- camlibs/ptp2/ptp.c | 8 ++++---- camlibs/spca50x/library.c | 2 +- camlibs/topfield/puppy.c | 4 ++-- examples/sample-multi-detect.c | 2 +- libgphoto2/gphoto2-filesys.c | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/camlibs/canon/library.c b/camlibs/canon/library.c index aeb4fcf6f..4b949cc7d 100644 --- a/camlibs/canon/library.c +++ b/camlibs/canon/library.c @@ -1091,7 +1091,7 @@ storage_info_func ( canon_int_get_disk_name_info (camera, root, &camera->pl->cached_capacity, &camera->pl->cached_available, context); - *sinfos = (CameraStorageInformation*) calloc (1, sizeof (CameraStorageInformation)); + *sinfos = (CameraStorageInformation*) calloc (sizeof (CameraStorageInformation), 1); *nrofsinfos = 1; (*sinfos)->fields = GP_STORAGEINFO_BASE; strcpy ((*sinfos)->basedir, "/"); diff --git a/camlibs/kodak/ez200/ez200.c b/camlibs/kodak/ez200/ez200.c index 246d800c1..d9b56374b 100644 --- a/camlibs/kodak/ez200/ez200.c +++ b/camlibs/kodak/ez200/ez200.c @@ -329,7 +329,7 @@ camera_init(Camera *camera, GPContext *context) /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); - camera->pl = calloc (1, sizeof (CameraPrivateLibrary)); + camera->pl = calloc (sizeof (CameraPrivateLibrary), 1); if (!camera->pl) return GP_ERROR_NO_MEMORY; /* Connect to the camera */ diff --git a/camlibs/lumix/lumix.c b/camlibs/lumix/lumix.c index 7c2a0be18..7505f3538 100644 --- a/camlibs/lumix/lumix.c +++ b/camlibs/lumix/lumix.c @@ -1866,7 +1866,7 @@ camera_init (Camera *camera, GPContext *context) int tries; char *result; - camera->pl = calloc(1, sizeof(CameraPrivateLibrary)); + camera->pl = calloc(sizeof(CameraPrivateLibrary),1); /* First, set up all the function pointers */ camera->functions->exit = camera_exit; diff --git a/camlibs/pentax/library.c b/camlibs/pentax/library.c index 3904ea1d6..71ff60967 100644 --- a/camlibs/pentax/library.c +++ b/camlibs/pentax/library.c @@ -1021,7 +1021,7 @@ camera_init (Camera *camera, GPContext *context) { CameraPrivateLibrary *cpl; - cpl = calloc (1, sizeof (CameraPrivateLibrary)); + cpl = calloc (sizeof (CameraPrivateLibrary), 1); /* pslr = pslr_init (model, device); ... but it basically just opens the fd */ cpl->pslr.fd = camera->port; diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c index 25d2de1fc..117f49744 100644 --- a/camlibs/ptp2/library.c +++ b/camlibs/ptp2/library.c @@ -307,8 +307,8 @@ fixup_cached_deviceinfo (Camera *camera, PTPDeviceInfo *di) { /* Dup and merge the lists */ #define DI_MERGE(x) \ - C_MEM (newdi.x = calloc((ndi.x##_len + outerdi->x##_len), sizeof(outerdi->x[0])); \ - for (i = 0; i < outerdi->x##_len ; i++) \ + C_MEM (newdi.x = calloc(sizeof(outerdi->x[0]),(ndi.x##_len + outerdi->x##_len)));\ + for (i = 0; i < outerdi->x##_len ; i++) \ newdi.x[i] = outerdi->x[i]; \ for (i = 0; i < ndi.x##_len ; i++) \ newdi.x[i+outerdi->x##_len] = ndi.x[i]; \ diff --git a/camlibs/ptp2/ptp-pack.c b/camlibs/ptp2/ptp-pack.c index 00cfca751..35544e6b1 100644 --- a/camlibs/ptp2/ptp-pack.c +++ b/camlibs/ptp2/ptp-pack.c @@ -821,7 +821,7 @@ ptp_unpack_OI (PTPParams *params, unsigned char* data, PTPObjectInfo *oi, unsign if (n > (total - (*offset))/sizeof(val->a.v[0].member))\ return 0; \ val->a.count = n; \ - val->a.v = calloc(n, sizeof(val->a.v[0])); \ + val->a.v = calloc(sizeof(val->a.v[0]),n); \ if (!val->a.v) return 0; \ for (j=0;ja.v[j].member, func); \ @@ -1118,7 +1118,7 @@ duplicate_PropertyValue (const PTPPropertyValue *src, PTPPropertyValue *dst, uin unsigned int i; dst->a.count = src->a.count; - dst->a.v = calloc (src->a.count, sizeof(src->a.v[0])); + dst->a.v = calloc (sizeof(src->a.v[0]),src->a.count); for (i=0;ia.count;i++) duplicate_PropertyValue (&src->a.v[i], &dst->a.v[i], type & ~PTP_DTC_ARRAY_MASK); return; @@ -1161,7 +1161,7 @@ duplicate_DevicePropDesc(const PTPDevicePropDesc *src, PTPDevicePropDesc *dst) { break; case PTP_DPFF_Enumeration: dst->FORM.Enum.NumberOfValues = src->FORM.Enum.NumberOfValues; - dst->FORM.Enum.SupportedValue = calloc (src->FORM.Enum.NumberOfValues, sizeof(dst->FORM.Enum.SupportedValue[0])); + dst->FORM.Enum.SupportedValue = calloc (sizeof(dst->FORM.Enum.SupportedValue[0]),src->FORM.Enum.NumberOfValues); for (i = 0; iFORM.Enum.NumberOfValues ; i++) duplicate_PropertyValue (&src->FORM.Enum.SupportedValue[i], &dst->FORM.Enum.SupportedValue[i], src->DataType); break; @@ -2031,7 +2031,7 @@ ptp_unpack_CANON_changes (PTPParams *params, unsigned char* data, unsigned int d curdata += size; entries++; } - ce = calloc (entries + 1, sizeof(PTPCanon_changes_entry)); + ce = calloc (sizeof(PTPCanon_changes_entry),(entries+1)); if (!ce) return 0; curdata = data; @@ -2158,7 +2158,7 @@ ptp_unpack_CANON_changes (PTPParams *params, unsigned char* data, unsigned int d dpd->FormFlag = PTP_DPFF_Enumeration; dpd->FORM.Enum.NumberOfValues = propxcnt; free (dpd->FORM.Enum.SupportedValue); - dpd->FORM.Enum.SupportedValue = calloc (propxcnt, sizeof (PTPPropertyValue)); + dpd->FORM.Enum.SupportedValue = calloc (sizeof (PTPPropertyValue),propxcnt); switch (proptype) { case PTP_DPC_CANON_EOS_ImageFormat: @@ -2955,7 +2955,7 @@ ptp_unpack_Nikon_EC (PTPParams *params, unsigned char* data, unsigned int len, P if (!*cnt) return; - *ec = calloc((*cnt), sizeof(PTPContainer)); + *ec = calloc(sizeof(PTPContainer),(*cnt)); for (i=0;i<*cnt;i++) { memset(&(*ec)[i],0,sizeof(PTPContainer)); @@ -2989,7 +2989,7 @@ ptp_unpack_Nikon_EC_EX (PTPParams *params, unsigned char* data, unsigned int len if (!*cnt) return 1; - *ec = calloc((*cnt), sizeof(PTPContainer)); + *ec = calloc(sizeof(PTPContainer),(*cnt)); offset = PTP_nikon_ec_ex_Code+sizeof(uint16_t); for (i=0;i<*cnt;i++) { @@ -3218,7 +3218,7 @@ ptp_unpack_ptp11_manifest ( return 0; numberoifs = dtoh64ap(params,data); curoffset = 8; - xoifs = calloc(numberoifs, sizeof(PTPObjectFilesystemInfo)); + xoifs = calloc(sizeof(PTPObjectFilesystemInfo),numberoifs); if (!xoifs) return 0; diff --git a/camlibs/ptp2/ptp.c b/camlibs/ptp2/ptp.c index b02b2dab8..fc26ff37a 100644 --- a/camlibs/ptp2/ptp.c +++ b/camlibs/ptp2/ptp.c @@ -1473,7 +1473,7 @@ c0 03 00 05 bc 02 1e 00 return PTP_RC_GeneralError; } - *liveviewsizes = calloc (count, sizeof(PanasonicLiveViewSize)); + *liveviewsizes = calloc (sizeof(PanasonicLiveViewSize),count); for (i = 0;i < count; i++) { (*liveviewsizes)[i].height = dtoh16a (data + 12 + i*structsize); (*liveviewsizes)[i].width = dtoh16a (data + 12 + 2 + i*structsize); @@ -3175,7 +3175,7 @@ ptp_canon_gettreesize (PTPParams* params, PTP_CNT_INIT(ptp, PTP_OC_CANON_GetTreeSize); CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size)); *cnt = dtoh32a(data); - *entries = calloc((*cnt), sizeof(PTPCanon_directtransfer_entry)); + *entries = calloc(sizeof(PTPCanon_directtransfer_entry),(*cnt)); if (!*entries) { ret = PTP_RC_GeneralError; goto exit; @@ -3927,7 +3927,7 @@ ptp_canon_eos_getdevicepropdesc (PTPParams* params, uint16_t propcode, memcpy (dpd, ¶ms->canon_props[i].dpd, sizeof (*dpd)); if (dpd->FormFlag == PTP_DPFF_Enumeration) { /* need to duplicate the Enumeration alloc */ - dpd->FORM.Enum.SupportedValue = calloc (dpd->FORM.Enum.NumberOfValues, sizeof (PTPPropertyValue)); + dpd->FORM.Enum.SupportedValue = calloc (sizeof (PTPPropertyValue),dpd->FORM.Enum.NumberOfValues); memcpy (dpd->FORM.Enum.SupportedValue, params->canon_props[i].dpd.FORM.Enum.SupportedValue, sizeof (PTPPropertyValue)*dpd->FORM.Enum.NumberOfValues @@ -5962,7 +5962,7 @@ ptp_fuji_getdeviceinfo (PTPParams* params, uint16_t **props, unsigned int *numpr xdata = data + 4; xsize = size - 4; - *props = calloc(nums, sizeof(uint16_t)); + *props = calloc(sizeof(uint16_t),nums); *numprops = nums; for (i=0;ipl = calloc (1, sizeof (CameraPrivateLibrary)); + camera->pl = calloc (sizeof (CameraPrivateLibrary), 1); if (!camera->pl) return (GP_ERROR_NO_MEMORY); camera->pl->gpdev = camera->port; diff --git a/camlibs/topfield/puppy.c b/camlibs/topfield/puppy.c index c5a8b2da6..14815bd9e 100644 --- a/camlibs/topfield/puppy.c +++ b/camlibs/topfield/puppy.c @@ -1076,7 +1076,7 @@ storage_info_func (CameraFilesystem *fs, unsigned int totalk = get_u32(&reply.data); unsigned int freek = get_u32(&reply.data[4]); - sif = *storageinformations = calloc(1, sizeof(CameraStorageInformation)); + sif = *storageinformations = calloc(sizeof(CameraStorageInformation),1); *nrofstorageinformations = 1; sif->fields |= GP_STORAGEINFO_BASE; @@ -1212,7 +1212,7 @@ camera_init (Camera *camera, GPContext *context) gp_port_set_timeout (camera->port, TF_PROTOCOL_TIMEOUT); gp_port_usb_clear_halt (camera->port, GP_PORT_USB_ENDPOINT_IN); - camera->pl = calloc (1, sizeof (CameraPrivateLibrary)); + camera->pl = calloc (sizeof (CameraPrivateLibrary),1); if (!camera->pl) return GP_ERROR_NO_MEMORY; #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H) diff --git a/examples/sample-multi-detect.c b/examples/sample-multi-detect.c index 4f8218637..2099b8cf0 100644 --- a/examples/sample-multi-detect.c +++ b/examples/sample-multi-detect.c @@ -32,7 +32,7 @@ int main(int argc, char **argv) { /* Now open all cameras we autodected for usage */ printf("Number of cameras: %d\n", count); - cams = calloc (count, sizeof (Camera*)); + cams = calloc (sizeof (Camera*),count); for (i = 0; i < count; i++) { gp_list_get_name (list, i, &name); gp_list_get_value (list, i, &value); diff --git a/libgphoto2/gphoto2-filesys.c b/libgphoto2/gphoto2-filesys.c index 5bf265ccf..746d91446 100644 --- a/libgphoto2/gphoto2-filesys.c +++ b/libgphoto2/gphoto2-filesys.c @@ -646,7 +646,7 @@ gp_filesystem_new (CameraFilesystem **fs) C_MEM (*fs = calloc (1, sizeof (CameraFilesystem))); - (*fs)->rootfolder = calloc (1, sizeof (CameraFilesystemFolder)); + (*fs)->rootfolder = calloc (sizeof (CameraFilesystemFolder), 1); if (!(*fs)->rootfolder) { free (*fs); return (GP_ERROR_NO_MEMORY); @@ -716,7 +716,7 @@ internal_append (CameraFilesystem *fs, CameraFilesystemFolder *f, if (*new) return (GP_ERROR_FILE_EXISTS); - C_MEM ((*new) = calloc (1, sizeof (CameraFilesystemFile))); + C_MEM ((*new) = calloc (sizeof (CameraFilesystemFile), 1)); (*new)->name = strdup (filename); if (!(*new)->name) { free (*new);