Skip to content

Commit

Permalink
ran the code through formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
fangfufu committed Jul 25, 2023
1 parent 6d8db94 commit 1e80844
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#define DEFAULT_NETWORK_MAX_CONNS 10

/**
* \brief The default refresh_timeout
* \brief The default refresh_timeout
*/
#define DEFAULT_REFRESH_TIMEOUT 86400
#define DEFAULT_REFRESH_TIMEOUT 86400

/**
* \brief Operation modes
Expand Down
9 changes: 3 additions & 6 deletions src/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,7 @@ static void LinkTable_invalid_reset(LinkTable *linktbl)

void LinkTable_free(LinkTable *linktbl)
{
if (linktbl)
{
if (linktbl) {
for (int i = 0; i < linktbl->num; i++) {
LinkTable_free(linktbl->links[i]->next_table);
FREE(linktbl->links[i]);
Expand Down Expand Up @@ -755,11 +754,9 @@ LinkTable *path_to_Link_LinkTable_new(const char *path)
tmp_link = link;
}

if (next_table)
{
if (next_table) {
time_t time_now = time(NULL);
if (time_now - next_table->index_time > CONFIG.refresh_timeout)
{
if (time_now - next_table->index_time > CONFIG.refresh_timeout) {
/* refresh directory contents */
LinkTable_free(next_table);
next_table = NULL;
Expand Down
35 changes: 18 additions & 17 deletions src/sonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,27 +319,28 @@ XML_parser_general(void *data, const char *elem, const char **attr)
LinkTable_add(linktbl, link);
}

static void sanitise_LinkTable(LinkTable *linktbl) {
static void sanitise_LinkTable(LinkTable *linktbl)
{
for (int i = 0; i < linktbl->num; i++) {
if (!strcmp(linktbl->links[i]->linkname, ".")) {
if (!strcmp(linktbl->links[i]->linkname, ".")) {
/* Note the super long sanitised name to avoid collision */
strcpy(linktbl->links[i]->linkname, "__DOT__");
}
strcpy(linktbl->links[i]->linkname, "__DOT__");
}

if (!strcmp(linktbl->links[i]->linkname, "/")) {
if (!strcmp(linktbl->links[i]->linkname, "/")) {
/* Ditto */
strcpy(linktbl->links[i]->linkname, "__FORWARD-SLASH__");
}

for (size_t j = 0; j < strlen(linktbl->links[i]->linkname); j++) {
if (linktbl->links[i]->linkname[j] == '/') {
linktbl->links[i]->linkname[j] = '-';
}
}

if (linktbl->links[i]->next_table != NULL) {
sanitise_LinkTable(linktbl->links[i]->next_table);
}
strcpy(linktbl->links[i]->linkname, "__FORWARD-SLASH__");
}

for (size_t j = 0; j < strlen(linktbl->links[i]->linkname); j++) {
if (linktbl->links[i]->linkname[j] == '/') {
linktbl->links[i]->linkname[j] = '-';
}
}

if (linktbl->links[i]->next_table != NULL) {
sanitise_LinkTable(linktbl->links[i]->next_table);
}
}
}

Expand Down

0 comments on commit 1e80844

Please sign in to comment.