diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2022-06-29 09:00:56 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-06-29 09:00:56 +0200 |
commit | bd0e1e5dde37cb927ad9e5d225d55d0cb636a53d (patch) | |
tree | 52390373b797d525e283ada7609b22bdc4fe25d2 /commands | |
parent | 8828e1226981b6a31b12a643768cac63fae3576e (diff) | |
parent | 370f346bca176a93d034af2c0021b5da9a6101ad (diff) | |
download | barebox-bd0e1e5dde37cb927ad9e5d225d55d0cb636a53d.tar.gz |
Merge branch 'for-next/misc'
Diffstat (limited to 'commands')
-rw-r--r-- | commands/bootm.c | 1 | ||||
-rw-r--r-- | commands/clk.c | 10 | ||||
-rw-r--r-- | commands/crc.c | 14 | ||||
-rw-r--r-- | commands/hwclock.c | 4 | ||||
-rw-r--r-- | commands/loadb.c | 4 | ||||
-rw-r--r-- | commands/loads.c | 4 | ||||
-rw-r--r-- | commands/ls.c | 10 | ||||
-rw-r--r-- | commands/memtester/memtester.c | 2 | ||||
-rw-r--r-- | commands/spd_decode.c | 3 | ||||
-rw-r--r-- | commands/state.c | 3 |
10 files changed, 20 insertions, 35 deletions
diff --git a/commands/bootm.c b/commands/bootm.c index f54a4827eb..95d267135c 100644 --- a/commands/bootm.c +++ b/commands/bootm.c @@ -17,7 +17,6 @@ #include <fs.h> #include <errno.h> #include <bootm.h> -#include <of.h> #include <rtc.h> #include <init.h> #include <of.h> diff --git a/commands/clk.c b/commands/clk.c index dfbc7c988f..b1741b9da4 100644 --- a/commands/clk.c +++ b/commands/clk.c @@ -139,13 +139,9 @@ static int do_clk_get_rate(int argc, char *argv[]) rate = clk_get_rate(clk); - if (variable_name) { - char *t; - - t = basprintf("%lu", rate); - setenv(variable_name, t); - free(t); - } else + if (variable_name) + pr_setenv(variable_name, "%lu", rate); + else printf("%lu\n", rate); return COMMAND_SUCCESS; diff --git a/commands/crc.c b/commands/crc.c index 80ecf7fe29..23ffd4360b 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -83,17 +83,11 @@ static int do_crc(int argc, char *argv[]) printf("CRC32 for %s 0x%08lx ... 0x%08lx ==> 0x%08lx", filename, (ulong)start, (ulong)start + total - 1, crc); - if (crcvarname) { - char *crcstr = basprintf("0x%lx", crc); - setenv(crcvarname, crcstr); - kfree(crcstr); - } + if (crcvarname) + pr_setenv(crcvarname, "0x%lx", crc); - if (sizevarname) { - char *sizestr = basprintf("0x%lx", total); - setenv(sizevarname, sizestr); - kfree(sizestr); - } + if (sizevarname) + pr_setenv(sizevarname, "0x%lx", total); #ifdef CONFIG_CMD_CRC_CMP if (vfilename) { diff --git a/commands/hwclock.c b/commands/hwclock.c index abb0500e6a..c594e070ac 100644 --- a/commands/hwclock.c +++ b/commands/hwclock.c @@ -153,11 +153,9 @@ static int do_hwclock(int argc, char *argv[]) if (env_name) { unsigned long time; - char t[12]; rtc_tm_to_time(&tm, &time); - snprintf(t, 12, "%lu", time); - setenv(env_name, t); + pr_setenv(env_name, "%lu", time); } else { printf("%s\n", time_str(&tm)); } diff --git a/commands/loadb.c b/commands/loadb.c index 17d3af84b5..7ab989f459 100644 --- a/commands/loadb.c +++ b/commands/loadb.c @@ -542,7 +542,6 @@ packet_error: static ulong load_serial_bin(void) { int size, i; - char buf[32]; /* Try to allocate the buffer we shall write to files */ write_buffer = malloc(MAX_WRITE_BUFFER); @@ -576,8 +575,7 @@ static ulong load_serial_bin(void) write_idx = 0; } printf("## Total Size = 0x%08x = %d Bytes\n", size, size); - sprintf(buf, "%X", size); - setenv("filesize", buf); + pr_setenv("filesize", "%X", size); err_quit: free(write_buffer); diff --git a/commands/loads.c b/commands/loads.c index 8260673c51..7c5df31251 100644 --- a/commands/loads.c +++ b/commands/loads.c @@ -65,7 +65,6 @@ static ulong load_serial(ulong offset) int type; /* return code for record type */ ulong addr; /* load address from S-Record */ ulong size; /* number of bytes transferred */ - char buf[32]; ulong store_addr; ulong start_addr = ~0; ulong end_addr = 0; @@ -100,8 +99,7 @@ static ulong load_serial(ulong offset) "## Total Size = 0x%08lX = %ld Bytes\n", start_addr, end_addr, size, size ); - sprintf(buf, "%lX", size); - setenv("filesize", buf); + pr_setenv("filesize", "%lX", size); return addr; case SREC_START: break; diff --git a/commands/ls.c b/commands/ls.c index bedf2e1c42..1192aed971 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -63,10 +63,10 @@ int ls(const char *path, ulong flags) if (stat(path, &s)) return -errno; - if (flags & LS_SHOWARG && s.st_mode & S_IFDIR) + if (flags & LS_SHOWARG && S_ISDIR(s.st_mode)) printf("%s:\n", path); - if (!(s.st_mode & S_IFDIR)) { + if (!S_ISDIR(s.st_mode)) { ls_one(path, path); return 0; } @@ -112,7 +112,7 @@ int ls(const char *path, ulong flags) continue; } - if (s.st_mode & S_IFDIR) + if (S_ISDIR(s.st_mode)) ls(tmp, flags); } @@ -171,7 +171,7 @@ static int do_ls(int argc, char *argv[]) continue; } - if (!(s.st_mode & S_IFDIR)) { + if (!S_ISDIR(s.st_mode)) { if (flags & LS_COLUMN) string_list_add_sorted(&sl, argv[o]); else @@ -197,7 +197,7 @@ static int do_ls(int argc, char *argv[]) continue; } - if (s.st_mode & S_IFDIR) { + if (S_ISDIR(s.st_mode)) { ret = ls(argv[o], flags); if (ret) { perror("ls"); diff --git a/commands/memtester/memtester.c b/commands/memtester/memtester.c index 130dc97c83..f4adbfc855 100644 --- a/commands/memtester/memtester.c +++ b/commands/memtester/memtester.c @@ -113,7 +113,7 @@ static int do_memtester(int argc, char **argv) { strerror(errno)); return COMMAND_ERROR_USAGE; } else { - if (!S_ISCHR(statbuf.st_mode)) { + if (!S_ISCHR(statbuf.st_mode) && !S_ISBLK(statbuf.st_mode)) { printf("can not mmap non-char device %s\n", optarg); return COMMAND_ERROR_USAGE; diff --git a/commands/spd_decode.c b/commands/spd_decode.c index e8ee339a91..fa8fe86cf8 100644 --- a/commands/spd_decode.c +++ b/commands/spd_decode.c @@ -16,13 +16,12 @@ static int do_spd_decode(int argc, char *argv[]) { int ret; - size_t size; void *data; if (argc != 2) return COMMAND_ERROR_USAGE; - ret = read_file_2(argv[1], &size, &data, 256); + ret = read_file_2(argv[1], NULL, &data, 256); if (ret && ret != -EFBIG) { printf("unable to read %s: %s\n", argv[1], strerror(-ret)); return COMMAND_ERROR; diff --git a/commands/state.c b/commands/state.c index e7cb9902f7..56ef93b19f 100644 --- a/commands/state.c +++ b/commands/state.c @@ -53,6 +53,9 @@ static int do_state(int argc, char *argv[]) ret = state_save(state); } + if (ret == -ENOMEDIUM) + ret = 0; + return ret; } |