函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\test_strscpy.c Create Date:2022-07-27 07:30:28
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:() - Run a specific test case.*@src: Source string, argument to strscpy_pad()*@count: Size of destination buffer, argument to strscpy_pad()*@expected: Expected return value from call to strscpy_pad()

函数原型:static int __init tc(char *src, int count, int expected, int chars, int terminator, int pad)

返回类型:int

参数:

类型参数名称
char *src
intcount
intexpected
intchars
intterminator
intpad
38  POISON等于'z'
40  Kernel module for testing 'strscpy' family of functions.自加
42  如果非src
43  打印错误信息("null source string not supported\n")
44  返回:负1
47  memset(buf, POISON, buf的长度)
49  max_count等于buf的长度减2
50  max_expected等于count减1
51  如果count大于max_count
52  打印错误信息("count (%d) is too big (%d) ... aborting", count, max_count)
53  返回:负1
55  如果expected大于max_expected
56  打印警告信息("expected (%d) is bigger than can possibly be returned (%d)", expected, max_expected)
60  written等于strscpy_pad() - Copy a C-string into a sized buffer*@dest: Where to copy the string to*@src: Where to copy the string from*@count: Size of destination buffer* Copy the string, or as much of it as fits, into the dest buffer. The
61  如果written不等于expected
62  打印错误信息("%d != %d (written, expected)\n", written, expected)
63  转到:fail
66  如果countwritten恒等于负E2BIG
67  如果字符串指定长度比较不等于0则
68  打印错误信息("buffer state invalid for -E2BIG\n")
69  转到:fail
71  如果buf[count - 1]不等于'\0'则
72  打印错误信息("too big string is not null terminated correctly\n")
73  转到:fail
77 i小于chars循环
78  如果buf[i]不等于src[i]则
79  打印错误信息("buf[i]==%c != src[i]==%c\n", buf[i], src[i])
80  转到:fail
84  如果terminator
85  如果buf[count - 1]不等于'\0'则
86  打印错误信息("string is not null terminated correctly\n")
87  转到:fail
91 i小于pad循环
92  index等于charsterminatori
93  如果buf[index]不等于'\0'则
94  打印错误信息("padding missing at index: %d\n", i)
95  转到:fail
99  nr_bytes_poison等于buf的长度减charsterminatorpad
100 i小于nr_bytes_poison循环
101  index等于buf的长度减1减i
102  如果buf[index]不等于POISON
103  打印错误信息("poison value missing at index: %d\n", i)
104  转到:fail
108  返回:0
109  fail :
110  failed_tests自加
111  返回:负1
调用者
名称描述
selftest