Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation with -DHAVE_STATS=0 #5

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions deps/ccommon/include/cc_metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ extern "C" {
#define METRIC_DECLARE(_name, _type, _description)
#define METRIC_INIT(_name, _type, _description)
#define METRIC_NAME(_name, _type, _description)
#define INCR(_base, _metric)
#define DECR(_base, _metric)
#define INCR_N(_base, _metric, _delta)
#define DECR_N(_base, _metric, _delta)

#endif

Expand Down
2 changes: 2 additions & 0 deletions deps/ccommon/src/buffer/cc_dbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ static rstatus_t
_dbuf_resize(struct buf **buf, uint32_t nsize)
{
struct buf *nbuf;
#if defined CC_STATS && CC_STATS == 1
uint32_t size = buf_size(*buf);
#endif
uint32_t roffset = (*buf)->rpos - (*buf)->begin;
uint32_t woffset = (*buf)->wpos - (*buf)->begin;

Expand Down
2 changes: 2 additions & 0 deletions deps/ccommon/src/cc_rbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ rbuf_destroy(struct rbuf *buf)
log_verb("Destroy ring buffer %p", buf);

if (buf != NULL) {
#if defined CC_STATS && CC_STATS == 1

This comment was marked as spam.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the warning:

/home/seppo/Projects/pelikan/deps/ccommon/src/cc_rbuf.c: In function 'rbuf_destroy':
/home/seppo/Projects/pelikan/deps/ccommon/src/cc_rbuf.c:99:18: warning: unused variable 'cap' [-Wunused-variable]
         uint32_t cap = buf->cap;

This comment was marked as spam.

uint32_t cap = buf->cap;
#endif

cc_free(buf);
INCR(rbuf_metrics, rbuf_destroy);
Expand Down
4 changes: 3 additions & 1 deletion src/util/procinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ procinfo_teardown(void)
procinfo_init = false;
}

#if defined CC_STATS && CC_STATS == 1

This comment was marked as spam.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? I believe (didn't check again) it'll fail to compile if it references structsb properties that do not exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, just confirmed

/Users/swaisbrot/workspace/pelikan/src/util/procinfo.c:48:1: warning: no previous prototype for function '_procinfo_update' [-Wmissing-prototypes]
_procinfo_update(void)
^
/Users/swaisbrot/workspace/pelikan/src/util/procinfo.c:52:23: error: no member named 'pid' in 'procinfo_metrics_st'
    procinfo_metrics->pid.vintmax         = (intmax_t)getpid();
    ~~~~~~~~~~~~~~~~  ^
/Users/swaisbrot/workspace/pelikan/src/util/procinfo.c:53:23: error: no member named 'time' in 'procinfo_metrics_st'
    procinfo_metrics->time.vintmax        = (intmax_t)time_now_abs();
    ~~~~~~~~~~~~~~~~  ^

(and a bunch more)

void
procinfo_update(void)
_procinfo_update(void)
{
struct rusage usage;

Expand Down Expand Up @@ -78,3 +79,4 @@ procinfo_update(void)
procinfo_metrics->ru_nvcsw.vintmax = (intmax_t)usage.ru_nvcsw;
procinfo_metrics->ru_nivcsw.vintmax = (intmax_t)usage.ru_nivcsw;
}
#endif
7 changes: 6 additions & 1 deletion src/util/procinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ typedef struct {
void procinfo_setup(procinfo_metrics_st *procinfo_metrics);
void procinfo_teardown(void);

void procinfo_update(void);
#if defined CC_STATS && CC_STATS == 1
void _procinfo_update(void);

This comment was marked as spam.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you trying to fix the warning in #5 (comment) but ignoring the errors? 😀 the problem is not that it has a warning, the problem is it does not compile because cc_metric.h defines METRIC_DECLARE empty when CC_STATS is off, thus the properties used in that function do not exist (pid, time and a few more).

This comment was marked as spam.

This comment was marked as spam.

#define procinfo_update() _procinfo_update()
#else
#define procinfo_update()
#endif
1 change: 1 addition & 0 deletions test/storage/cuckoo/check_cuckoo.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ START_TEST(test_insert_insert_expire_swap)
#undef NOW
}
END_TEST

/*
* test suite
*/
Expand Down