Skip to content

Commit 7e8c468

Browse files
committed
miscellaneous fixes
1 parent eacdcf0 commit 7e8c468

15 files changed

+48
-329
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ if (RPMBUILD)
359359

360360
# get the architecture of this machine
361361
# assumes that we are not cross compiling
362-
find_program(UNAME uname)
362+
find_program(UNAME uname) # REQUIRED option was not added until 3.18
363363
if (NOT UNAME)
364364
message(FATAL_ERROR "uname not found. Cannot build RPMs.")
365365
endif()

contrib/gendir.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ int main(int argc, char * argv[]) {
265265

266266
clock_gettime(CLOCK_MONOTONIC, &generation.end);
267267

268-
const long double gen_time = elapsed(&generation);
268+
const long double gen_time = sec(nsec(&generation));
269269

270270
printf("Time Spent Generating: %.2Lfs\n", gen_time);
271271
printf("Dirs/Sec: %.2Lf\n", total_dirs / gen_time);

include/BottomUp.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ OF SUCH DAMAGE.
7474

7575
#include <pthread.h>
7676

77-
#include "debug.h"
7877
#include "SinglyLinkedList.h"
78+
#include "bf.h"
79+
#include "debug.h"
7980

8081
/* extra AscendFunc_t argments */
8182
#if defined(DEBUG) && defined(PER_THREAD_STATS)
83+
#include "OutputBuffers.h"
8284
#define timestamp_sig , struct OutputBuffers *timestamp_buffers
8385
#define timestamp_args , timestamp_buffers
8486
#else

include/debug.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ struct start_end {
105105
/* nanoseconds since an unspecified epoch */
106106
uint64_t since_epoch(struct timespec * ts);
107107

108-
/* Get number of seconds between two events recorded in struct timespecs */
109-
uint64_t elapsed(struct start_end * se);
108+
/* Get number of nanoseconds between two events recorded in struct timespecs */
109+
uint64_t nsec(struct start_end * se);
110110

111-
long double sec(uint64_t nsec);
111+
long double sec(uint64_t ns);
112112

113113
int print_timer(struct OutputBuffers * obufs, const size_t id, char * str, const size_t size, const char * name, struct start_end * se);
114114

@@ -166,7 +166,7 @@ int print_timer(struct OutputBuffers * obufs, const size_t id, char * str, const
166166
#endif /* PER_THREAD_STATS */
167167

168168
#define timestamp_elapsed(name) \
169-
elapsed(&timestamp_get_name(name))
169+
nsec(&timestamp_get_name(name))
170170

171171
#define timestamp_destroy(obs) \
172172
OutputBuffers_flush_to_single(obs, stderr); \

include/trace.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ extern "C" {
7474
#endif
7575

7676
/* write a work struct to a file */
77-
int worktofile(FILE *file, char *delim, struct work *work);
77+
int worktofile(FILE *file, const char *delim, struct work *work);
7878

7979
/* convert a formatted string to a work struct */
80-
int linetowork(char *line, const size_t len, char *delim, struct work *work);
80+
int linetowork(char *line, const size_t len, const char *delim, struct work *work);
8181

8282
#ifdef __cplusplus
8383
}

src/BottomUp.c

+16-11
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,11 @@ processed before processing the current one
7878
#include <sys/types.h>
7979
#include <unistd.h>
8080

81-
#include "bf.h"
8281
#include "BottomUp.h"
83-
#include "dbutils.h"
84-
#include "debug.h"
8582
#include "QueuePerThreadPool.h"
8683
#include "SinglyLinkedList.h"
84+
#include "dbutils.h"
85+
#include "debug.h"
8786
#include "utils.h"
8887

8988

@@ -178,7 +177,7 @@ static struct BottomUp *track(const char *name, const size_t name_len,
178177
const size_t level) {
179178
struct BottomUp *copy = malloc(user_struct_size);
180179

181-
memcpy(copy->name, name, name_len + 1);
180+
memcpy(copy->name, name, name_len + 1); /* NULL terminate */
182181
copy->name_len = name_len;
183182

184183
copy->level = level;
@@ -229,13 +228,19 @@ int descend_to_bottom(struct QPTPool *ctx, const size_t id, void *data, void *ar
229228
break;
230229
}
231230

232-
if ((strncmp(entry->d_name, ".", 2) == 0) ||
233-
(strncmp(entry->d_name, "..", 3) == 0)) {
234-
continue;
231+
const size_t name_len = strlen(entry->d_name);
232+
if (name_len < 3) {
233+
if ((strncmp(entry->d_name, ".", 1) == 0) ||
234+
(strncmp(entry->d_name, "..", 2) == 0)) {
235+
continue;
236+
}
235237
}
236238

237239
struct BottomUp new_work;
238-
new_work.name_len = SNPRINTF(new_work.name, MAXPATH, "%s/%s", bu->name, entry->d_name);
240+
new_work.name_len = SNFORMAT_S(new_work.name, MAXPATH, 3,
241+
bu->name, bu->name_len,
242+
"/", (size_t) 1,
243+
entry->d_name, name_len);
239244

240245
timestamp_start(lstat_entry);
241246
struct stat st;
@@ -335,9 +340,9 @@ int parallel_bottomup(char **root_names, size_t root_count,
335340
#endif
336341

337342
struct QPTPool *pool = QPTPool_init(thread_count
338-
#if defined(DEBUG) && defined(PER_THREAD_STATS)
339-
, timestamp_buffers
340-
#endif
343+
#if defined(DEBUG) && defined(PER_THREAD_STATS)
344+
, timestamp_buffers
345+
#endif
341346
);
342347

343348
if (!pool) {

src/debug.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ uint64_t since_epoch(struct timespec * ts) {
8383
return ns;
8484
}
8585

86-
uint64_t elapsed(struct start_end * se) {
86+
uint64_t nsec(struct start_end * se) {
8787
const uint64_t s = (se->start.tv_sec * 1000000000ULL) + se->start.tv_nsec;
8888
const uint64_t e = (se->end.tv_sec * 1000000000ULL) + se->end.tv_nsec;
8989
return e - s;
9090
}
9191

92-
long double sec(uint64_t nsec) {
93-
return ((long double) nsec) / 1e9L;
92+
long double sec(uint64_t ns) {
93+
return ((long double) ns) / 1e9L;
9494
}
9595

9696
int print_timer(struct OutputBuffers * obufs, const size_t id, char * str, const size_t size, const char * name, struct start_end * se) {

src/gufi_query.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ uint64_t buffer_sum(struct sll * timers) {
197197
uint64_t sum = 0;
198198
sll_loop(timers, node) {
199199
struct start_end * timer = (struct start_end *) sll_node_data(node);
200-
sum += elapsed(timer);
200+
sum += nsec(timer);
201201
}
202202

203203
return sum;
@@ -213,7 +213,7 @@ uint64_t buffer_sum(struct sll * timers) {
213213

214214
#endif
215215
#else
216-
struct sll * descend_timers_init() {}
216+
struct sll *descend_timers_init() { return NULL; }
217217
void descend_timers_destroy(struct sll * dt) {}
218218
#define buffered_start(name)
219219
#define buffered_end(name)

src/gufi_trace2index.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ int scout_function(struct QPTPool *ctx, const size_t id, void *data, void *args)
591591
clock_gettime(CLOCK_MONOTONIC, &scouting.end);
592592

593593
pthread_mutex_lock(&print_mutex);
594-
fprintf(stdout, "Scout finished in %.2Lf seconds\n", sec(elapsed(&scouting)));
594+
fprintf(stdout, "Scout finished in %.2Lf seconds\n", sec(nsec(&scouting)));
595595
fprintf(stdout, "Files: %zu\n", file_count);
596596
fprintf(stdout, "Dirs: %zu (%zu empty)\n", dir_count, empty);
597597
fprintf(stdout, "Total: %zu\n", file_count + dir_count);
@@ -738,7 +738,7 @@ int main(int argc, char *argv[]) {
738738
fprintf(stderr, "Files inserted: %zu\n", total_files);
739739
#endif
740740

741-
fprintf(stderr, "main completed in %.2Lf seconds\n", sec(elapsed(&main_func)));
741+
fprintf(stderr, "main completed in %.2Lf seconds\n", sec(nsec(&main_func)));
742742

743743
return 0;
744744
}

src/querydb.c

-184
This file was deleted.

src/rollup.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ struct DirStats {
9090
size_t subdir_count; /* unrolled up count from readdir, not summary */
9191
size_t subnondir_count; /* rolled up count from entries and subdir.pentries */
9292

93-
int too_many_before; /* current directory is too big to roll up */
94-
int too_many_after; /* rolling up would result in too many rows in pentries */
93+
size_t too_many_before; /* current directory is too big to roll up */
94+
size_t too_many_after; /* rolling up would result in too many rows in pentries */
9595
int score; /* roll up score regardless of success or failure */
9696
int success; /* whether or not the roll up succeeded */
9797
};
@@ -214,8 +214,8 @@ do { \
214214

215215
void print_stanza(const char * name, struct sll * stats) {
216216
fprintf(stdout, "%s %*zu\n", name, (int) (29 - strlen(name)), sll_get_size(stats));
217-
sll_dir_stats("Subdirectories", stats, subdir_count, 10);
218-
sll_dir_stats("Files/Links", stats, subnondir_count, 10);
217+
sll_dir_stats("Subdirectories", stats, subdir_count, (size_t) 10);
218+
sll_dir_stats("Files/Links", stats, subnondir_count, (size_t) 10);
219219
sll_dir_stats("Level", stats, level, 10);
220220
}
221221

@@ -842,7 +842,7 @@ int main(int argc, char * argv[]) {
842842
free(stats);
843843

844844
timestamp_set_end_raw(runtime);
845-
fprintf(stderr, "Took %.2Lf seconds\n", sec(elapsed(&runtime)));
845+
fprintf(stderr, "Took %.2Lf seconds\n", sec(nsec(&runtime)));
846846

847847
return rc;
848848
}

0 commit comments

Comments
 (0)