Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Helper function to decode printf style format

Proto:static __attribute__((__noinline__)) int format_decode(const char *fmt, struct printf_spec *spec)

Type:int

Parameter:

TypeParameterName
const char *fmt
struct printf_spec *spec
2284  start = fmt
2288  If format_type enum == FORMAT_TYPE_WIDTH Then
2289  If width of output field < 0 Then
2293  format_type enum = Just a string part
2294  Go to precision
2298  If format_type enum == FORMAT_TYPE_PRECISION Then
2299  If # of digits/chars < 0 Then # of digits/chars = 0
2302  format_type enum = Just a string part
2303  Go to qualifier
2307  format_type enum = Just a string part
2309  When fmt cycle
2310  If fmt == '%' Then Break
2315  If fmt != start || Not fmt Then Return fmt - start
2319  flags to number() = 0
2321  When 1 cycle
2322  bool found = true
2324  ++fmt
2327  Case fmt == '-'
2327  Break
2328  Case fmt == '+'
2328  Break
2329  Case fmt == ' '
2329  Break
2330  Case fmt == '#'
2330  Break
2331  Case fmt == '0'
2331  Break
2332  Default
2332  found = false
2335  If Not found Then Break
2340  width of output field = -1
2342  If isdigit( * fmt) Then width of output field = -*- linux-c -*- ------------------------------------------------------- ** Copyright (C) 1991, 1992 Linus Torvalds* Copyright 2007 rPath, Inc. - All Rights Reserved* -----------------------------------------------------------------------
2344  Else if fmt == '*' Then
2346  format_type enum = FORMAT_TYPE_WIDTH
2347  Return ++fmt - start
2350  precision :
2352  # of digits/chars = -1
2353  If fmt == '.' Then
2354  ++fmt
2355  If isdigit( * fmt) Then
2359  Else if fmt == '*' Then
2362  Return ++fmt - start
2366  qualifier :
2368  qualifier = 0
2369  If fmt == 'h' || Fast implementation of tolower() for internal usage. Do not use in your* code. == 'l' || fmt == 'z' || fmt == 't' Then
2371  qualifier = fmt++
2373  If qualifier == 'l' Then
2374  qualifier = 'L'
2375  ++fmt
2376  Else if qualifier == 'h' Then
2377  qualifier = 'H'
2378  ++fmt
2384  number base, 8, 10 or 16 only = 10
2386  Case fmt == 'c'
2387  format_type enum = FORMAT_TYPE_CHAR
2388  Return ++fmt - start
2390  Case fmt == 's'
2391  format_type enum = FORMAT_TYPE_STR
2392  Return ++fmt - start
2394  Case fmt == 'p'
2395  format_type enum = FORMAT_TYPE_PTR
2396  Return ++fmt - start
2398  Case fmt == '%'
2399  format_type enum = FORMAT_TYPE_PERCENT_CHAR
2400  Return ++fmt - start
2403  Case fmt == 'o'
2404  number base, 8, 10 or 16 only = 8
2405  Break
2407  Case fmt == 'x'
2408  flags to number() |= use lowercase in hex (must be 32 == 0x20)
2411  Case fmt == 'X'
2412  number base, 8, 10 or 16 only = 16
2413  Break
2415  Case fmt == 'd'
2416  Case fmt == 'i'
2417  flags to number() |= unsigned/signed, must be 1
2418  Case fmt == 'u'
2419  Break
2421  Case fmt == 'n'
2429  Default
2430  WARN_ONCE(1, "Please remove unsupported %%%c in format string\n", * fmt)
2431  format_type enum = FORMAT_TYPE_INVALID
2432  Return fmt - start
2435  If qualifier == 'L' Then format_type enum = FORMAT_TYPE_LONG_LONG
2437  Else if qualifier == 'l' Then
2438  BUILD_BUG_ON - break compile if a condition is true(FORMAT_TYPE_ULONG + unsigned/signed, must be 1 != FORMAT_TYPE_LONG)
2439  format_type enum = FORMAT_TYPE_ULONG + ( flags to number() & unsigned/signed, must be 1 )
2440  Else if qualifier == 'z' Then
2441  format_type enum = FORMAT_TYPE_SIZE_T
2442  Else if qualifier == 't' Then
2443  format_type enum = FORMAT_TYPE_PTRDIFF
2444  Else if qualifier == 'H' Then
2445  BUILD_BUG_ON - break compile if a condition is true(FORMAT_TYPE_UBYTE + unsigned/signed, must be 1 != FORMAT_TYPE_BYTE)
2446  format_type enum = FORMAT_TYPE_UBYTE + ( flags to number() & unsigned/signed, must be 1 )
2447  Else if qualifier == 'h' Then
2448  BUILD_BUG_ON - break compile if a condition is true(FORMAT_TYPE_USHORT + unsigned/signed, must be 1 != FORMAT_TYPE_SHORT)
2449  format_type enum = FORMAT_TYPE_USHORT + ( flags to number() & unsigned/signed, must be 1 )
2450  Else
2451  BUILD_BUG_ON - break compile if a condition is true(FORMAT_TYPE_UINT + unsigned/signed, must be 1 != FORMAT_TYPE_INT)
2452  format_type enum = FORMAT_TYPE_UINT + ( flags to number() & unsigned/signed, must be 1 )
2455  Return ++fmt - start
Caller
NameDescribe
vsnprintfvsnprintf - 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*@args: Arguments for the format string* This function generally