函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\vsprintf.c Create Date:2022-07-27 07:09:15
Last Modify:2022-05-21 09:47:42 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:Convert passed number to decimal string.* Returns the length of string. On buffer overflow, returns 0.* If speed is not important, use snprintf(). It's easy to read the code.

函数原型:int num_to_str(char *buf, int size, unsigned long long num, unsigned int width)

返回类型:int

参数:

类型参数名称
char *buf
intsize
unsigned long longnum
unsigned intwidth
347  char tmp[num的长度 * 3] gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-aligned-function-attribute* gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-aligned-type-attribute* gcc: https://gcc(2)
351  如果num小于等于9则
352  tmp[0]等于'0'加num
353  len等于1
354  否则
355  len等于Based on code by Douglas W. Jones found at* * (with permission from the author).* Performs no 64-bit division and hence should be fast on 32-bit machines.tmp
358  如果len大于sizewidth大于size则返回:0
361  如果width大于len
362  width等于widthlen
363 idx小于width循环buf[idx]等于' '
365  否则
366  width等于0
369 idx小于len循环buf[idx + width]等于tmp[len - idx - 1]
372  返回:lenwidth
调用者
名称描述
seq_put_decimal_ll
seq_put_decimal_ull_widthA helper routine for putting decimal numbers without rich format of printf()