函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:string_get_size - get the size in the specified units*@size: The size to be converted in blocks*@blk_size: Size of the block (use 1 for size in bytes)*@units: units to use (powers of 1000 or 1024)*@buf: buffer to format to*@len: length of buffer* This

函数原型:void string_get_size(u64 size, u64 blk_size, const enum string_size_units units, char *buf, int len)

返回类型:void

参数:

类型参数名称
u64size
u64blk_size
const enum string_size_unitsunits
char *buf
intlen
37  static const char * const units_10[] = {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}
40  static const char * const units_2[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}
43  static const char * const * const units_str[] = {[use powers of 10^3 (standard SI) ] = units_10, [use binary powers of 2^10 ] = units_2, }
47  static const unsigned int divisor[] = {[use powers of 10^3 (standard SI) ] = 1000, [use binary powers of 2^10 ] = 1024, }
51  static const unsigned int rounding[] = {500, 50, 5}
52  i等于0
53  remainder等于0
57  tmp[0]等于'\0'
59  如果blk_size恒等于0则size等于0
61  如果size恒等于0则转到:out
75 blk_size右移32位循环
76  do_div() is NOT a C function(blk_size, divisor[units])
77  i自加
80 size右移32位循环
81  do_div() is NOT a C function(size, divisor[units])
82  i自加
87  size乘等于blk_size
90 size大于等于divisor[units]循环
91  remainder等于do_div() is NOT a C function(size, divisor[units])
92  i自加
97  sf_cap等于size
98 sf_cap乘10小于1000循环sf_cap乘等于10
101  如果units恒等于use binary powers of 2^10
105  remainder乘等于1000
106  remainder右移等于10位
111  remainder加等于rounding[j]
112  如果remainder大于等于1000则
113  remainder减等于1000
114  size加等于1
117  如果j
118  snprintf - Format a string and place it in a buffer*@buf: The buffer to place the result into*@size: The size of the buffer, including the trailing null space*@fmt: The format string to use*@
119  tmp[j + 1]等于'\0'
122  out :
123  如果i大于等于ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(units_2)则unit等于"UNK"
125  否则unit等于units_str[units][i]
128  snprintf - Format a string and place it in a buffer*@buf: The buffer to place the result into*@size: The size of the buffer, including the trailing null space*@fmt: The format string to use*@
调用者
名称描述
__test_string_get_size
report_hugepages
hugetlb_hstate_alloc_pages