Skip to content

Commit

Permalink
Use _r variant of basename and dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Nov 6, 2019
1 parent a8f8180 commit 22599fd
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/bin/unit_test_attribute.c
Expand Up @@ -2195,6 +2195,9 @@ int main(int argc, char *argv[])
bool do_commands = false;
bool do_usage = false;

char dir_buff[PATH_MAX];
char file_buff[PATH_MAX];

#ifndef NDEBUG
if (fr_fault_setup(autofree, getenv("PANIC_ACTION"), argv[0]) < 0) {
fr_perror("unit_test_attribute");
Expand Down Expand Up @@ -2319,7 +2322,7 @@ int main(int argc, char *argv[])
* Read tests from stdin
*/
if (argc < 2) {
ret = process_file(&exit_now, autofree, features, dict, name, "-");
ret = process_file(&exit_now, autofree, features, dict, dirname_r(name, dir_buff), "-");

/*
* ...or process each file in turn.
Expand All @@ -2328,19 +2331,8 @@ int main(int argc, char *argv[])
int i;

for (i = 1; i < argc; i++) {
char *dir, *file;
char *p = strrchr(argv[i], '/');

if (p) {
*p = '\0'; /* we are allowed to modify our arguments. No one cares. */
dir = argv[i];
file = p + 1;
} else {
dir = NULL;
file = argv[i];
}

ret = process_file(&exit_now, autofree, features, dict, dir, file);
ret = process_file(&exit_now, autofree, features, dict,
dirname_r(argv[i], dir_buff), basename_r(argv[i], file_buff));
if ((ret != 0) || exit_now) break;
}
}
Expand Down

0 comments on commit 22599fd

Please sign in to comment.