From 947fb5adf8af450507c978abf1c7ec9f051e5842 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 11 Apr 2016 16:52:10 +0200 Subject: string: Fix (v)asprintf prototypes Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer --- commands/boot.c | 6 +++--- commands/clk.c | 2 +- commands/crc.c | 4 ++-- commands/defaultenv.c | 4 ++-- commands/hashsum.c | 2 +- commands/tftp.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) (limited to 'commands') diff --git a/commands/boot.c b/commands/boot.c index f403010130..bd1be4ba75 100644 --- a/commands/boot.c +++ b/commands/boot.c @@ -156,7 +156,7 @@ static int bootscript_scan_path(struct blspec *blspec, const char *path) return 1; } - files = asprintf("%s/*", path); + files = basprintf("%s/*", path); glob(files, 0, NULL, &globb); @@ -208,7 +208,7 @@ static int bootentry_parse_one(struct blspec *blspec, const char *name) char *path; if (*name != '/') - path = asprintf("/env/boot/%s", name); + path = basprintf("/env/boot/%s", name); else path = xstrdup(name); @@ -233,7 +233,7 @@ static struct blspec *bootentries_collect(char *entries[], int num_entries) blspec = blspec_alloc(); if (IS_ENABLED(CONFIG_MENU)) - blspec->menu->display = asprintf("boot"); + blspec->menu->display = basprintf("boot"); if (!num_entries) bootscript_scan_path(blspec, "/env/boot"); diff --git a/commands/clk.c b/commands/clk.c index e9459a3fd3..65832d4985 100644 --- a/commands/clk.c +++ b/commands/clk.c @@ -110,7 +110,7 @@ static int do_clk_get_rate(int argc, char *argv[]) if (variable_name) { char *t; - t = asprintf("%lu", rate); + t = basprintf("%lu", rate); setenv(variable_name, t); free(t); } else diff --git a/commands/crc.c b/commands/crc.c index 066d91e179..edb1fb125c 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -98,13 +98,13 @@ static int do_crc(int argc, char *argv[]) filename, (ulong)start, (ulong)start + total - 1, crc); if (crcvarname) { - char *crcstr = asprintf("0x%lx", crc); + char *crcstr = basprintf("0x%lx", crc); setenv(crcvarname, crcstr); kfree(crcstr); } if (sizevarname) { - char *sizestr = asprintf("0x%lx", total); + char *sizestr = basprintf("0x%lx", total); setenv(sizevarname, sizestr); kfree(sizestr); } diff --git a/commands/defaultenv.c b/commands/defaultenv.c index bae2d78f47..47bdf26d14 100644 --- a/commands/defaultenv.c +++ b/commands/defaultenv.c @@ -60,8 +60,8 @@ static int do_defaultenv(int argc, char *argv[]) if (ret) return ret; - from = asprintf("/.defaultenv/%s", restorepath); - to = asprintf("%s/%s", dirname, restorepath); + from = basprintf("/.defaultenv/%s", restorepath); + to = basprintf("%s/%s", dirname, restorepath); printf("Restoring %s from default environment\n", restorepath); diff --git a/commands/hashsum.c b/commands/hashsum.c index 8d3694fa78..d05e571fb9 100644 --- a/commands/hashsum.c +++ b/commands/hashsum.c @@ -46,7 +46,7 @@ static int do_hash(char *algo, int argc, char *argv[]) } if (key) { - char *tmp = asprintf("hmac(%s)", algo); + char *tmp = basprintf("hmac(%s)", algo); d = digest_alloc(tmp); free(tmp); BUG_ON(!d); diff --git a/commands/tftp.c b/commands/tftp.c index 8a3b541382..6a3121ad56 100644 --- a/commands/tftp.c +++ b/commands/tftp.c @@ -58,10 +58,10 @@ static int do_tftpb(int argc, char *argv[]) dest = argv[optind]; if (tftp_push) { - dest = freep = asprintf("%s/%s", TFTP_MOUNT_PATH, dest); + dest = freep = basprintf("%s/%s", TFTP_MOUNT_PATH, dest); flags = O_RDONLY; } else { - source = freep = asprintf("%s/%s", TFTP_MOUNT_PATH, source); + source = freep = basprintf("%s/%s", TFTP_MOUNT_PATH, source); flags = O_WRONLY | O_CREAT; } -- cgit v1.2.3