Skip to content

Commit

Permalink
threadstate: don't use an unnecessary macro
Browse files Browse the repository at this point in the history
Now that we've reduced the usage of GIT_THREADSTATE, remove it entirely
in favor of git_threadstate_get().
  • Loading branch information
ethomson committed May 13, 2023
1 parent a97a633 commit 062b3e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/libgit2/errors.c
Expand Up @@ -33,7 +33,7 @@ static git_error tlsdata_error = {

static void set_error_from_buffer(int error_class)
{
git_threadstate *threadstate = GIT_THREADSTATE;
git_threadstate *threadstate = git_threadstate_get();
git_error *error;
git_str *buf;

Expand All @@ -51,7 +51,7 @@ static void set_error_from_buffer(int error_class)

static void set_error(int error_class, char *string)
{
git_threadstate *threadstate = GIT_THREADSTATE;
git_threadstate *threadstate = git_threadstate_get();
git_str *buf;

if (!threadstate)
Expand All @@ -71,7 +71,7 @@ static void set_error(int error_class, char *string)

void git_error_set_oom(void)
{
git_threadstate *threadstate = GIT_THREADSTATE;
git_threadstate *threadstate = git_threadstate_get();

if (!threadstate)
return;
Expand All @@ -90,7 +90,7 @@ void git_error_set(int error_class, const char *fmt, ...)

void git_error_vset(int error_class, const char *fmt, va_list ap)
{
git_threadstate *threadstate = GIT_THREADSTATE;
git_threadstate *threadstate = git_threadstate_get();
int error_code = (error_class == GIT_ERROR_OS) ? errno : 0;
git_str *buf;

Expand Down Expand Up @@ -135,7 +135,7 @@ void git_error_vset(int error_class, const char *fmt, va_list ap)

int git_error_set_str(int error_class, const char *string)
{
git_threadstate *threadstate = GIT_THREADSTATE;
git_threadstate *threadstate = git_threadstate_get();
git_str *buf;

GIT_ASSERT_ARG(string);
Expand All @@ -157,7 +157,7 @@ int git_error_set_str(int error_class, const char *string)

void git_error_clear(void)
{
git_threadstate *threadstate = GIT_THREADSTATE;
git_threadstate *threadstate = git_threadstate_get();

if (!threadstate)
return;
Expand All @@ -181,15 +181,15 @@ const git_error *git_error_last(void)
if (!git_libgit2_init_count())
return &uninitialized_error;

if ((threadstate = GIT_THREADSTATE) == NULL)
if ((threadstate = git_threadstate_get()) == NULL)
return &tlsdata_error;

return threadstate->last_error;
}

int git_error_state_capture(git_error_state *state, int error_code)
{
git_threadstate *threadstate = GIT_THREADSTATE;
git_threadstate *threadstate = git_threadstate_get();
git_error *error;
git_str *error_buf;

Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/oid.c
Expand Up @@ -155,7 +155,7 @@ int git_oid_pathfmt(char *str, const git_oid *oid)

char *git_oid_tostr_s(const git_oid *oid)
{
git_threadstate *threadstate = GIT_THREADSTATE;
git_threadstate *threadstate = git_threadstate_get();
char *str;

if (!threadstate)
Expand Down
2 changes: 0 additions & 2 deletions src/libgit2/threadstate.h
Expand Up @@ -19,6 +19,4 @@ typedef struct {
extern int git_threadstate_global_init(void);
extern git_threadstate *git_threadstate_get(void);

#define GIT_THREADSTATE (git_threadstate_get())

#endif

0 comments on commit 062b3e4

Please sign in to comment.