summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-02-13 20:31:47 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-02-13 20:31:47 +0100
commit2a17e75a976d11c1712972d29813094b8020ac35 (patch)
treeea0e991c927752937803d72a5411f7159365aa83 /lib
parenta5f75fe8175aefec5b7cefaadc5359096c8eb22c (diff)
parent7185b353c96e1e831533eeaaada06ad9bebf84a2 (diff)
downloadbarebox-2a17e75a976d11c1712972d29813094b8020ac35.tar.gz
barebox-2a17e75a976d11c1712972d29813094b8020ac35.tar.xz
Merge branch 'for-next/misc'
Diffstat (limited to 'lib')
-rw-r--r--lib/image-sparse.c2
-rw-r--r--lib/readline.c1
-rw-r--r--lib/strtox.c102
-rw-r--r--lib/unlink-recursive.c27
4 files changed, 57 insertions, 75 deletions
diff --git a/lib/image-sparse.c b/lib/image-sparse.c
index 7137d15fd0..0c31742ab6 100644
--- a/lib/image-sparse.c
+++ b/lib/image-sparse.c
@@ -60,7 +60,7 @@ struct sparse_image_ctx {
uint32_t fill_val;
};
-int sparse_seek(struct sparse_image_ctx *si)
+static int sparse_seek(struct sparse_image_ctx *si)
{
unsigned int chunk_data_sz, payload;
loff_t offs;
diff --git a/lib/readline.c b/lib/readline.c
index 904a776394..d026af1104 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -290,6 +290,7 @@ int readline(const char *prompt, char *buf, int len)
insert = !insert;
break;
case BB_KEY_ERASE_LINE:
+ case CTL_CH('u'):
BEGINNING_OF_LINE();
ERASE_TO_EOL();
break;
diff --git a/lib/strtox.c b/lib/strtox.c
index 4b601a1b39..a5b770c8ca 100644
--- a/lib/strtox.c
+++ b/lib/strtox.c
@@ -1,38 +1,56 @@
#include <common.h>
#include <linux/ctype.h>
-unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base)
+#include "kstrtox.h"
+
+/**
+ * simple_strtoull - convert a string to an unsigned long long
+ * @cp: The start of the string
+ * @endp: A pointer to the end of the parsed string will be placed here
+ * @base: The number base to use
+ *
+ * This function is obsolete. Please use kstrtoull instead.
+ */
+unsigned long long simple_strtoull(const char *cp, char **endp,
+ unsigned int base)
{
- unsigned long result = 0, value;
-
- if (*cp == '0') {
- cp++;
-
- if ((*cp == 'x') && isxdigit(cp[1])) {
- base = 16;
- cp++;
- }
-
- if (!base)
- base = 8;
- }
+ unsigned long long result;
+ unsigned int rv;
- if (!base)
- base = 10;
-
- while (isxdigit(*cp) && (value = isdigit(*cp) ?
- *cp - '0' : toupper(*cp) - 'A' + 10) < base) {
- result = result * base + value;
- cp++;
- }
+ cp = _parse_integer_fixup_radix(cp, &base);
+ rv = _parse_integer(cp, base, &result);
+ /* FIXME */
+ cp += (rv & ~KSTRTOX_OVERFLOW);
if (endp)
*endp = (char *)cp;
return result;
}
+EXPORT_SYMBOL(simple_strtoull);
+
+/**
+ * simple_strtoul - convert a string to an unsigned long
+ * @cp: The start of the string
+ * @endp: A pointer to the end of the parsed string will be placed here
+ * @base: The number base to use
+ *
+ * This function is obsolete. Please use kstrtoul instead.
+ */
+unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base)
+{
+ return simple_strtoull(cp, endp, base);
+}
EXPORT_SYMBOL(simple_strtoul);
+/**
+ * simple_strtol - convert a string to a signed long
+ * @cp: The start of the string
+ * @endp: A pointer to the end of the parsed string will be placed here
+ * @base: The number base to use
+ *
+ * This function is obsolete. Please use kstrtol instead.
+ */
long simple_strtol(const char *cp, char **endp, unsigned int base)
{
if (*cp == '-')
@@ -42,38 +60,14 @@ long simple_strtol(const char *cp, char **endp, unsigned int base)
}
EXPORT_SYMBOL(simple_strtol);
-unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)
-{
- unsigned long long result = 0, value;
-
- if (*cp == '0') {
- cp++;
-
- if ((*cp == 'x') && isxdigit(cp[1])) {
- base = 16;
- cp++;
- }
-
- if (!base)
- base = 8;
- }
-
- if (!base)
- base = 10;
-
- while (isxdigit(*cp) && (value = isdigit(*cp) ?
- *cp - '0' : toupper(*cp) - 'A' + 10) < base) {
- result = result * base + value;
- cp++;
- }
-
- if (endp)
- *endp = (char *)cp;
-
- return result;
-}
-EXPORT_SYMBOL(simple_strtoull);
-
+/**
+ * simple_strtoll - convert a string to a signed long long
+ * @cp: The start of the string
+ * @endp: A pointer to the end of the parsed string will be placed here
+ * @base: The number base to use
+ *
+ * This function is obsolete. Please use kstrtoll instead.
+ */
long long simple_strtoll(const char *cp, char **endp, unsigned int base)
{
if (*cp == '-')
diff --git a/lib/unlink-recursive.c b/lib/unlink-recursive.c
index 434fdc791b..f28c6dae5b 100644
--- a/lib/unlink-recursive.c
+++ b/lib/unlink-recursive.c
@@ -6,50 +6,37 @@
static char unlink_recursive_failedpath[PATH_MAX];
-struct data {
- int error;
-};
-
static int file_action(const char *filename, struct stat *statbuf,
void *userdata, int depth)
{
- struct data *data = userdata;
- int ret;
-
- ret = unlink(filename);
- if (ret) {
+ if (unlink(filename)) {
strcpy(unlink_recursive_failedpath, filename);
- data->error = ret;
+ return 0;
}
- return ret ? 0 : 1;
+ return 1;
}
static int dir_action(const char *dirname, struct stat *statbuf,
void *userdata, int depth)
{
- struct data *data = userdata;
- int ret;
-
- ret = rmdir(dirname);
- if (ret) {
+ if (rmdir(dirname)) {
strcpy(unlink_recursive_failedpath, dirname);
- data->error = ret;
+ return 0;
}
- return ret ? 0 : 1;
+ return 1;
}
int unlink_recursive(const char *path, char **failedpath)
{
- struct data data = {};
int ret;
if (failedpath)
*failedpath = NULL;
ret = recursive_action(path, ACTION_RECURSE | ACTION_DEPTHFIRST,
- file_action, dir_action, &data, 0);
+ file_action, dir_action, NULL, 0);
if (!ret && failedpath)
*failedpath = unlink_recursive_failedpath;