Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 13, 2024
1 parent ef7c907 commit d1172cc
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitpicker.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"user": "torvalds",
"repo": "linux",
"branch": "8f602276d3902642fdc3429b548d73c745446601",
"branch": "36c254515dc6592c44db77b84908358979dd6b50",
"data": [
{
"root": "scripts/kconfig",
Expand Down
1 change: 1 addition & 0 deletions expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static struct expr *expr_lookup(enum expr_type type, void *l, void *r)
e->type = type;
e->left._initdata = l;
e->right._initdata = r;
e->val_is_valid = false;

hash_add(expr_hashtable, &e->node, hash);

Expand Down
50 changes: 50 additions & 0 deletions list.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,36 @@ static inline void list_del(struct list_head *entry)
entry->prev = LIST_POISON2;
}

/**
* list_replace - replace old entry by new one
* @old : the element to be replaced
* @new : the new element to insert
*
* If @old was empty, it will be overwritten.
*/
static inline void list_replace(struct list_head *old,
struct list_head *new)
{
new->next = old->next;
new->next->prev = new;
new->prev = old->prev;
new->prev->next = new;
}

/**
* list_replace_init - replace old entry by new one and initialize the old one
* @old : the element to be replaced
* @new : the new element to insert
*
* If @old was empty, it will be overwritten.
*/
static inline void list_replace_init(struct list_head *old,
struct list_head *new)
{
list_replace(old, new);
INIT_LIST_HEAD(old);
}

/**
* list_move - delete from one list and add as another's head
* @list: the entry to move
Expand All @@ -150,6 +180,26 @@ static inline void list_move_tail(struct list_head *list,
list_add_tail(list, head);
}

/**
* list_is_first -- tests whether @list is the first entry in list @head
* @list: the entry to test
* @head: the head of the list
*/
static inline int list_is_first(const struct list_head *list, const struct list_head *head)
{
return list->prev == head;
}

/**
* list_is_last - tests whether @list is the last entry in list @head
* @list: the entry to test
* @head: the head of the list
*/
static inline int list_is_last(const struct list_head *list, const struct list_head *head)
{
return list->next == head;
}

/**
* list_is_head - tests whether @list is the list @head
* @list: the entry to test
Expand Down
10 changes: 8 additions & 2 deletions parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,14 @@ config_stmt: config_entry_start config_option_list
yynerrs++;
}

list_add_tail(&current_entry->sym->choice_link,
&current_choice->choice_members);
/*
* If the same symbol appears twice in a choice block, the list
* node would be added twice, leading to a broken linked list.
* list_empty() ensures that this symbol has not yet added.
*/
if (list_empty(&current_entry->sym->choice_link))
list_add_tail(&current_entry->sym->choice_link,
&current_choice->choice_members);
}

printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno);
Expand Down

0 comments on commit d1172cc

Please sign in to comment.