mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-27 03:33:50 +00:00
Reformat to kernel style
No code changes, just reformatting. BUG=none BRANCH=none TEST=make runtests Change-Id: Id690c8334147970784db5ac54933ad1f5a58dcc1 Reviewed-on: https://gerrit.chromium.org/gerrit/42263 Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
committed by
ChromeBot
parent
49cb0d3471
commit
7993f257af
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
||||
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*
|
||||
@@ -10,62 +10,64 @@
|
||||
|
||||
|
||||
uint32_t Uint64ToString(char *buf, uint32_t bufsize, uint64_t value,
|
||||
uint32_t radix, uint32_t zero_pad_width) {
|
||||
char ibuf[UINT64_TO_STRING_MAX];
|
||||
char *s;
|
||||
uint32_t usedsize = 1;
|
||||
uint32_t radix, uint32_t zero_pad_width)
|
||||
{
|
||||
char ibuf[UINT64_TO_STRING_MAX];
|
||||
char *s;
|
||||
uint32_t usedsize = 1;
|
||||
|
||||
if (!buf)
|
||||
return 0;
|
||||
if (!buf)
|
||||
return 0;
|
||||
|
||||
/* Clear output buffer in case of error */
|
||||
*buf = '\0';
|
||||
/* Clear output buffer in case of error */
|
||||
*buf = '\0';
|
||||
|
||||
/* Sanity-check input args */
|
||||
if (radix < 2 || radix > 36 || zero_pad_width >= UINT64_TO_STRING_MAX)
|
||||
return 0;
|
||||
/* Sanity-check input args */
|
||||
if (radix < 2 || radix > 36 || zero_pad_width >= UINT64_TO_STRING_MAX)
|
||||
return 0;
|
||||
|
||||
/* Start at end of string and work backwards */
|
||||
s = ibuf + UINT64_TO_STRING_MAX - 1;
|
||||
*(s) = '\0';
|
||||
do {
|
||||
int v = value % radix;
|
||||
value /= radix;
|
||||
/* Start at end of string and work backwards */
|
||||
s = ibuf + UINT64_TO_STRING_MAX - 1;
|
||||
*(s) = '\0';
|
||||
do {
|
||||
int v = value % radix;
|
||||
value /= radix;
|
||||
|
||||
*(--s) = (char)(v < 10 ? v + '0' : v + 'a' - 10);
|
||||
if (++usedsize > bufsize)
|
||||
return 0; /* Result won't fit in buffer */
|
||||
} while (value);
|
||||
*(--s) = (char)(v < 10 ? v + '0' : v + 'a' - 10);
|
||||
if (++usedsize > bufsize)
|
||||
return 0; /* Result won't fit in buffer */
|
||||
} while (value);
|
||||
|
||||
/* Zero-pad if necessary */
|
||||
while (usedsize <= zero_pad_width) {
|
||||
*(--s) = '0';
|
||||
if (++usedsize > bufsize)
|
||||
return 0; /* Result won't fit in buffer */
|
||||
}
|
||||
/* Zero-pad if necessary */
|
||||
while (usedsize <= zero_pad_width) {
|
||||
*(--s) = '0';
|
||||
if (++usedsize > bufsize)
|
||||
return 0; /* Result won't fit in buffer */
|
||||
}
|
||||
|
||||
/* Now copy the string back to the input buffer. */
|
||||
Memcpy(buf, s, usedsize);
|
||||
/* Now copy the string back to the input buffer. */
|
||||
Memcpy(buf, s, usedsize);
|
||||
|
||||
/* Don't count the terminating null in the bytes used */
|
||||
return usedsize - 1;
|
||||
/* Don't count the terminating null in the bytes used */
|
||||
return usedsize - 1;
|
||||
}
|
||||
|
||||
uint32_t Strncat(char *dest, const char *src, uint32_t destlen)
|
||||
{
|
||||
uint32_t used = 0;
|
||||
|
||||
uint32_t Strncat(char *dest, const char *src, uint32_t destlen) {
|
||||
uint32_t used = 0;
|
||||
if (!dest || !src)
|
||||
return 0;
|
||||
|
||||
if (!dest || !src)
|
||||
return 0;
|
||||
/* Skip past existing string in destination.*/
|
||||
while (dest[used] && used < destlen - 1)
|
||||
used++;
|
||||
|
||||
/* Skip past existing string in destination.*/
|
||||
while (dest[used] && used < destlen - 1)
|
||||
used++;
|
||||
/* Now copy source */
|
||||
while (*src && used < destlen - 1)
|
||||
dest[used++] = *src++;
|
||||
/* Now copy source */
|
||||
while (*src && used < destlen - 1)
|
||||
dest[used++] = *src++;
|
||||
|
||||
/* Terminate destination and return count of non-null characters */
|
||||
dest[used] = 0;
|
||||
return used;
|
||||
/* Terminate destination and return count of non-null characters */
|
||||
dest[used] = 0;
|
||||
return used;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user