Skip to content

Commit 8e55ea2

Browse files
authored
fix: use a static const to define array size (#4917)
1 parent 7c55297 commit 8e55ea2

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

Sources/SentryCrash/Recording/Tools/SentryCrashMachineContext.c

-6
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,6 @@ getThreadList(SentryCrashMachineContext *context)
9191
return true;
9292
}
9393

94-
int
95-
sentrycrashmc_contextSize(void)
96-
{
97-
return sizeof(SentryCrashMachineContext);
98-
}
99-
10094
SentryCrashThread
10195
sentrycrashmc_getThreadFromContext(const SentryCrashMachineContext *const context)
10296
{

Sources/SentryCrash/Recording/Tools/SentryCrashMachineContext.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#ifndef HDR_SentryCrashMachineContext_h
2929
#define HDR_SentryCrashMachineContext_h
3030

31+
#include "SentryCrashMachineContext_Apple.h"
3132
#include "SentryCrashThread.h"
3233
#include <mach/mach.h>
3334
#include <stdbool.h>
@@ -64,16 +65,12 @@ void sentrycrashmc_resumeEnvironment(thread_act_array_t threads, mach_msg_type_n
6465
* @param NAME The C identifier to give the pointer.
6566
*/
6667
#define SentryCrashMC_NEW_CONTEXT(NAME) \
67-
char sentrycrashmc_##NAME##_storage[sentrycrashmc_contextSize()]; \
68+
char sentrycrashmc_##NAME##_storage[sentrycrashmc_contextSize]; \
6869
struct SentryCrashMachineContext *NAME \
6970
= (struct SentryCrashMachineContext *)sentrycrashmc_##NAME##_storage
7071

7172
struct SentryCrashMachineContext;
7273

73-
/** Get the internal size of a machine context.
74-
*/
75-
int sentrycrashmc_contextSize(void);
76-
7774
/** Fill in a machine context from a thread.
7875
*
7976
* @param thread The thread to get information from.

Sources/SentryCrash/Recording/Tools/SentryCrashMachineContext_Apple.h

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extern "C" {
3434

3535
#include <mach/mach_types.h>
3636
#include <stdbool.h>
37+
#include <stddef.h>
3738
#include <sys/ucontext.h>
3839

3940
#ifdef __arm64__
@@ -53,6 +54,8 @@ typedef struct SentryCrashMachineContext {
5354
STRUCT_MCONTEXT_L machineContext;
5455
} SentryCrashMachineContext;
5556

57+
static const size_t sentrycrashmc_contextSize = sizeof(SentryCrashMachineContext);
58+
5659
#ifdef __cplusplus
5760
}
5861
#endif

0 commit comments

Comments
 (0)