Skip to content

Commit

Permalink
fix some compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
calccrypto committed Dec 1, 2023
1 parent 6dff105 commit 0635524
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 56 deletions.
2 changes: 1 addition & 1 deletion contrib/make_testindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ int main(int argc, char *argv[]) {
clock_gettime(CLOCK_MONOTONIC, &start);

// set up progress thread
LoopedThread progress(settings.progress_rate, ThreadArgs::mutex, [&print_mutex, &start, &pool, &settings](){
LoopedThread progress(settings.progress_rate, ThreadArgs::mutex, [&print_mutex, &start, &settings](){
std::lock_guard <std::mutex> print_lock(print_mutex);

struct timespec now = {};
Expand Down
10 changes: 10 additions & 0 deletions src/bffuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ static int gufir_getattr(const char *path, struct stat *stbuf) {
}

static int gufir_readdir(const char *path, void *buf, fuse_fill_dir_t filler,off_t offset, struct fuse_file_info *fi) {
(void) offset;
(void) fi;

int rc;
sqlite3_stmt *res;
const char *tail;
Expand Down Expand Up @@ -344,6 +347,8 @@ static int gufir_access(const char *path, int mask) {
}

static int gufir_statfs(const char *path, struct statvfs *stbuf) {
(void) path;

int res;

res = statvfs("/", stbuf);
Expand All @@ -358,6 +363,11 @@ static int gufir_getxattr(const char *path, const char *name, char *value,size_t
#else
static int gufir_getxattr(const char *path, const char *name, char *value,size_t size) {
#endif
#ifdef __APPLE__
(void) position;
#endif
(void) name;

int rc;
sqlite3_stmt *res;
const char *tail;
Expand Down
10 changes: 10 additions & 0 deletions src/bfresultfuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ static int gufir_getattr(const char *path, struct stat *stbuf) {
}

static int gufir_readdir(const char *path, void *buf, fuse_fill_dir_t filler,off_t offset, struct fuse_file_info *fi) {
(void) offset;
(void) fi;

size_t i;
int rc;
sqlite3_stmt *res;
Expand Down Expand Up @@ -337,6 +340,8 @@ static int gufir_readdir(const char *path, void *buf, fuse_fill_dir_t filler,off
}

static int gufir_access(const char *path, int mask) {
(void) path;
(void) mask;
return 0;
}

Expand Down Expand Up @@ -405,6 +410,11 @@ static int gufir_getxattr(const char *path, const char *name, char *value, size_
static int gufir_getxattr(const char *path, const char *name, char *value, size_t size)
#endif
{
#ifdef __APPLE__
(void) position;
#endif
(void) name;

int rc;
sqlite3_stmt *res;
const char *tail;
Expand Down
1 change: 1 addition & 0 deletions src/dfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ static int printit(const char *name, const struct stat *status, char *type, char
static int printload(struct input *in, const char *name, const struct stat *status,
char *type, char *linkname, struct xattrs *xattrs, long long pinode,
char *sortf, FILE *of) {
(void) pinode;
fprintf(of,"%s%c", name,in->delim);
fprintf(of,"%c%c", type[0],in->delim);
fprintf(of,"%"STAT_ino"%c", status->st_ino,in->delim);
Expand Down
5 changes: 5 additions & 0 deletions src/tsmepoch2time.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

int main(int argc, char **argv)
{
if (argc < 2) {
fprintf(stderr, "Syntax: %s timestamp", argv[0]);
return 1;
}

struct tm ts;
char buf[80];

Expand Down
6 changes: 6 additions & 0 deletions src/tsmtime2epoch.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ OF SUCH DAMAGE.

int main(int argc, char **argv)
{
if (argc < 3) {
fprintf(stderr, "Syntax: %s M/D/Y H:M:S\n", argv[0]);
return 1;
}

struct tm t;
time_t t_of_day;
int myear;
Expand All @@ -81,4 +86,5 @@ int main(int argc, char **argv)
t_of_day = mktime(&t);

printf("seconds since the Epoch: %ld\n", (long) t_of_day);
return 0;
}
81 changes: 39 additions & 42 deletions test/unit/googletest/BottomUp.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -72,49 +72,54 @@ OF SUCH DAMAGE.

BU_f f = [](void *args timestamp_sig) -> void { (void) args; };

/* C Standard 6.10.3/C++ Standard 16.3 Macro replacement */
static int parallel_bottomup_wrapper(char **root_names, const size_t root_count,
const size_t thread_count,
const size_t user_struct_size,
BU_f descend, BU_f ascend,
const int track_non_dirs,
const int generate_alt_name,
void *extra_args) {
return parallel_bottomup(root_names, root_count,
thread_count,
user_struct_size,
descend, ascend,
track_non_dirs,
generate_alt_name,
extra_args
#if defined(DEBUG) && defined(PER_THREAD_STATS)
, nullptr
#endif
);
}

TEST(BottomUp, builddir) {
const char *roots[] = {
"@CMAKE_BINARY_DIR@",
};

const size_t root_count = sizeof(roots) / sizeof(roots[0]);

EXPECT_EQ(parallel_bottomup((char **) roots, root_count, 1,
sizeof(struct BottomUp),
f, f, 0, 0, nullptr
#if defined(DEBUG) && defined(PER_THREAD_STATS)
, nullptr
#endif
), 0);
EXPECT_EQ(parallel_bottomup_wrapper((char **) roots, root_count, 1,
sizeof(struct BottomUp),
f, f, 0, 0, nullptr), 0);
}

TEST(BottomUp, bad) {
// bad user struct size
EXPECT_EQ(parallel_bottomup(nullptr, 0, 1,
sizeof(struct BottomUp) - 1,
f, f, 0, 0, nullptr
#if defined(DEBUG) && defined(PER_THREAD_STATS)
, nullptr
#endif
), -1);
EXPECT_EQ(parallel_bottomup_wrapper(nullptr, 0, 1,
sizeof(struct BottomUp) - 1,
f, f, 0, 0, nullptr), -1);

// bad thread count
EXPECT_EQ(parallel_bottomup(nullptr, 0, 0,
sizeof(struct BottomUp),
f, f, 0, 0, nullptr
#if defined(DEBUG) && defined(PER_THREAD_STATS)
, nullptr
#endif
), -1);
EXPECT_EQ(parallel_bottomup_wrapper(nullptr, 0, 0,
sizeof(struct BottomUp),
f, f, 0, 0, nullptr), -1);

/* no root dirs */
EXPECT_EQ(parallel_bottomup(nullptr, 0, 1,
sizeof(struct BottomUp),
f, f, 0, 0, nullptr
#if defined(DEBUG) && defined(PER_THREAD_STATS)
, nullptr
#endif
), 0);
EXPECT_EQ(parallel_bottomup_wrapper(nullptr, 0, 1,
sizeof(struct BottomUp),
f, f, 0, 0, nullptr), 0);

char badfilename[] = "@CMAKE_BINARY_DIR@/XXXXXX";
int fd = mkstemp(badfilename);
Expand All @@ -128,22 +133,14 @@ TEST(BottomUp, bad) {
const size_t root_count = sizeof(roots) / sizeof(roots[0]);

// root path is not directory
EXPECT_EQ(parallel_bottomup(roots, root_count, 1,
sizeof(struct BottomUp),
f, f, 0, 0, nullptr
#if defined(DEBUG) && defined(PER_THREAD_STATS)
, nullptr
#endif
), 0);
EXPECT_EQ(parallel_bottomup_wrapper(roots, root_count, 1,
sizeof(struct BottomUp),
f, f, 0, 0, nullptr), 0);

EXPECT_EQ(remove(badfilename), 0);

// root path doesn't exist
EXPECT_EQ(parallel_bottomup(roots, root_count, 1,
sizeof(struct BottomUp),
f, f, 0, 0, nullptr
#if defined(DEBUG) && defined(PER_THREAD_STATS)
, nullptr
#endif
), 0);
EXPECT_EQ(parallel_bottomup_wrapper(roots, root_count, 1,
sizeof(struct BottomUp),
f, f, 0, 0, nullptr), 0);
}
15 changes: 10 additions & 5 deletions test/unit/googletest/QueuePerThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@ TEST(QueuePerThreadPool, no_start_stop) {
QPTPool_destroy(pool);
}

/* C Standard 6.10.3/C++ Standard 16.3 Macro replacement */
static void *qptpool_init_with_props() {
return QPTPool_init_with_props(-1, nullptr, nullptr, nullptr, 0, 0, 0
#if defined(DEBUG) && defined(PER_THREAD_STATS)
, nullptr
#endif
);
}

TEST(QueuePreThreadPool, bad_init) {
EXPECT_EQ(QPTPool_init(-1, nullptr), nullptr);
EXPECT_EQ(QPTPool_init_with_props(-1, nullptr, nullptr, nullptr, 0, 0, 0
#if defined(DEBUG) && defined(PER_THREAD_STATS)
, nullptr
#endif
), nullptr);
EXPECT_EQ(qptpool_init_with_props(), nullptr);
}

TEST(QueuePerThreadPool, bad_start) {
Expand Down
14 changes: 6 additions & 8 deletions test/unit/googletest/template_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,9 @@ TEST(create_empty_dbdb, good) {
char dirname[] = "XXXXXX" ;
ASSERT_NE(mkdtemp(dirname), nullptr);

refstr_t dst = {
.data = dirname,
.len = strlen(dirname),
};
refstr_t dst;
dst.data = dirname;
dst.len = strlen(dirname);

// <dirname>/db.db
char dbname[MAXPATH];
Expand Down Expand Up @@ -221,10 +220,9 @@ TEST(create_empty_dbdb, path_is_file) {
ASSERT_GT(fd, -1);
EXPECT_EQ(close(fd), 0);

refstr_t dst = {
.data = filename,
.len = strlen(filename),
};
refstr_t dst;
dst.data = filename;
dst.len = strlen(filename);

// attempt to create file under file
EXPECT_EQ(create_empty_dbdb(nullptr, &dst, -1, -1), -1);
Expand Down

0 comments on commit 0635524

Please sign in to comment.