Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\vsprintf.c Create Date:2022-07-28 06:11:58
Last Modify:2022-05-21 09:47:42 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name: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.

Proto:int num_to_str(char *buf, int size, unsigned long long num, unsigned int width)

Type:int

Parameter:

TypeParameterName
char *buf
intsize
unsigned long longnum
unsigned intwidth
347  char tmp[ size of 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  If num <= 9 Then
352  tmp[0] = '0' + num
353  len = 1
354  Else
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  If len > size || width > size Then Return 0
361  If width > len Then
362  width = width - len
363  When idx < width cycle buf[idx] = ' '
365  Else
366  width = 0
369  When idx < len cycle buf[idx + width] = tmp[len - idx - 1]
372  Return len + width
Caller
NameDescribe
seq_put_decimal_ll