diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2016-05-09 08:49:42 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-05-09 08:49:42 +0200 |
commit | 55aca0a48c5cb68eeddf723a5bc69fc052071e61 (patch) | |
tree | 00961bee994725f5d3ee678c5630b53ecc5a02fe /commands | |
parent | 216f412ede9cb78ccdfd00df89246ab1ffc9e300 (diff) | |
parent | 18f0d2221a4c781dad2a224f8ac17e7c95fd1d9c (diff) | |
download | barebox-55aca0a48c5cb68eeddf723a5bc69fc052071e61.tar.gz barebox-55aca0a48c5cb68eeddf723a5bc69fc052071e61.tar.xz |
Merge branch 'for-next/include-cleanup'
Diffstat (limited to 'commands')
-rw-r--r-- | commands/automount.c | 1 | ||||
-rw-r--r-- | commands/boot.c | 6 | ||||
-rw-r--r-- | commands/clk.c | 4 | ||||
-rw-r--r-- | commands/crc.c | 5 | ||||
-rw-r--r-- | commands/defaultenv.c | 4 | ||||
-rw-r--r-- | commands/echo.c | 10 | ||||
-rw-r--r-- | commands/edit.c | 2 | ||||
-rw-r--r-- | commands/hashsum.c | 2 | ||||
-rw-r--r-- | commands/loadb.c | 7 | ||||
-rw-r--r-- | commands/loadenv.c | 1 | ||||
-rw-r--r-- | commands/loads.c | 6 | ||||
-rw-r--r-- | commands/md.c | 1 | ||||
-rw-r--r-- | commands/mem.c | 23 | ||||
-rw-r--r-- | commands/memcmp.c | 1 | ||||
-rw-r--r-- | commands/memcpy.c | 1 | ||||
-rw-r--r-- | commands/memset.c | 1 | ||||
-rw-r--r-- | commands/menu.c | 4 | ||||
-rw-r--r-- | commands/miitool.c | 2 | ||||
-rw-r--r-- | commands/mkdir.c | 1 | ||||
-rw-r--r-- | commands/mm.c | 1 | ||||
-rw-r--r-- | commands/mmc_extcsd.c | 83 | ||||
-rw-r--r-- | commands/mw.c | 1 | ||||
-rw-r--r-- | commands/rm.c | 1 | ||||
-rw-r--r-- | commands/tftp.c | 4 |
24 files changed, 86 insertions, 86 deletions
diff --git a/commands/automount.c b/commands/automount.c index b491d203fd..a71430c9ef 100644 --- a/commands/automount.c +++ b/commands/automount.c @@ -20,6 +20,7 @@ #include <fs.h> #include <errno.h> #include <getopt.h> +#include <libfile.h> static int do_automount(int argc, char *argv[]) { 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..f862c45b2a 100644 --- a/commands/clk.c +++ b/commands/clk.c @@ -97,7 +97,7 @@ static int do_clk_get_rate(int argc, char *argv[]) } if (optind == argc) { - fprintf(stderr, "No clock name given\n"); + eprintf("No clock name given\n"); return COMMAND_ERROR_USAGE; } @@ -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 58b750eb95..edb1fb125c 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -20,6 +20,7 @@ #include <common.h> #include <command.h> #include <fs.h> +#include <crc.h> #include <getopt.h> #include <malloc.h> #include <libfile.h> @@ -97,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/echo.c b/commands/echo.c index 7d47ab7ca7..8853ee0a30 100644 --- a/commands/echo.c +++ b/commands/echo.c @@ -27,7 +27,7 @@ static int do_echo(int argc, char *argv[]) { int i, optind = 1; - int fd = stdout, opt, newline = 1; + int fd = STDOUT_FILENO, opt, newline = 1; char *file = NULL; int oflags = O_WRONLY | O_CREAT; char str[CONFIG_CBSIZE]; @@ -81,17 +81,17 @@ exit_parse: for (i = optind; i < argc; i++) { if (i > optind) - fputc(fd, ' '); + dputc(fd, ' '); if (process_escape) { process_escape_sequence(argv[i], str, CONFIG_CBSIZE); - fputs(fd, str); + dputs(fd, str); } else { - fputs(fd, argv[i]); + dputs(fd, argv[i]); } } if (newline) - fputc(fd, '\n'); + dputc(fd, '\n'); if (file) close(fd); diff --git a/commands/edit.c b/commands/edit.c index c014892fc4..a5415a6e5b 100644 --- a/commands/edit.c +++ b/commands/edit.c @@ -367,7 +367,7 @@ static void getwinsize(void) printf(ESC "7" ESC "[r" ESC "[999;999H" ESC "[6n"); - while ((r = getc()) != 'R') { + while ((r = getchar()) != 'R') { buf[i] = r; i++; } 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/loadb.c b/commands/loadb.c index 6223512477..6180ce371a 100644 --- a/commands/loadb.c +++ b/commands/loadb.c @@ -183,8 +183,7 @@ static int os_data_save(void) ret = write(ofd, write_buffer, MAX_WRITE_BUFFER); if (ret < 0) { - fprintf(stderr, - "write to device failed\n"); + eprintf("write to device failed\n"); return ret; } write_idx = 0; @@ -563,7 +562,7 @@ static ulong load_serial_bin(void) /* Try to allocate the buffer we shall write to files */ write_buffer = malloc(MAX_WRITE_BUFFER); if (write_buffer == NULL) { - fprintf(stderr, "could not allocate file i/o buffer\n"); + eprintf("could not allocate file i/o buffer\n"); return -ENOMEM; } @@ -585,7 +584,7 @@ static ulong load_serial_bin(void) if (write_idx > 0) { i = write(ofd, write_buffer, write_idx); if (i < 0) { - fprintf(stderr, "write to device failed\n"); + eprintf("write to device failed\n"); size = i; goto err_quit; } diff --git a/commands/loadenv.c b/commands/loadenv.c index 8d6be2fa83..44e96c3b60 100644 --- a/commands/loadenv.c +++ b/commands/loadenv.c @@ -26,6 +26,7 @@ #include <envfs.h> #include <errno.h> #include <fs.h> +#include <libfile.h> #include <malloc.h> #include <globalvar.h> diff --git a/commands/loads.c b/commands/loads.c index aa3095ee8c..eb3e109b0b 100644 --- a/commands/loads.c +++ b/commands/loads.c @@ -59,7 +59,7 @@ static int do_load_serial(int argc, char *argv[]) */ for (i=0; i<100; ++i) { if (tstc()) { - (void) getc(); + (void) getchar(); } udelay(1000); } @@ -142,7 +142,7 @@ static int read_record(char *buf, ulong len) --len; /* always leave room for terminating '\0' byte */ for (p=buf; p < buf+len; ++p) { - c = getc(); /* read character */ + c = getchar(); /* read character */ if (do_echo) putchar(c); @@ -180,7 +180,7 @@ static int do_save_serial(int argc, char *argv[]) printf ("## Ready for S-Record upload, press ENTER to proceed ...\n"); for (;;) { - if (getc() == '\r') + if (getchar() == '\r') break; } if (save_serial(offset, size)) { diff --git a/commands/md.c b/commands/md.c index c88259a3f8..3e83c723a3 100644 --- a/commands/md.c +++ b/commands/md.c @@ -28,6 +28,7 @@ #include <malloc.h> #include <errno.h> #include <fs.h> +#include <libfile.h> #include <fcntl.h> #include <getopt.h> #include <linux/stat.h> diff --git a/commands/mem.c b/commands/mem.c index 23c703f0b5..907f1f76a8 100644 --- a/commands/mem.c +++ b/commands/mem.c @@ -41,29 +41,6 @@ char *mem_rw_buf; -int open_and_lseek(const char *filename, int mode, loff_t pos) -{ - int fd, ret; - - fd = open(filename, mode | O_RDONLY); - if (fd < 0) { - perror("open"); - return fd; - } - - if (!pos) - return fd; - - ret = lseek(fd, pos, SEEK_SET); - if (ret == -1) { - perror("lseek"); - close(fd); - return -errno; - } - - return fd; -} - /* * Common function for parsing options for the 'md', 'mw', 'memcpy', 'memcmp' * commands. diff --git a/commands/memcmp.c b/commands/memcmp.c index e079d5f78e..ce044df0d9 100644 --- a/commands/memcmp.c +++ b/commands/memcmp.c @@ -28,6 +28,7 @@ #include <malloc.h> #include <errno.h> #include <fs.h> +#include <libfile.h> #include <fcntl.h> #include <getopt.h> #include <linux/stat.h> diff --git a/commands/memcpy.c b/commands/memcpy.c index 9c8b64525c..168ef3b4fc 100644 --- a/commands/memcpy.c +++ b/commands/memcpy.c @@ -28,6 +28,7 @@ #include <malloc.h> #include <errno.h> #include <fs.h> +#include <libfile.h> #include <fcntl.h> #include <getopt.h> #include <linux/stat.h> diff --git a/commands/memset.c b/commands/memset.c index fc5b659b9b..f871e07c95 100644 --- a/commands/memset.c +++ b/commands/memset.c @@ -28,6 +28,7 @@ #include <malloc.h> #include <errno.h> #include <fs.h> +#include <libfile.h> #include <fcntl.h> #include <getopt.h> #include <linux/stat.h> diff --git a/commands/menu.c b/commands/menu.c index 2008aa5e9d..9ec2d579b7 100644 --- a/commands/menu.c +++ b/commands/menu.c @@ -160,8 +160,8 @@ static int do_menu_add(struct cmd_menu *cm) free: eprintf("Menu '%s' add fail", cm->menu); if (ret == -EEXIST) - eputs(" already exist"); - eputs("\n"); + eprintf(" already exist"); + eprintf("\n"); menu_free(m); diff --git a/commands/miitool.c b/commands/miitool.c index ba6e604633..07bce18651 100644 --- a/commands/miitool.c +++ b/commands/miitool.c @@ -120,7 +120,7 @@ static int show_basic_mii(struct mii_bus *mii, struct phy_device *phydev, if (mii_val[MII_BMCR] == 0xffff || mii_val[MII_BMSR] == 0x0000) { - fprintf(stderr, " No MII transceiver present!.\n"); + eprintf(" No MII transceiver present!.\n"); return -1; } diff --git a/commands/mkdir.c b/commands/mkdir.c index 1f978869ab..7d024c871d 100644 --- a/commands/mkdir.c +++ b/commands/mkdir.c @@ -22,6 +22,7 @@ #include <fs.h> #include <errno.h> #include <getopt.h> +#include <libfile.h> static int do_mkdir(int argc, char *argv[]) { diff --git a/commands/mm.c b/commands/mm.c index 7c890a6696..6d2a887892 100644 --- a/commands/mm.c +++ b/commands/mm.c @@ -22,6 +22,7 @@ #include <malloc.h> #include <errno.h> #include <fs.h> +#include <libfile.h> #include <fcntl.h> #include <getopt.h> #include <linux/stat.h> diff --git a/commands/mmc_extcsd.c b/commands/mmc_extcsd.c index d05128c6e7..d7fc50697c 100644 --- a/commands/mmc_extcsd.c +++ b/commands/mmc_extcsd.c @@ -153,15 +153,16 @@ static int print_field_ge_v7(u8 *reg, int index) tmp = get_field_val(DATA_SECTOR_SIZE, 0, 0x1); if (tmp64 == 0xFFFFFFFF) if (tmp) - str = "16 TB"; + str = strdup("16 TB"); else - str = "2 TB"; + str = strdup("2 TB"); else if (tmp) - sprintf(str, "%llu B", tmp64 * 4096); + str = basprintf("%llu B", tmp64 * 4096); else - sprintf(str, "%llu B", tmp64 * 512); + str = basprintf("%llu B", tmp64 * 512); printf("\tMax_Pre_Loading_Data_Size: %s\n", str); + free(str); return 1; /* EXT_CSD_PRE_LOADING_DATA_SIZE */ @@ -181,15 +182,16 @@ static int print_field_ge_v7(u8 *reg, int index) tmp = get_field_val(DATA_SECTOR_SIZE, 0, 0x1); if (tmp64 == 0xFFFFFFFF) if (tmp) - str = "16 TB"; + str = strdup("16 TB"); else - str = "2 TB"; + str = strdup("2 TB"); else if (tmp) - sprintf(str, "%llu B", tmp64 * 4096); + str = basprintf("%llu B", tmp64 * 4096); else - sprintf(str, "%llu B", tmp64 * 512); + str = basprintf("%llu B", tmp64 * 512); printf("\tPre_Loading_Data_Size: %s\n", str); + free(str); return 1; case EXT_CSD_FFU_STATUS: @@ -319,12 +321,13 @@ static int print_field_ge_v7(u8 *reg, int index) val = get_field_val(DEVICE_LIFE_TIME_EST_TYP_A, 0, 0xFF); val = val * 10; if (val == 0) - str = "not defined"; + str = strdup("not defined"); else if (val == 0xB) - str = "maximum"; + str = strdup("maximum"); else - sprintf(str, "%u%% - %u%%", (val - 10), val); + str = basprintf("%u%% - %u%%", (val - 10), val); printf("\tDevice life time, type A (estimation): %s\n", str); + free(str); return 1; case EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B: @@ -332,12 +335,13 @@ static int print_field_ge_v7(u8 *reg, int index) val = get_field_val(DEVICE_LIFE_TIME_EST_TYP_B, 0, 0xFF); val = val * 10; if (val == 0) - str = "not defined"; + str = strdup("not defined"); else if (val == 0xB) - str = "maximum"; + str = strdup("maximum"); else - sprintf(str, "%u%% - %u%%", (val - 10), val); + str = basprintf("%u%% - %u%%", (val - 10), val); printf("\tDevice life time, type B (estimation): %s\n", str); + free(str); return 1; /* EXT_CSD_NMBR_OF_FW_SCTRS_CRRCTLY_PRGRMD */ @@ -1687,11 +1691,12 @@ static int print_field(u8 *reg, int index) val = get_field_val(SLEEP_NOTIFICATION_TIME, 0, 0xFF); val = 100 << val; if (val) - sprintf(str, "Sleep Notification timeout values: %u us", - val); + str = basprintf("Sleep Notification timeout values: %u us", + val); else - str = "Not defined"; + str = strdup("Not defined"); printf("\t[7-0] %s\n", str); + free(str); return 1; case EXT_CSD_S_A_TIMEOUT: @@ -1699,10 +1704,11 @@ static int print_field(u8 *reg, int index) val = get_field_val(S_A_TIMEOUT, 0, 0xFF); val = 100 << val; if (val) - sprintf(str, "Sleep/awake timeout values: %u ns", val); + str = basprintf("Sleep/awake timeout values: %u ns", val); else - str = "Not defined"; + str = strdup("Not defined"); printf("\t[7-0] %s\n", str); + free(str); return 1; case EXT_CSD_PRODUCTION_ST8_AWARENSS_TIMEOUT: @@ -1710,12 +1716,13 @@ static int print_field(u8 *reg, int index) val = get_field_val(PRODUCTION_ST8_AWARENSS_TIMEOUT, 0, 0xFF); val = 100 << val; if (val) - sprintf(str, + str = basprintf( "Production State Awareness timeout definition: %u us", val); else - str = "Not defined"; + str = strdup("Not defined"); printf("\t[7-0] %s\n", str); + free(str); return 1; case EXT_CSD_S_C_VCCQ: @@ -1723,10 +1730,11 @@ static int print_field(u8 *reg, int index) val = get_field_val(S_C_VCCQ, 0, 0xF); val = 1 << val; if (val) - sprintf(str, "S_C_VCCQ Sleep Current: %u uA", val); + str = basprintf("S_C_VCCQ Sleep Current: %u uA", val); else - str = "Not defined"; + str = strdup("Not defined"); printf("\t[3-0] %s\n", str); + free(str); return 1; case EXT_CSD_S_C_VCC: @@ -1734,20 +1742,22 @@ static int print_field(u8 *reg, int index) val = get_field_val(S_C_VCC, 0, 0xFF); val = 1 << val; if (val) - sprintf(str, "S_C_VCC Sleep Current: %u uA", val); + str = basprintf("S_C_VCC Sleep Current: %u uA", val); else - str = "Not defined"; + str = strdup("Not defined"); printf("\t[3-0] %s\n", str); + free(str); return 1; case EXT_CSD_HC_WP_GRP_SIZE: print_field_caption(HC_WP_GRP_SIZE, R); val = get_field_val(HC_WP_GRP_SIZE, 0, 0xFF); if (val) - sprintf(str, "Write protect group size: %u", val); + str = basprintf("Write protect group size: %u", val); else - str = "No support"; + str = strdup("No support"); printf("\t[7-0] %s\n", str); + free(str); return 1; case EXT_CSD_REL_WR_SEC_C: @@ -1761,10 +1771,11 @@ static int print_field(u8 *reg, int index) val = get_field_val(ERASE_TIMEOUT_MULT, 0, 0xFF); val = val * 300; if (val) - sprintf(str, "Erase timeout values: %u", val); + str = basprintf("Erase timeout values: %u", val); else - str = "No support"; + str = strdup("No support"); printf("\t[7-0] %s\n", str); + free(str); return 1; case EXT_CSD_HC_ERASE_GRP_SIZE: @@ -1772,10 +1783,11 @@ static int print_field(u8 *reg, int index) val = get_field_val(HC_ERASE_GRP_SIZE, 0, 0xFF); val = val * 524288; if (val) - sprintf(str, "Erase-unit size: %u", val); + str = basprintf("Erase-unit size: %u", val); else - str = "No support"; + str = strdup("No support"); printf("\t[7-0] %s\n", str); + free(str); return 1; case EXT_CSD_ACC_SIZE: @@ -1783,10 +1795,11 @@ static int print_field(u8 *reg, int index) val = get_field_val(ACC_SIZE, 0, 0xF); val = val * 512; if (val) - sprintf(str, "Superpage size: %u", val); + str = basprintf("Superpage size: %u", val); else - str = "Not defined"; + str = strdup("Not defined"); printf("\t[3-0] %s\n", str); + free(str); return 1; case EXT_CSD_BOOT_SIZE_MULT: @@ -1867,14 +1880,14 @@ static int request_write_operation(void) int c; printf("This is a one time programmable field!\nDo you want to write? [y/N] "); - c = getc(); + c = getchar(); /* default is N */ if (c == 0xD) { printf("\n"); return 0; } printf("%c", c); - getc(); /* wait for carriage return */ + getchar(); /* wait for carriage return */ printf("\n"); if (c == 'y' || c == 'Y') return 1; diff --git a/commands/mw.c b/commands/mw.c index 8ca3c61d7f..bb6a16ef3d 100644 --- a/commands/mw.c +++ b/commands/mw.c @@ -28,6 +28,7 @@ #include <malloc.h> #include <errno.h> #include <fs.h> +#include <libfile.h> #include <fcntl.h> #include <getopt.h> #include <linux/stat.h> diff --git a/commands/rm.c b/commands/rm.c index 5f1f582f5e..4eebb3d159 100644 --- a/commands/rm.c +++ b/commands/rm.c @@ -19,6 +19,7 @@ #include <common.h> #include <command.h> #include <fs.h> +#include <libfile.h> #include <getopt.h> #include <errno.h> 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; } |