Skip to content

Commit

Permalink
common/stm32/serialno: utoa_upper: Update and document return value
Browse files Browse the repository at this point in the history
  • Loading branch information
ALTracer committed Jan 7, 2024
1 parent 5f63e54 commit 98a018f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/platforms/common/stm32/serialno.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

char serial_no[DFU_SERIAL_LENGTH];

static const char *utoa_upper(uint32_t value, char *const str, int base) __attribute__((unused));
static char *utoa_upper(uint32_t value, char *const str, int base) __attribute__((unused));

void read_serial_number(void)
{
Expand Down Expand Up @@ -73,9 +73,10 @@ void read_serial_number(void)
* @param[in] value Machine integer for conversion
* @param[out] str Pointer to caller-managed buffer write the string into
* @param[in] base Representation base between 2 and 36
* @returns NULL on error (unsupported base), or same as str
* @returns NULL on error (unsupported base), or pointer into str,
* advanced past the written part (for chaining; points to inserted NUL-terminator)
*/
static const char *utoa_upper(uint32_t value, char *const str, const int base)
static char *utoa_upper(uint32_t value, char *const str, const int base)
{
static const char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static char buf[33] = {0};
Expand Down Expand Up @@ -106,5 +107,5 @@ static const char *utoa_upper(uint32_t value, char *const str, const int base)
}
str[total + 1] = '\0';

return str;
return str + total + 1;
}

0 comments on commit 98a018f

Please sign in to comment.