Skip to content

Commit

Permalink
Merge pull request #14986 from LabNConsulting/chopps/fix-asan-odr
Browse files Browse the repository at this point in the history
lib: fix the ASAN OneDefinitionRule violation.
  • Loading branch information
ton31337 authored Dec 12, 2023
2 parents 5077b6a + 29340e6 commit 54625f5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
17 changes: 9 additions & 8 deletions lib/mgmt_be_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ struct debug mgmt_dbg_be_client = {
.desc = "Management backend client operations"
};

struct mgmt_be_client *mgmt_be_client;
/* NOTE: only one client per proc for now. */
static struct mgmt_be_client *__be_client;

static int mgmt_be_client_send_msg(struct mgmt_be_client *client_ctx,
Mgmtd__BeMessage *be_msg)
Expand Down Expand Up @@ -828,11 +829,11 @@ static void mgmt_debug_client_be_set(uint32_t flags, bool set)
{
DEBUG_FLAGS_SET(&mgmt_dbg_be_client, flags, set);

if (!mgmt_be_client)
if (!__be_client)
return;

mgmt_be_client->client.conn.debug =
DEBUG_MODE_CHECK(&mgmt_dbg_be_client, DEBUG_MODE_ALL);
__be_client->client.conn.debug = DEBUG_MODE_CHECK(&mgmt_dbg_be_client,
DEBUG_MODE_ALL);
}

DEFPY(debug_mgmt_client_be, debug_mgmt_client_be_cmd,
Expand Down Expand Up @@ -878,11 +879,11 @@ struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
{
struct mgmt_be_client *client;

if (mgmt_be_client)
if (__be_client)
return NULL;

client = XCALLOC(MTYPE_MGMTD_BE_CLIENT, sizeof(*client));
mgmt_be_client = client;
__be_client = client;

/* Only call after frr_init() */
assert(running_config);
Expand Down Expand Up @@ -916,7 +917,7 @@ void mgmt_be_client_lib_vty_init(void)

void mgmt_be_client_destroy(struct mgmt_be_client *client)
{
assert(client == mgmt_be_client);
assert(client == __be_client);

MGMTD_BE_CLIENT_DBG("Destroying MGMTD Backend Client '%s'",
client->name);
Expand All @@ -929,5 +930,5 @@ void mgmt_be_client_destroy(struct mgmt_be_client *client)
XFREE(MTYPE_MGMTD_BE_CLIENT_NAME, client->name);
XFREE(MTYPE_MGMTD_BE_CLIENT, client);

mgmt_be_client = NULL;
__be_client = NULL;
}
17 changes: 9 additions & 8 deletions lib/mgmt_fe_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ struct debug mgmt_dbg_fe_client = {
.desc = "Management frontend client operations"
};

struct mgmt_fe_client *mgmt_fe_client;
/* NOTE: only one client per proc for now. */
static struct mgmt_fe_client *__fe_client;

static inline const char *dsid2name(Mgmtd__DatastoreId id)
{
Expand Down Expand Up @@ -550,11 +551,11 @@ static void mgmt_debug_client_fe_set(uint32_t mode, bool set)
{
DEBUG_FLAGS_SET(&mgmt_dbg_fe_client, mode, set);

if (!mgmt_fe_client)
if (!__fe_client)
return;

mgmt_fe_client->client.conn.debug =
DEBUG_MODE_CHECK(&mgmt_dbg_fe_client, DEBUG_MODE_ALL);
__fe_client->client.conn.debug = DEBUG_MODE_CHECK(&mgmt_dbg_fe_client,
DEBUG_MODE_ALL);
}

DEFPY(debug_mgmt_client_fe, debug_mgmt_client_fe_cmd,
Expand Down Expand Up @@ -603,11 +604,11 @@ struct mgmt_fe_client *mgmt_fe_client_create(const char *client_name,
{
struct mgmt_fe_client *client;

if (mgmt_fe_client)
if (__fe_client)
return NULL;

client = XCALLOC(MTYPE_MGMTD_FE_CLIENT, sizeof(*client));
mgmt_fe_client = client;
__fe_client = client;

client->name = XSTRDUP(MTYPE_MGMTD_FE_CLIENT_NAME, client_name);
client->user_data = user_data;
Expand Down Expand Up @@ -704,7 +705,7 @@ void mgmt_fe_client_destroy(struct mgmt_fe_client *client)
{
struct mgmt_fe_client_session *session;

assert(client == mgmt_fe_client);
assert(client == __fe_client);

MGMTD_FE_CLIENT_DBG("Destroying MGMTD Frontend Client '%s'",
client->name);
Expand All @@ -717,5 +718,5 @@ void mgmt_fe_client_destroy(struct mgmt_fe_client *client)
XFREE(MTYPE_MGMTD_FE_CLIENT_NAME, client->name);
XFREE(MTYPE_MGMTD_FE_CLIENT, client);

mgmt_fe_client = NULL;
__fe_client = NULL;
}
2 changes: 1 addition & 1 deletion staticd/static_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct option longopts[] = { { 0 } };
/* Master of threads. */
struct event_loop *master;

struct mgmt_be_client *mgmt_be_client;
static struct mgmt_be_client *mgmt_be_client;

static struct frr_daemon_info staticd_di;

Expand Down

0 comments on commit 54625f5

Please sign in to comment.