Skip to content

Commit 3ad2dd4

Browse files
committed
cleanup
1 parent c2e0912 commit 3ad2dd4

File tree

9 files changed

+32
-20
lines changed

9 files changed

+32
-20
lines changed

src/gufi_query/main.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,13 @@ int main(int argc, char *argv[])
111111
int idx = parse_cmd_line(argc, argv, "hHT:S:E:an:jo:d:O:I:F:y:z:J:K:G:mB:wxk:M:" COMPRESS_OPT "Q:", 1, "GUFI_index ...", &in);
112112
if (in.helped)
113113
sub_help();
114-
if (idx < 0)
114+
if (idx < 0) {
115+
input_fini(&in);
115116
return EXIT_FAILURE;
117+
}
116118

117119
if (validate_inputs(&in) != 0) {
120+
input_fini(&in);
118121
return EXIT_FAILURE;
119122
}
120123

src/gufi_query/processdir.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ int processdir(QPTPool_t *ctx, const size_t id, void *data, void *args) {
195195
thread_timestamp_end(lstat_db_call);
196196

197197
if (rc != 0) {
198-
goto out_free;
198+
goto close_dir;
199199
}
200200

201201
if (gqw->work.level >= in->min_level) {
@@ -429,6 +429,8 @@ int processdir(QPTPool_t *ctx, const size_t id, void *data, void *args) {
429429
}
430430
thread_timestamp_end(utime_call);
431431

432+
close_dir:
433+
;
432434
thread_timestamp_start(ts.tts, closedir_call);
433435
closedir(dir);
434436
thread_timestamp_end(closedir_call);

src/gufi_trace2index.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,14 @@ static struct row *row_init(const int trace, const size_t first_delim, char *lin
131131
return row;
132132
}
133133

134-
static void row_destroy(struct row *row) {
134+
static void row_destroy(struct row **ref) {
135135
/* Not checking arguments */
136+
137+
struct row *row = *ref;
136138
free(row->line);
137139
free(row);
140+
141+
*ref = NULL;
138142
}
139143

140144
#ifdef DEBUG
@@ -233,7 +237,7 @@ static int processdir(QPTPool_t *ctx, const size_t id, void *data, void *args) {
233237
const int err = errno;
234238
fprintf(stderr, "Dupdir failure: \"%s\": %s (%d)\n",
235239
topath, strerror(err), err);
236-
row_destroy(w);
240+
row_destroy(&w);
237241
return 1;
238242
}
239243
timestamp_set_end(dupdir);
@@ -442,7 +446,7 @@ static int processdir(QPTPool_t *ctx, const size_t id, void *data, void *args) {
442446
}
443447

444448
timestamp_create_start(row_destroy);
445-
row_destroy(w);
449+
row_destroy(&w);
446450
timestamp_set_end(row_destroy);
447451

448452
#ifdef DEBUG
@@ -558,13 +562,10 @@ static int scout_function(QPTPool_t *ctx, const size_t id, void *data, void *arg
558562
* bad line
559563
*/
560564
if (!first_delim) {
561-
free(line);
562-
line = NULL;
563-
size = 0;
564-
len = 0;
565+
row_destroy(&work);
565566
fprintf(stderr, "Scout encountered bad line ending at %s offset %jd\n",
566567
sa->tracename, (intmax_t) offset);
567-
return 1;
568+
break;
568569
}
569570

570571
/* push directories onto queues */
@@ -596,10 +597,12 @@ static int scout_function(QPTPool_t *ctx, const size_t id, void *data, void *arg
596597

597598
free(line);
598599

599-
/* handle the last work item */
600-
dir_count++;
601-
empty += !work->entries;
602-
QPTPool_enqueue(ctx, id, processdir, work);
600+
if (work) {
601+
/* handle the last work item */
602+
dir_count++;
603+
empty += !work->entries;
604+
QPTPool_enqueue(ctx, id, processdir, work);
605+
}
603606

604607
clock_gettime(CLOCK_MONOTONIC, &scouting.end);
605608

src/parallel_cpr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static int setup(const refstr_t *dst) {
360360

361361
static void sub_help(void) {
362362
printf("src... directory to copy\n");
363-
printf("dst directory to copy place sources under\n");
363+
printf("dst directory to place sources under\n");
364364
printf("\n");
365365
}
366366

test/regression/gufi_trace2index.expected

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,12 @@ Total Files: 0
118118

119119
# file delimiter not found
120120
$ gufi_trace2index -d "|" -n "2" "badtrace" "prefix"
121-
Scout encountered bad line ending at badtrace offset 24
121+
Scout encountered bad line ending at badtrace offset 62
122122
Creating GUFI Index prefix with 2 threads
123+
Dirs: 0 (0 empty)
124+
Files: 0
125+
Total: 0
126+
123127
Total Dirs: 0
124128
Total Files: 0
125129

test/regression/gufi_trace2index.sh.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ echo
139139
# generate trace with good directory line and bad file line
140140
# only need the first delimiter to trigger error
141141
(
142-
echo "${SRCDIR}${DELIM}d${DELIM}"
142+
head -n 1 "${TRACE}" | sed 's/[0-9]\+/0/g'
143143
echo "${SRCDIR}/1KB${BADDELIM}f${BADDELIM}"
144144
) > "${BADTRACE}"
145145

test/regression/parallel_cpr.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ options:
77
-x index/query xattrs
88

99
src... directory to copy
10-
dst directory to copy place sources under
10+
dst directory to place sources under
1111

1212

1313
$ parallel_cpr -n 2 "prefix" "copy"

test/regression/parallel_rmr.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ empty_directory
1515
leaf_directory
1616
unusual#? directory ,
1717

18-
$ parallel_rmr "prefix/directory" "prefix/empty_directory" "prefix/leaf_directory"
18+
$ parallel_rmr -n 2 "prefix/directory" "prefix/empty_directory" "prefix/leaf_directory"
1919

2020
$ ls -1 prefix
2121
db.db

test/regression/parallel_rmr.sh.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ OUTPUT="parallel_rmr.out"
6969
(
7070
run_no_sort "${PARALLEL_RMR} -h"
7171
run_sort "ls -1 ${INDEXROOT}"
72-
run_no_sort "${PARALLEL_RMR} \"${INDEXROOT}/directory\" \"${INDEXROOT}/empty_directory\" \"${INDEXROOT}/leaf_directory\""
72+
run_no_sort "${PARALLEL_RMR} -n ${THREADS} \"${INDEXROOT}/directory\" \"${INDEXROOT}/empty_directory\" \"${INDEXROOT}/leaf_directory\""
7373
run_sort "ls -1 ${INDEXROOT}"
7474
) | tee "${OUTPUT}"
7575

0 commit comments

Comments
 (0)