Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\test_list_sort.c Create Date:2022-07-28 06:29:49
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:list_sort_test

Proto:static int __init list_sort_test(void)

Type:int

Parameter:Nothing

72  count = 1 , err = -ENOMEM
75  LIST_HEAD(head)
77  pr_debug("start testing list_sort()\n")
79  Array, containing pointers to all elements in the test list = kcalloc - allocate memory for an array. The memory is set to zero.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
80  If Not Array, containing pointers to all elements in the test list Then Return err
83  When i < including head cycle
84  el = kmalloc( size of el , GFP_KERNEL)
85  If Not el Then Go to exit
89  value = prandom_u32() % including head / 3
90  serial = i
91  poison1 = TEST_POISON1
92  poison2 = TEST_POISON2
93  Array, containing pointers to all elements in the test list [i] = el
94  list_add_tail - add a new entry*@new: new entry to be added*@head: list head to add it before* Insert a new entry before the specified head.* This is useful for implementing queues.
97  list_sort - sort a list*@priv: private data, opaque to list_sort(), passed to @cmp*@head: the list to sort*@cmp: the elements comparison function* The comparison funtion @cmp must return > 0 if @a should sort after*@b ("@a > @b" if you want an ascending
99  err = -EINVAL
100  When next != head cycle
104  If prev != cur Then
105  pr_err("error: list is corrupted\n")
106  Go to exit
109  cmp_result = cmp(NULL, cur, next)
110  If cmp_result > 0 Then
111  pr_err("error: list is not sorted\n")
112  Go to exit
115  el = container_of - cast a member of a structure out to the containing structure*@ptr: the pointer to the member.*@type: the type of the container struct this is embedded in.*@member: the name of the member within the struct.(cur, structdebug_el, list)
116  el1 = container_of - cast a member of a structure out to the containing structure*@ptr: the pointer to the member.*@type: the type of the container struct this is embedded in.*@member: the name of the member within the struct.(next, structdebug_el, list)
117  If cmp_result == 0 && serial >= serial Then
118  pr_err("error: order of equivalent elements not preserved\n")
120  Go to exit
123  If check(el, el1) Then
124  pr_err("error: element check failed\n")
125  Go to exit
127  count++
129  If prev != cur Then
130  pr_err("error: list is corrupted\n")
131  Go to exit
135  If count != including head Then
136  pr_err("error: bad list length %d", count)
137  Go to exit
140  err = 0
141  exit :
142  When i < including head cycle kfree(Array, containing pointers to all elements in the test list [i])
144  kfree(Array, containing pointers to all elements in the test list )
145  Return err