summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/blspec.c34
-rw-r--r--common/bootargs.c6
-rw-r--r--common/console.c22
-rw-r--r--common/console_common.c18
-rw-r--r--common/console_countdown.c2
-rw-r--r--common/console_simple.c6
-rw-r--r--common/env.c2
-rw-r--r--common/environment.c5
-rw-r--r--common/firmware.c2
-rw-r--r--common/globalvar.c9
-rw-r--r--common/imd.c4
-rw-r--r--common/imx-bbu-nand-fcb.c1
-rw-r--r--common/menutree.c6
-rw-r--r--common/partitions.c2
-rw-r--r--common/partitions/efi.c1
-rw-r--r--common/password.c3
-rw-r--r--common/startup.c1
-rw-r--r--common/state.c5
-rw-r--r--common/uimage.c1
19 files changed, 67 insertions, 63 deletions
diff --git a/common/blspec.c b/common/blspec.c
index ac8f512891..bf98e6b29a 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -203,16 +203,18 @@ static char *parse_nfs_url(const char *url)
if (ip == 0)
goto out;
- hostpath = asprintf("%s:%s", ip_to_string(ip), path);
+ hostpath = basprintf("%s:%s", ip_to_string(ip), path);
prevpath = nfs_find_mountpath(hostpath);
if (prevpath) {
mountpath = xstrdup(prevpath);
} else {
- mountpath = asprintf("/mnt/nfs-%s-blspec-%08x", host, rand());
+ mountpath = basprintf("/mnt/nfs-%s-blspec-%08x", host,
+ rand());
if (port)
- options = asprintf("mountport=%s,port=%s", port, port);
+ options = basprintf("mountport=%s,port=%s", port,
+ port);
ret = make_directory(mountpath);
if (ret)
@@ -278,7 +280,7 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
if (!strcmp(devicetree, "none"))
return true;
- filename = asprintf("%s/%s", abspath, devicetree);
+ filename = basprintf("%s/%s", abspath, devicetree);
fdt = read_file(filename, &size);
if (!fdt) {
@@ -338,7 +340,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
entry_default = read_file_line("%s/default", root);
entry_once = read_file_line("%s/once", root);
- abspath = asprintf("%s/%s", root, dirname);
+ abspath = basprintf("%s/%s", root, dirname);
dir = opendir(abspath);
if (!dir) {
@@ -356,7 +358,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
if (*d->d_name == '.')
continue;
- configname = asprintf("%s/%s", abspath, d->d_name);
+ configname = basprintf("%s/%s", abspath, d->d_name);
dot = strrchr(configname, '.');
if (!dot) {
@@ -402,7 +404,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
found++;
- name = asprintf("%s/%s", dirname, d->d_name);
+ name = basprintf("%s/%s", dirname, d->d_name);
if (entry_default && !strcmp(name, entry_default))
entry->boot_default = true;
if (entry_once && !strcmp(name, entry_once))
@@ -415,10 +417,10 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
hwdevname = xstrdup(dev_name(entry->cdev->dev->parent));
}
- entry->me.display = asprintf("%-20s %-20s %s",
- devname ? devname : "",
- hwdevname ? hwdevname : "",
- blspec_entry_var_get(entry, "title"));
+ entry->me.display = basprintf("%-20s %-20s %s",
+ devname ? devname : "",
+ hwdevname ? hwdevname : "",
+ blspec_entry_var_get(entry, "title"));
free(devname);
free(hwdevname);
@@ -669,7 +671,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
else
abspath = "";
- data.os_file = asprintf("%s/%s", abspath, linuximage);
+ data.os_file = basprintf("%s/%s", abspath, linuximage);
if (devicetree) {
if (!strcmp(devicetree, "none")) {
@@ -677,13 +679,13 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
if (node)
of_delete_node(node);
} else {
- data.oftree_file = asprintf("%s/%s", abspath,
- devicetree);
+ data.oftree_file = basprintf("%s/%s", abspath,
+ devicetree);
}
}
if (initrd)
- data.initrd_file = asprintf("%s/%s", abspath, initrd);
+ data.initrd_file = basprintf("%s/%s", abspath, initrd);
globalvar_add_simple("linux.bootargs.dyn.blspec", options);
@@ -704,7 +706,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
entry->cdev ? dev_name(entry->cdev->dev) : "none");
if (entry->boot_once) {
- char *s = asprintf("%s/once", abspath);
+ char *s = basprintf("%s/once", abspath);
ret = unlink(s);
if (ret)
diff --git a/common/bootargs.c b/common/bootargs.c
index 803736fc94..a89f23a3f2 100644
--- a/common/bootargs.c
+++ b/common/bootargs.c
@@ -53,7 +53,8 @@ const char *linux_bootargs_get(void)
parts = globalvar_get_match("linux.mtdparts.", ";");
if (strlen(parts)) {
- bootargs = asprintf("%s mtdparts=%s", linux_bootargs, parts);
+ bootargs = basprintf("%s mtdparts=%s", linux_bootargs,
+ parts);
free(linux_bootargs);
free(parts);
linux_bootargs = bootargs;
@@ -61,7 +62,8 @@ const char *linux_bootargs_get(void)
parts = globalvar_get_match("linux.blkdevparts.", ";");
if (strlen(parts)) {
- bootargs = asprintf("%s blkdevparts=%s", linux_bootargs, parts);
+ bootargs = basprintf("%s blkdevparts=%s", linux_bootargs,
+ parts);
free(linux_bootargs);
free(parts);
linux_bootargs = bootargs;
diff --git a/common/console.c b/common/console.c
index a541892583..a67f169b42 100644
--- a/common/console.c
+++ b/common/console.c
@@ -164,7 +164,7 @@ int console_set_baudrate(struct console_device *cdev, unsigned baudrate)
if (cdev->f_active) {
mdelay(50);
do {
- c = getc();
+ c = getchar();
} while (c != '\r' && c != '\n');
}
@@ -208,8 +208,8 @@ static void console_set_stdoutpath(struct console_device *cdev)
if (id < 0)
return;
- str = asprintf("console=%s%d,%dn8", cdev->linux_console_name,
- id, cdev->baudrate);
+ str = basprintf("console=%s%d,%dn8", cdev->linux_console_name, id,
+ cdev->baudrate);
globalvar_add_simple("linux.bootargs.console", str);
@@ -345,7 +345,7 @@ static int tstc_raw(void)
return 0;
}
-int getc(void)
+int getchar(void)
{
unsigned char ch;
uint64_t start;
@@ -380,17 +380,7 @@ int getc(void)
return ch;
}
-EXPORT_SYMBOL(getc);
-
-int fgetc(int fd)
-{
- char c;
-
- if (!fd)
- return getc();
- return read(fd, &c, 1);
-}
-EXPORT_SYMBOL(fgetc);
+EXPORT_SYMBOL(getchar);
int tstc(void)
{
@@ -476,7 +466,7 @@ int ctrlc (void)
{
poller_call();
- if (tstc() && getc() == 3)
+ if (tstc() && getchar() == 3)
return 1;
return 0;
}
diff --git a/common/console_common.c b/common/console_common.c
index a9bbce9a28..2e5869fab0 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -278,7 +278,7 @@ EXPORT_SYMBOL(console_get_first_active);
#endif /* !CONFIG_CONSOLE_NONE */
-int fprintf(int file, const char *fmt, ...)
+int dprintf(int file, const char *fmt, ...)
{
va_list args;
char printbuffer[CFG_PBSIZE];
@@ -293,30 +293,30 @@ int fprintf(int file, const char *fmt, ...)
va_end(args);
/* Print the string */
- return fputs(file, printbuffer);
+ return dputs(file, printbuffer);
}
-EXPORT_SYMBOL(fprintf);
+EXPORT_SYMBOL(dprintf);
-int fputs(int fd, const char *s)
+int dputs(int fd, const char *s)
{
if (fd == 1)
return puts(s);
else if (fd == 2)
- return eputs(s);
+ return console_puts(CONSOLE_STDERR, s);
else
return write(fd, s, strlen(s));
}
-EXPORT_SYMBOL(fputs);
+EXPORT_SYMBOL(dputs);
-int fputc(int fd, char c)
+int dputc(int fd, char c)
{
if (fd == 1)
putchar(c);
else if (fd == 2)
- eputc(c);
+ console_putc(CONSOLE_STDERR, c);
else
return write(fd, &c, 1);
return 0;
}
-EXPORT_SYMBOL(fputc);
+EXPORT_SYMBOL(dputc);
diff --git a/common/console_countdown.c b/common/console_countdown.c
index ffbdb4fa2d..c0c8c95022 100644
--- a/common/console_countdown.c
+++ b/common/console_countdown.c
@@ -39,7 +39,7 @@ int console_countdown(int timeout_s, unsigned flags, char *out_key)
do {
if (tstc()) {
- key = getc();
+ key = getchar();
if (flags & CONSOLE_COUNTDOWN_ANYKEY)
goto out;
if (flags & CONSOLE_COUNTDOWN_RETURN && key == '\n')
diff --git a/common/console_simple.c b/common/console_simple.c
index 69e76593ad..9675cbb0a6 100644
--- a/common/console_simple.c
+++ b/common/console_simple.c
@@ -48,13 +48,13 @@ int tstc(void)
}
EXPORT_SYMBOL(tstc);
-int getc(void)
+int getchar(void)
{
if (!console)
return -EINVAL;
return console->getc(console);
}
-EXPORT_SYMBOL(getc);
+EXPORT_SYMBOL(getchar);
void console_flush(void)
{
@@ -67,7 +67,7 @@ EXPORT_SYMBOL(console_flush);
/* test if ctrl-c was pressed */
int ctrlc (void)
{
- if (tstc() && getc() == 3)
+ if (tstc() && getchar() == 3)
return 1;
return 0;
}
diff --git a/common/env.c b/common/env.c
index d6cab52a4b..6f736d5add 100644
--- a/common/env.c
+++ b/common/env.c
@@ -261,7 +261,7 @@ EXPORT_SYMBOL(export);
void export_env_ull(const char *name, unsigned long long val)
{
- char *valstr = asprintf("%llu", val);
+ char *valstr = basprintf("%llu", val);
setenv(name, valstr);
export(name);
diff --git a/common/environment.c b/common/environment.c
index be102db3d2..c3ad25266a 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -29,6 +29,7 @@
#include <malloc.h>
#include <errno.h>
#include <fs.h>
+#include <crc.h>
#include <fcntl.h>
#include <envfs.h>
#include <xfuncs.h>
@@ -79,7 +80,7 @@ static int do_compare_file(const char *filename, const char *base)
char *cmp;
const char *relname = filename + strlen(base) + 1;
- cmp = asprintf("%s/%s", TMPDIR, relname);
+ cmp = basprintf("%s/%s", TMPDIR, relname);
ret = compare_file(cmp, filename);
free(cmp);
@@ -193,7 +194,7 @@ static int file_remove_action(const char *filename, struct stat *statbuf,
filename += sizeof(TMPDIR) - 1;
- envname = asprintf("%s/%s", data->base, filename);
+ envname = basprintf("%s/%s", data->base, filename);
ret = stat(envname, &s);
if (ret) {
diff --git a/common/firmware.c b/common/firmware.c
index a6f75bf887..664f9107d0 100644
--- a/common/firmware.c
+++ b/common/firmware.c
@@ -202,7 +202,7 @@ out:
int firmwaremgr_load_file(struct firmware_mgr *mgr, const char *firmware)
{
int ret;
- char *name = asprintf("/dev/%s", mgr->handler->id);
+ char *name = basprintf("/dev/%s", mgr->handler->id);
ret = copy_file(firmware, name, 0);
diff --git a/common/globalvar.c b/common/globalvar.c
index 05c3e798d7..5dad4f6a45 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -52,7 +52,7 @@ static int nv_save(const char *name, const char *val)
if (ret)
return ret;
- fname = asprintf("/env/nv/%s", name);
+ fname = basprintf("/env/nv/%s", name);
fd = open(fname, O_CREAT | O_WRONLY | O_TRUNC);
@@ -61,7 +61,7 @@ static int nv_save(const char *name, const char *val)
if (fd < 0)
return fd;
- fprintf(fd, "%s", val);
+ dprintf(fd, "%s", val);
close(fd);
@@ -145,7 +145,7 @@ int nvvar_remove(const char *name)
if (!p)
return -ENOENT;
- fname = asprintf("/env/nv/%s", p->name);
+ fname = basprintf("/env/nv/%s", p->name);
unlink(fname);
free(fname);
@@ -227,7 +227,8 @@ char *globalvar_get_match(const char *match, const char *separator)
if (!strncmp(match, param->name, strlen(match))) {
const char *p = dev_get_param(&global_device, param->name);
if (val) {
- char *new = asprintf("%s%s%s", val, separator, p);
+ char *new = basprintf("%s%s%s", val,
+ separator, p);
free(val);
val = new;
} else {
diff --git a/common/imd.c b/common/imd.c
index 241ebbdaed..159b73a828 100644
--- a/common/imd.c
+++ b/common/imd.c
@@ -306,7 +306,7 @@ int imd_command(int argc, char *argv[])
case 't':
type = imd_name_to_type(optarg);
if (type == IMD_TYPE_INVALID) {
- fprintf(stderr, "no such type: %s\n", optarg);
+ eprintf("no such type: %s\n", optarg);
return -ENOSYS;
}
break;
@@ -325,7 +325,7 @@ int imd_command(int argc, char *argv[])
}
if (optind == argc) {
- fprintf(stderr, "No image given\n");
+ eprintf("No image given\n");
return -ENOSYS;
}
diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
index 04c6e6050c..1ffa79d1ec 100644
--- a/common/imx-bbu-nand-fcb.c
+++ b/common/imx-bbu-nand-fcb.c
@@ -34,6 +34,7 @@
#include <linux/mtd/nand.h>
#include <linux/stat.h>
#include <io.h>
+#include <crc.h>
#include <mach/generic.h>
#include <mtd/mtd-peb.h>
diff --git a/common/menutree.c b/common/menutree.c
index 97e628de88..eb14da0d01 100644
--- a/common/menutree.c
+++ b/common/menutree.c
@@ -12,9 +12,11 @@
#include <environment.h>
#include <libbb.h>
#include <common.h>
+#include <command.h>
#include <glob.h>
#include <menu.h>
#include <fs.h>
+#include <shell.h>
#include <libfile.h>
#include <linux/stat.h>
@@ -96,7 +98,7 @@ int menutree(const char *path, int toplevel)
menu = menu_alloc();
- globpath = asprintf("%s/*", path);
+ globpath = basprintf("%s/*", path);
ret = glob(globpath, 0, NULL, &g);
free(globpath);
if (ret == GLOB_NOMATCH) {
@@ -147,7 +149,7 @@ int menutree(const char *path, int toplevel)
mt->me.type = MENU_ENTRY_NORMAL;
- mt->action = asprintf("%s/action", g.gl_pathv[i]);
+ mt->action = basprintf("%s/action", g.gl_pathv[i]);
ret = stat(mt->action, &s);
if (ret) {
diff --git a/common/partitions.c b/common/partitions.c
index 82ec508e64..69a2b1fefb 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -51,7 +51,7 @@ static int register_one_partition(struct block_device *blk,
uint64_t size = part->size * SECTOR_SIZE;
struct cdev *cdev;
- partition_name = asprintf("%s.%d", blk->cdev.name, no);
+ partition_name = basprintf("%s.%d", blk->cdev.name, no);
if (!partition_name)
return -ENOMEM;
dev_dbg(blk->dev, "Registering partition %s on drive %s\n",
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index a9945dd9eb..88734f166b 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -17,6 +17,7 @@
#include <init.h>
#include <asm/unaligned.h>
#include <dma.h>
+#include <crc.h>
#include <linux/ctype.h>
#include "efi.h"
diff --git a/common/password.c b/common/password.c
index 5b754d943f..d52b746f0f 100644
--- a/common/password.c
+++ b/common/password.c
@@ -24,6 +24,7 @@
#include <digest.h>
#include <malloc.h>
#include <xfuncs.h>
+#include <command.h>
#include <magicvar.h>
#include <clock.h>
#include <init.h>
@@ -62,7 +63,7 @@ int password(unsigned char *passwd, size_t length, int flags, int timeout)
do {
if (tstc()) {
- ch = getc();
+ ch = getchar();
switch (ch) {
case '\r':
diff --git a/common/startup.c b/common/startup.c
index 093a23ba08..432be67cd6 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -30,6 +30,7 @@
* @brief Main entry into the C part of barebox
*/
#include <common.h>
+#include <shell.h>
#include <init.h>
#include <command.h>
#include <malloc.h>
diff --git a/common/state.c b/common/state.c
index b55b1503bd..87afff3056 100644
--- a/common/state.c
+++ b/common/state.c
@@ -20,6 +20,7 @@
#include <errno.h>
#include <fcntl.h>
#include <fs.h>
+#include <crc.h>
#include <init.h>
#include <ioctl.h>
#include <libbb.h>
@@ -703,8 +704,8 @@ static int state_convert_node_variable(struct state *state,
*indexs = 0;
/* construct full name */
- name = asprintf("%s%s%s",
- parent_name, parent_name[0] ? "." : "", short_name);
+ name = basprintf("%s%s%s", parent_name, parent_name[0] ? "." : "",
+ short_name);
free(short_name);
if ((conv == STATE_CONVERT_TO_NODE) ||
diff --git a/common/uimage.c b/common/uimage.c
index 59d7b65c90..34daf70dc1 100644
--- a/common/uimage.c
+++ b/common/uimage.c
@@ -21,6 +21,7 @@
#include <image.h>
#include <malloc.h>
#include <errno.h>
+#include <crc.h>
#include <libbb.h>
#include <libfile.h>
#include <uncompress.h>