Skip to content

Commit

Permalink
fix: use void for all empty parameter-lists in C functions (#804)
Browse files Browse the repository at this point in the history
This is one of many aspects where C and C++ standards deviate:

An empty parameter list in C++ is equivalent to a void parameter list. But in C, an empty parameter list meant: you could give any number of types as parameters.

With C11, this "feature" became obsolete: empty parameter lists are no longer standard-conforming C. Since some of those are in our API surface, we should fix this.
  • Loading branch information
supervacuus authored Feb 8, 2023
1 parent 41487ca commit d82af0a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ SENTRY_EXPERIMENTAL_API void sentry_transaction_iter_headers(
* 0 = no crash recognized
* -1 = sentry_init() hasn't been called yet
*/
SENTRY_EXPERIMENTAL_API int sentry_get_crashed_last_run();
SENTRY_EXPERIMENTAL_API int sentry_get_crashed_last_run(void);

/**
* Clear the status of the "crashed-last-run". You should explicitly call
Expand All @@ -1875,22 +1875,22 @@ SENTRY_EXPERIMENTAL_API int sentry_get_crashed_last_run();
*
* Returns 0 on success, 1 on error.
*/
SENTRY_EXPERIMENTAL_API int sentry_clear_crashed_last_run();
SENTRY_EXPERIMENTAL_API int sentry_clear_crashed_last_run(void);

/**
* Sentry SDK version.
*/
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_version();
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_version(void);

/**
* Sentry SDK name.
*/
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_name();
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_name(void);

/**
* Sentry SDK User-Agent.
*/
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_user_agent();
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_user_agent(void);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions src/sentry_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,13 +1014,13 @@ sentry_span_finish(sentry_span_t *opaque_span)
}

int
sentry_get_crashed_last_run()
sentry_get_crashed_last_run(void)
{
return g_last_crash;
}

int
sentry_clear_crashed_last_run()
sentry_clear_crashed_last_run(void)
{
bool success = false;
sentry_options_t *options = sentry__options_lock();
Expand Down
6 changes: 3 additions & 3 deletions src/sentry_info.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#include "sentry_boot.h"

const char *
sentry_sdk_version()
sentry_sdk_version(void)
{
return SENTRY_SDK_VERSION;
}

const char *
sentry_sdk_name()
sentry_sdk_name(void)
{
return SENTRY_SDK_NAME;
}

const char *
sentry_sdk_user_agent()
sentry_sdk_user_agent(void)
{
return SENTRY_SDK_USER_AGENT;
}
4 changes: 2 additions & 2 deletions src/sentry_scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ sentry__scope_unlock(void)
}

void
sentry__scope_flush_unlock()
sentry__scope_flush_unlock(void)
{
sentry__scope_unlock();
SENTRY_WITH_OPTIONS (options) {
Expand Down Expand Up @@ -245,7 +245,7 @@ sentry__get_span_or_transaction(const sentry_scope_t *scope)

#ifdef SENTRY_UNITTEST
sentry_value_t
sentry__scope_get_span_or_transaction()
sentry__scope_get_span_or_transaction(void)
{
SENTRY_WITH_SCOPE (scope) {
return sentry__get_span_or_transaction(scope);
Expand Down
4 changes: 2 additions & 2 deletions src/sentry_scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void sentry__scope_cleanup(void);
* This function must be called while holding the scope lock, and it will be
* unlocked internally.
*/
void sentry__scope_flush_unlock();
void sentry__scope_flush_unlock(void);

/**
* This will merge the requested data which is in the given `scope` to the given
Expand Down Expand Up @@ -98,5 +98,5 @@ void sentry__scope_apply_to_event(const sentry_scope_t *scope,

// this is only used in unit tests
#ifdef SENTRY_UNITTEST
sentry_value_t sentry__scope_get_span_or_transaction();
sentry_value_t sentry__scope_get_span_or_transaction(void);
#endif
2 changes: 1 addition & 1 deletion src/sentry_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ sentry__thread_setname(sentry_threadid_t thread_id, const char *thread_name)
}
#else
sentry_threadid_t
sentry__thread_get_current_threadid()
sentry__thread_get_current_threadid(void)
{
return pthread_self();
}
Expand Down
2 changes: 1 addition & 1 deletion src/sentry_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ sentry__iso8601_to_msec(const char *iso)
// to ensure the C locale is also used there.
#if !defined(SENTRY_PLATFORM_ANDROID) && !defined(SENTRY_PLATFORM_IOS)
static sentry__locale_t
c_locale()
c_locale(void)
{
static long c_locale_initialized = 0;
static sentry__locale_t c_locale;
Expand Down

0 comments on commit d82af0a

Please sign in to comment.