aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/lspci.c6
-rw-r--r--toys/other/pwdx.c14
-rw-r--r--toys/other/stat.c2
3 files changed, 7 insertions, 15 deletions
diff --git a/toys/other/lspci.c b/toys/other/lspci.c
index 077ce757..a0671791 100644
--- a/toys/other/lspci.c
+++ b/toys/other/lspci.c
@@ -50,10 +50,9 @@ static int do_lspci(struct dirtree *new)
if (-1 == (dirfd = openat(dirtree_parentfd(new), new->name, O_RDONLY)))
return 0;
- // it's ok for the driver link not to be there, whatever fortify says
*driver = 0;
if (toys.optflags & FLAG_k)
- if (readlinkat(dirfd, "driver", driver, sizeof(driver))) {};
+ readlinkat0(dirfd, "driver", driver, sizeof(driver));
for (fields = (char*[]){"class", "vendor", "device", 0}; *fields; fields++) {
int fd, size = 6 + 2*((toys.optflags & FLAG_e) && p == toybuf);
@@ -122,8 +121,7 @@ void lspci_main(void)
{
if (CFG_LSPCI_TEXT && TT.numeric != 1) {
if (!TT.ids) TT.ids = "/usr/share/misc/pci.ids";
- if (!(TT.db = fopen(TT.ids, "r")))
- perror_msg("could not open PCI ID db");
+ if (!(TT.db = fopen(TT.ids, "r"))) perror_msg("%s", TT.ids);
}
dirtree_read("/sys/bus/pci/devices", do_lspci);
diff --git a/toys/other/pwdx.c b/toys/other/pwdx.c
index bde16e79..2a72dba3 100644
--- a/toys/other/pwdx.c
+++ b/toys/other/pwdx.c
@@ -20,20 +20,14 @@ void pwdx_main(void)
char **optargs;
for (optargs = toys.optargs; *optargs; optargs++) {
- char *path;
- int num_bytes;
+ char *path = toybuf;
- path = xmprintf("/proc/%s/cwd", *optargs);
- num_bytes = readlink(path, toybuf, sizeof(toybuf)-1);
- free(path);
-
- if (num_bytes==-1) {
+ sprintf(toybuf, "/proc/%d/cwd", atoi(*optargs));
+ if (!readlink0(path, toybuf, sizeof(toybuf))) {
path = strerror(errno);
toys.exitval = 1;
- } else {
- path = toybuf;
- toybuf[num_bytes] = 0;
}
+
xprintf("%s: %s\n", *optargs, path);
}
}
diff --git a/toys/other/stat.c b/toys/other/stat.c
index 9f77a600..7a6b38d7 100644
--- a/toys/other/stat.c
+++ b/toys/other/stat.c
@@ -110,7 +110,7 @@ static void print_stat(char type)
} else if (type == 'N') {
xprintf("`%s'", TT.file);
if (S_ISLNK(stat->st_mode))
- if (0<readlink(TT.file, toybuf, sizeof(toybuf)))
+ if (readlink0(TT.file, toybuf, sizeof(toybuf)))
xprintf(" -> `%s'", toybuf);
} else if (type == 'o') out('u', stat->st_blksize);
else if (type == 's') out('u', stat->st_size);