Move sizeof to second argument in calloc calls

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

kbd.c: In function ‘KbdPreInit’:
kbd.c:160:32: warning: ‘calloc’ sizes specified with ‘sizeof’ in the
 earlier argument and not in the later argument [-Wcalloc-transposed-args]
  160 |     if (!(pKbd = calloc(sizeof(KbdDevRec), 1))) {
      |                                ^~~~~~~~~
kbd.c:160:32: 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/driver/xf86-input-keyboard/-/merge_requests/14>
This commit is contained in:
Alan Coopersmith
2024-07-14 11:33:37 -07:00
parent 8f6fd12607
commit 6c2a8e59f0
3 changed files with 3 additions and 3 deletions

View File

@@ -507,7 +507,7 @@ xf86OSKbdPreInit(InputInfoPtr pInfo)
pKbd->OpenKeyboard = OpenKeyboard;
pKbd->private = calloc(sizeof(BsdKbdPrivRec), 1);
pKbd->private = calloc(1, sizeof(BsdKbdPrivRec));
if (pKbd->private == NULL) {
xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
return FALSE;

View File

@@ -157,7 +157,7 @@ KbdPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
xf86CollectInputOptions(pInfo, defaults);
xf86ProcessCommonOptions(pInfo, pInfo->options);
if (!(pKbd = calloc(sizeof(KbdDevRec), 1))) {
if (!(pKbd = calloc(1, sizeof(KbdDevRec)))) {
rc = BadAlloc;
goto out;
}

View File

@@ -525,7 +525,7 @@ xf86OSKbdPreInit(InputInfoPtr pInfo)
pKbd->OpenKeyboard = OpenKeyboard;
pKbd->private = calloc(sizeof(sunKbdPrivRec), 1);
pKbd->private = calloc(1, sizeof(sunKbdPrivRec));
if (pKbd->private == NULL) {
xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
return FALSE;