Skip to content

Commit

Permalink
Improve code clarity and remove TODOs (issues TBA)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthäus Wininger committed Jan 12, 2024
1 parent 0bf16cc commit 78bccf8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,6 @@ Options:

![zps -n](assets/demo-no-color.gif)

## TODO(s)

- Check Korean translation for mistranslations introduced in new release.
- Maybe extend `cmdline`/`COMMAND` output to extend to the maximum line length,
although this would still lead to varying results if one were to look for
a specific string in the "interactive"/non-piped `zps` output manually
compared to piping `stdout` to `grep`, as the maximum line length would
not have the same limit. Thus, it might actually be desirable to actually
limit the lengths in any case.

## License

GNU General Public License v3.0 only ([GPL-3.0-only](https://www.gnu.org/licenses/gpl.txt))
Expand Down
10 changes: 0 additions & 10 deletions README_KO.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,6 @@ docker run zps

![zps -n](assets/demo-no-color.gif)

## TODO(s)

- Check Korean translation for mistranslations introduced in new release.
- Maybe extend `cmdline`/`COMMAND` output to extend to the maximum line length,
although this would still lead to varying results if one were to look for
a specific string in the "interactive"/non-piped `zps` output manually
compared to piping `stdout` to `grep`, as the maximum line length would
not have the same limit. Thus, it might actually be desirable to actually
limit the lengths in any case.

## License

GNU General Public License v3.0 only ([GPL-3.0-only](https://www.gnu.org/licenses/gpl.txt))
Expand Down
11 changes: 10 additions & 1 deletion src/zps.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@

#include "zps.h"

#ifndef PATH_MAX
#define PATH_MAX MAX_BUF_SIZE
#endif

/* Array used for lookup of common signals' abbreviations */
static const char *const abbrevs[NSIG] = {
[SIGHUP] = "HUP", [SIGINT] = "INT", [SIGQUIT] = "QUIT",
[SIGILL] = "ILL", [SIGTRAP] = "TRAP", [SIGABRT] = "ABRT",
Expand Down Expand Up @@ -430,8 +435,12 @@ static ssize_t read_file(char *buf, size_t bufsiz, const char *format, ...)
assert(format);

va_start(vargs, format);
vsnprintf(path, sizeof(path), format, vargs);
int num_required = vsnprintf(path, sizeof(path), format, vargs);
va_end(vargs);
/* Check for errors or truncation */
if (num_required < 0 || (size_t)num_required >= sizeof(path)) {
return -1;
}

const int fd = open(path, O_RDONLY);
if (fd == -1) {
Expand Down

0 comments on commit 78bccf8

Please sign in to comment.