openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libnl/1_3.4.0-r0/libnl-3.4.0/lib/utils.c
char* nl_size2str(const size_t size, char* buf, const size_t len)
{
    size_t i;

    if (size == 0)
    {
        snprintf(buf, len, "0B");
        return buf;
    }

    for (i = 0; i < ARRAY_SIZE(size_units); i++)
    {
        if (size >= size_units[i].limit)
        {
            snprintf(buf, len, "%.2g%s", (double)size / size_units[i].limit,
                     size_units[i].unit);
            return buf;
        }
    }

    BUG();
}
/**
 * Convert a size toa character string
 * @arg size		Size in number of bytes
 * @arg buf		Buffer to write character string to
 * @arg len		Size of buf
 *
 * This function converts a value in bytes to a human readable representation
 * of it. The function uses IEC prefixes:
 *
 * @code
 * 1024 bytes => 1 KiB
 * 1048576 bytes => 1 MiB
 * @endcode
 *
 * The highest prefix is used which ensures a result of >= 1.0, the result
 * is provided as floating point number with a maximum precision of 2 digits:
 * @code
 * 965176 bytes => 942.55 KiB
 * @endcode
 *
 * @return pointer to buf
 */
Convert a size toa character string
@arg size            Size in number of bytes
@arg buf             Buffer to write character string to
@arg len             Size of buf

This function converts a value in bytes to a human readable representation
of it. The function uses IEC prefixes.



The highest prefix is used which ensures a result of >= 1.0, the result
is provided as floating point number with a maximum precision of 2 digits:
@code
965176 bytes => 942.55 KiB
@endcode

@return pointer to buf
Convert a size toa character string @arg size Size in number of bytes @arg buf Buffer to write character string to @arg len Size of buf This function converts a value in bytes to a human readable representation of it . The function uses IEC prefixes . The highest prefix is used which ensures a result of > = 1 . 0 the result is provided as floating point number with a maximum precision of 2 digits : @code 965176 bytes = > 942 . 55 KiB @endcode @return pointer to buf
char* nl_size2str(const size_t size, char* buf, const size_t len)
{
    size_t i;
    if (size == 0)
    {
        snprintf(buf, len, "0B");
        return buf;
    }
    for (i = 0; i < ARRAY_SIZE(size_units); i++)
    {
        if (size >= size_units[i].limit)
        {
            snprintf(buf, len, "%.2g%s", (double)size / size_units[i].limit,
                     size_units[i].unit);
            return buf;
        }
    }
    BUG();
}
char * nl_size2str ( const size_t size , char * buf , const size_t len ) { size_t i ; if ( size == 0 ) { snprintf ( buf , len , " " ) ; return buf ; } for ( i = 0 ; i < ARRAY_SIZE ( size_units ) ; i ++ ) { if ( size >= size_units [ i ] . limit ) { snprintf ( buf , len , " " , ( double ) size / size_units [ i ] . limit , size_units [ i ] . unit ) ; return buf ; } } BUG ( ) ; }
Convert a size toa character string
 @arg size            Size in number of bytes
 @arg buf             Buffer to write character string to
 @arg len             Size of buf
Convert a size toa character string @arg size Size in number of bytes @arg buf Buffer to write character string to @arg len Size of buf