Make switch fallthrough markers compatible with clang and C23

Uses _X_FALLTHROUGH from xproto 7.0.34 if available,
local fallback if xproto is older than that.

Clears warnings from clang 19.1.7 of the form:

mouse.c:1219:17: warning: unannotated fall-through between switch labels
 [-Wimplicit-fallthrough]
 1219 |                 default:
      |                 ^
mouse.c:1219:17: note: insert '[[fallthrough]];' to silence this warning
 1219 |                 default:
      |                 ^
      |                 [[fallthrough]];
mouse.c:1219:17: note: insert 'break;' to avoid fall-through
 1219 |                 default:
      |                 ^
      |                 break;

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-input-mouse/-/merge_requests/23>
This commit is contained in:
Alan Coopersmith
2025-04-21 16:19:30 -07:00
parent 2c481bb020
commit b6d147fb53
4 changed files with 14 additions and 4 deletions

View File

@@ -48,7 +48,7 @@ XORG_WITH_LINT
AC_CHECK_FUNCS([asprintf timingsafe_memcmp])
# Obtain compiler/linker options from server and required extensions
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.10] xproto inputproto)
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.10 xproto >= 7.0.27 inputproto])
# Define a configure option for an alternate input module directory
AC_ARG_WITH(xorg-module-dir,

View File

@@ -1214,7 +1214,7 @@ MouseReadInput(InputInfoPtr pInfo)
case PROT_GLIDE:
case PROT_THINKING:
buttons |= ((int)(u & 0x10) >> 1);
/* fall through */
_X_FALLTHROUGH; /* fall through */
default:
buttons |= ((int)(u & 0x20) >> 4) |
@@ -3641,7 +3641,7 @@ autoGood(MouseDevPtr pMse)
case AUTOPROBE_H_VALIDATE2:
if (mPriv->goodCount < PROBE_UNCERTAINTY/2)
return TRUE;
/* FALLTHROUGH */
_X_FALLTHROUGH; /* FALLTHROUGH */
default:
return FALSE;
}

View File

@@ -30,6 +30,16 @@
#ifndef _XF86OSMOUSE_H_
#define _XF86OSMOUSE_H_
#include <X11/Xfuncproto.h>
#ifndef _X_FALLTHROUGH /* xproto < 7.0.34 */
# if __has_attribute(fallthrough)
# define _X_FALLTHROUGH __attribute__((fallthrough))
# else
# define _X_FALLTHROUGH (void)0
# endif
#endif
#include "xf86Xinput.h"
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 18

View File

@@ -752,7 +752,7 @@ vuidMouseProc(DeviceIntPtr pPointer, int what)
if (m != NULL)
m->next = pVuidMse->next;
}
/* fallthrough */
_X_FALLTHROUGH; /* fallthrough */
case DEVICE_OFF:
if (pInfo->fd != -1) {
if (pVuidMse->strmod) {