Commit 32ef1480 authored by Vinayak Chettimada's avatar Vinayak Chettimada Committed by Anas Nashif
Browse files

Bluetooth: Controller: Remove unused util functions


Change-id: I7b691d082d080239c35b63221e3c6c7aa93ed58e
Signed-off-by: default avatarVinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
parent 39410d79
No related merge requests found
Showing with 0 additions and 100 deletions
+0 -100
......@@ -18,103 +18,6 @@
#include <stdint.h>
#include "util.h"
/* Convert the integer D to a string and save the string in BUF. If
* BASE is equal to 'd', interpret that D is decimal, and if BASE is
* equal to 'x', interpret that D is hexadecimal.
*/
void util_itoa(char *buf, int base, int d)
{
char *p = buf;
char *p1, *p2;
unsigned long ud = d;
int divisor = 10;
/* If %d is specified and D is minus, put `-' in the head. */
if (base == 'd' && d < 0) {
*p++ = '-';
buf++;
ud = -d;
} else if (base == 'x')
divisor = 16;
/* Divide UD by DIVISOR until UD == 0. */
do {
int remainder = ud % divisor;
*p++ =
(remainder < 10) ? remainder + '0' : remainder + 'a' - 10;
} while (ud /= divisor);
/* Terminate BUF. */
*p = 0;
/* Reverse BUF. */
p1 = buf;
p2 = p - 1;
while (p1 < p2) {
char tmp = *p1;
*p1 = *p2;
*p2 = tmp;
p1++;
p2--;
}
}
int util_atoi(char *s)
{
int val = 0;
while (*s) {
if (*s < '0' || *s > '9')
return val;
val = (val * 10) + (*s - '0');
s++;
}
return val;
}
/* Format a string and print it on the screen, just like the libc
* function printf.
*/
void util_sprintf(char *str, const char *format, ...)
{
char **arg = (char **)&format;
int c;
char buf[20];
arg++;
while ((c = *format++)) {
if (c != '%')
*str++ = c;
else {
char *p;
c = *format++;
switch (c) {
case 'd':
case 'u':
case 'x':
util_itoa(buf, c, *((int *)arg++));
p = buf;
goto string;
case 's':
p = *arg++;
if (!p)
p = "(null)";
string:
while (*p)
*str++ = *p++;
break;
default:
*str++ = (*((int *)arg++));
break;
}
}
}
*str = 0;
}
uint8_t util_ones_count_get(uint8_t *octets, uint8_t octets_len)
{
uint8_t one_count = 0;
......
......@@ -18,9 +18,6 @@
#ifndef _UTIL_H_
#define _UTIL_H_
void util_itoa(char *buf, int base, int d);
int util_atoi(char *s);
void util_sprintf(char *str, const char *format, ...);
uint8_t util_ones_count_get(uint8_t *octets, uint8_t octets_len);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment