[c standard] use WINPR_FALLTHROUGH

use the macro to silence intentional switch fallthrough locations
This commit is contained in:
akallabeth
2023-08-25 11:26:08 +02:00
committed by akallabeth
parent 0a90e9214e
commit 9cee9b3c08
9 changed files with 60 additions and 9 deletions

View File

@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <winpr/wtypes.h>
#include <winpr/sysinfo.h>
#include <winpr/collections.h>
@@ -286,10 +287,12 @@ static void LIBUSB_CALL func_iso_callback(struct libusb_transfer* transfer)
}
}
/* fallthrough */
WINPR_FALLTHROUGH
case LIBUSB_TRANSFER_CANCELLED:
/* fallthrough */
WINPR_FALLTHROUGH
case LIBUSB_TRANSFER_TIMED_OUT:
/* fallthrough */
WINPR_FALLTHROUGH
case LIBUSB_TRANSFER_ERROR:
{

View File

@@ -38,6 +38,7 @@
#include "xf_input.h"
#include <winpr/assert.h>
#include <winpr/wtypes.h>
#include <freerdp/log.h>
#define TAG CLIENT_TAG("x11")
@@ -855,15 +856,19 @@ static int xf_input_handle_event_remote(xfContext* xfc, const XEvent* event)
{
case XI_TouchBegin:
xf_input_pens_unhover(xfc);
/* fallthrough */
WINPR_FALLTHROUGH
case XI_TouchUpdate:
/* fallthrough */
WINPR_FALLTHROUGH
case XI_TouchEnd:
xf_input_touch_remote(xfc, cookie.cc->data, cookie.cc->evtype);
break;
case XI_ButtonPress:
/* fallthrough */
WINPR_FALLTHROUGH
case XI_Motion:
/* fallthrough */
WINPR_FALLTHROUGH
case XI_ButtonRelease:
{
@@ -877,6 +882,7 @@ static int xf_input_handle_event_remote(xfContext* xfc, const XEvent* event)
break;
}
}
/* fallthrough */
WINPR_FALLTHROUGH
default:
xf_input_pens_unhover(xfc);

View File

@@ -27,6 +27,7 @@
#include <freerdp/peer.h>
#include <winpr/crt.h>
#include <winpr/wtypes.h>
#include <winpr/assert.h>
#include <winpr/library.h>
#include <winpr/registry.h>
@@ -706,7 +707,7 @@ void credssp_auth_free(rdpCredsspAuth* auth)
case AUTH_STATE_FINAL:
WINPR_ASSERT(auth->table->DeleteSecurityContext);
auth->table->DeleteSecurityContext(&auth->context);
/* FALLTHROUGH */
/* fallthrouth */
WINPR_FALLTHROUGH
case AUTH_STATE_CREDS:
WINPR_ASSERT(auth->table->FreeCredentialsHandle);

View File

@@ -22,6 +22,7 @@
#include <freerdp/log.h>
#include <winpr/crt.h>
#include <winpr/wtypes.h>
#include <winpr/assert.h>
#include <winpr/print.h>
#include <winpr/synch.h>
@@ -286,7 +287,7 @@ static int rpc_client_recv_pdu(rdpRpc* rpc, RPC_PDU* pdu)
WLog_ERR(TAG, "rpc_secure_bind: error sending rpc_auth_3 pdu!");
return -1;
}
/* FALLTHROUGH */
/* fallthrough */
WINPR_FALLTHROUGH
case RPC_BIND_STATE_COMPLETE:
rpc_client_transition_to_state(rpc, RPC_CLIENT_STATE_CONTEXT_NEGOTIATED);

View File

@@ -29,9 +29,13 @@
#define WINPR_RESTRICT
#endif
// C17 related macros
#if defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201710L)
#define WINPR_FALLTHROUGH [[fallthrough]]
// C23 related macros
#if defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
#define WINPR_FALLTHROUGH [[fallthrough]];
#elif defined(__clang__)
#define WINPR_FALLTHROUGH __attribute__((fallthrough));
#elif defined(__GNUC__) && (__GNUC__ >= 7)
#define WINPR_FALLTHROUGH __attribute__((fallthrough));
#else
#define WINPR_FALLTHROUGH
#endif

View File

@@ -38,6 +38,7 @@ See the header file "utf.h" for complete documentation.
------------------------------------------------------------------------ */
#include <winpr/wtypes.h>
#include <winpr/string.h>
#include <winpr/assert.h>
@@ -242,14 +243,19 @@ static ConversionResult winpr_ConvertUTF16toUTF8_Internal(const uint16_t** sourc
case 4:
*--target = (uint8_t)((ch | byteMark) & byteMask);
ch >>= 6;
/* fallthrough */
WINPR_FALLTHROUGH
case 3:
*--target = (uint8_t)((ch | byteMark) & byteMask);
ch >>= 6;
/* fallthrough */
WINPR_FALLTHROUGH
case 2:
*--target = (uint8_t)((ch | byteMark) & byteMask);
ch >>= 6;
/* fallthrough */
WINPR_FALLTHROUGH
case 1:
*--target = (uint8_t)(ch | firstByteMark[bytesToWrite]);
@@ -262,12 +268,18 @@ static ConversionResult winpr_ConvertUTF16toUTF8_Internal(const uint16_t** sourc
/* note: everything falls through. */
case 4:
--target;
/* fallthrough */
WINPR_FALLTHROUGH
case 3:
--target;
/* fallthrough */
WINPR_FALLTHROUGH
case 2:
--target;
/* fallthrough */
WINPR_FALLTHROUGH
case 1:
--target;
@@ -309,10 +321,14 @@ static bool isLegalUTF8(const uint8_t* source, int length)
case 4:
if ((a = (*--srcptr)) < 0x80 || a > 0xBF)
return false;
/* fallthrough */
WINPR_FALLTHROUGH
case 3:
if ((a = (*--srcptr)) < 0x80 || a > 0xBF)
return false;
/* fallthrough */
WINPR_FALLTHROUGH
case 2:
if ((a = (*--srcptr)) > 0xBF)
@@ -348,7 +364,10 @@ static bool isLegalUTF8(const uint8_t* source, int length)
default:
if (a < 0x80)
return false;
break;
}
/* fallthrough */
WINPR_FALLTHROUGH
case 1:
if (*source >= 0x80 && *source < 0xC2)
@@ -404,22 +423,32 @@ static ConversionResult winpr_ConvertUTF8toUTF16_Internal(const uint8_t** source
case 5:
ch += *source++;
ch <<= 6; /* remember, illegal UTF-8 */
/* fallthrough */
WINPR_FALLTHROUGH
case 4:
ch += *source++;
ch <<= 6; /* remember, illegal UTF-8 */
/* fallthrough */
WINPR_FALLTHROUGH
case 3:
ch += *source++;
ch <<= 6;
/* fallthrough */
WINPR_FALLTHROUGH
case 2:
ch += *source++;
ch <<= 6;
/* fallthrough */
WINPR_FALLTHROUGH
case 1:
ch += *source++;
ch <<= 6;
/* fallthrough */
WINPR_FALLTHROUGH
case 0:
ch += *source++;

View File

@@ -208,9 +208,12 @@ static CK_RV object_load_attributes(NCryptP11ProviderHandle* provider, CK_SESSIO
return rv;
/* fallthrough */
WINPR_FALLTHROUGH
case CKR_ATTRIBUTE_SENSITIVE:
/* fallthrough */
WINPR_FALLTHROUGH
case CKR_ATTRIBUTE_TYPE_INVALID:
/* fallthrough */
WINPR_FALLTHROUGH
case CKR_BUFFER_TOO_SMALL:
/* attributes need some buffers for the result value */
if (!attributes_allocate_buffers(attributes, count))

View File

@@ -818,6 +818,7 @@ static SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextA(
goto bad_token;
/* Continue to AP-REQ */
/* fall through */
WINPR_FALLTHROUGH
case KERBEROS_STATE_AP_REQ:

View File

@@ -21,6 +21,7 @@
#include <winpr/config.h>
#include <winpr/crt.h>
#include <winpr/wtypes.h>
#include <winpr/assert.h>
#include <winpr/sspi.h>
#include <winpr/tchar.h>
@@ -798,7 +799,9 @@ static SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextW(
case REJECT:
return SEC_E_LOGON_DENIED;
case REQUEST_MIC:
context->mic = TRUE; /* fallthrough */
context->mic = TRUE;
/* fallthrough */
WINPR_FALLTHROUGH
case ACCEPT_INCOMPLETE:
context->state = NEGOTIATE_STATE_NEGORESP;
break;