Skip to content

Commit

Permalink
net/credman : Move 'CREDMAN_MAX_CREDENTIALS' to 'CONFIG_'
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaim committed Jul 14, 2020
1 parent 60def88 commit 774c18e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions sys/include/net/credman.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ extern "C" {
/**
* @brief Maximum number of credentials in credential pool
*/
#ifndef CREDMAN_MAX_CREDENTIALS
#define CREDMAN_MAX_CREDENTIALS (2)
#ifndef CONFIG_CREDMAN_MAX_CREDENTIALS
#define CONFIG_CREDMAN_MAX_CREDENTIALS (2)
#endif

/**
Expand Down Expand Up @@ -173,7 +173,7 @@ void credman_delete(credman_tag_t tag, credman_type_t type);
/**
* @brief Gets the number of credentials currently in the credential pool
*
* Maximum number of allowed credentials is defined by CREDMAN_MAX_CREDENTIALS
* Maximum number of allowed credentials is defined by CONFIG_CREDMAN_MAX_CREDENTIALS
*
* @return number of credentials currently in the credential pool
*/
Expand Down
6 changes: 3 additions & 3 deletions sys/net/credman/credman.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

static mutex_t _mutex = MUTEX_INIT;

static credman_credential_t credentials[CREDMAN_MAX_CREDENTIALS];
static credman_credential_t credentials[CONFIG_CREDMAN_MAX_CREDENTIALS];
static unsigned used = 0;

static int _find_credential_pos(credman_tag_t tag, credman_type_t type,
Expand Down Expand Up @@ -129,7 +129,7 @@ int credman_get_used_count(void)
static int _find_credential_pos(credman_tag_t tag, credman_type_t type,
credman_credential_t **empty)
{
for (unsigned i = 0; i < CREDMAN_MAX_CREDENTIALS; i++) {
for (unsigned i = 0; i < CONFIG_CREDMAN_MAX_CREDENTIALS; i++) {
credman_credential_t *c = &credentials[i];
if ((c->tag == tag) && (c->type == type)) {
return i;
Expand All @@ -148,7 +148,7 @@ void credman_reset(void)
{
mutex_lock(&_mutex);
memset(credentials, 0,
sizeof(credman_credential_t) * CREDMAN_MAX_CREDENTIALS);
sizeof(credman_credential_t) * CONFIG_CREDMAN_MAX_CREDENTIALS);
used = 0;
mutex_unlock(&_mutex);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/tests-credman/tests-credman.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static void test_credman_add(void)

/* fill the pool */
memcpy(&credential.params.psk, &exp_psk_params, sizeof(psk_params_t));
while (credman_get_used_count() < CREDMAN_MAX_CREDENTIALS) {
while (credman_get_used_count() < CONFIG_CREDMAN_MAX_CREDENTIALS) {
/* increase tag number so that it is not recognized as duplicate */
credential.tag++;
TEST_ASSERT_EQUAL_INT(CREDMAN_OK, credman_add(&credential));
Expand Down Expand Up @@ -176,7 +176,7 @@ static void test_credman_delete_random_order(void)
};
TEST_ASSERT_EQUAL_INT(0, credman_get_used_count());

/* fill the credential pool, assume CREDMAN_MAX_CREDENTIALS is 2 */
/* fill the credential pool, assume CONFIG_CREDMAN_MAX_CREDENTIALS is 2 */
TEST_ASSERT_EQUAL_INT(CREDMAN_OK, credman_add(&in_credential));
in_credential.tag = tag2;
TEST_ASSERT_EQUAL_INT(CREDMAN_OK, credman_add(&in_credential));
Expand Down

0 comments on commit 774c18e

Please sign in to comment.