* [PATCH] libbb: Drop simple_itoa()
@ 2019-05-28 5:52 Andrey Smirnov
2019-05-28 8:18 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Andrey Smirnov @ 2019-05-28 5:52 UTC (permalink / raw)
To: barebox; +Cc: Andrey Smirnov
Hush is the only one user of simple_itoa() and the code there can be
re-implemented using snprintf(). Change the code to get rid of
simple_itoa().
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
common/hush.c | 7 ++++++-
include/libbb.h | 2 --
lib/libbb.c | 14 --------------
3 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/common/hush.c b/common/hush.c
index dab9b0408..68c3eccdf 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -402,7 +402,12 @@ static void b_free(o_string *o)
static int b_adduint(o_string *o, unsigned int i)
{
int r;
- char *p = simple_itoa(i);
+ /* 21 digits plus null terminator, good for 64-bit or smaller
+ * ints */
+ char number[22];
+ char *p = number;
+
+ snprintf(number, sizeof(number), "%u", i);
/* no escape checking necessary */
do {
diff --git a/include/libbb.h b/include/libbb.h
index 1f6afaa27..d05c19063 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -29,6 +29,4 @@ char * safe_strncpy(char *dst, const char *src, size_t size);
int process_escape_sequence(const char *source, char *dest, int destlen);
-char *simple_itoa(unsigned int i);
-
#endif /* __LIBBB_H */
diff --git a/lib/libbb.c b/lib/libbb.c
index 239611c27..d0c9bf4d8 100644
--- a/lib/libbb.c
+++ b/lib/libbb.c
@@ -112,17 +112,3 @@ char * safe_strncpy(char *dst, const char *src, size_t size)
return strncpy(dst, src, size);
}
EXPORT_SYMBOL(safe_strncpy);
-
-char *simple_itoa(unsigned int i)
-{
- /* 21 digits plus null terminator, good for 64-bit or smaller ints */
- static char local[22];
- char *p = &local[21];
- *p-- = '\0';
- do {
- *p-- = '0' + i % 10;
- i /= 10;
- } while (i > 0);
- return p + 1;
-}
-EXPORT_SYMBOL(simple_itoa);
--
2.21.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libbb: Drop simple_itoa()
2019-05-28 5:52 [PATCH] libbb: Drop simple_itoa() Andrey Smirnov
@ 2019-05-28 8:18 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2019-05-28 8:18 UTC (permalink / raw)
To: Andrey Smirnov; +Cc: barebox
On Mon, May 27, 2019 at 10:52:57PM -0700, Andrey Smirnov wrote:
> Hush is the only one user of simple_itoa() and the code there can be
> re-implemented using snprintf(). Change the code to get rid of
> simple_itoa().
>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> common/hush.c | 7 ++++++-
> include/libbb.h | 2 --
> lib/libbb.c | 14 --------------
> 3 files changed, 6 insertions(+), 17 deletions(-)
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-28 8:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-28 5:52 [PATCH] libbb: Drop simple_itoa() Andrey Smirnov
2019-05-28 8:18 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox