Skip to content

Commit 3397a53

Browse files
committed
Small imporvement in MOD_ASSERT macro. Updated TODO.
1 parent c6ac395 commit 3397a53

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

Lib/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static module_ret_code init_ctx(const char *ctx_name, m_context **context) {
2525
**context = (m_context) {0};
2626

2727
(*context)->fd = poll_create();
28-
MOD_ASSERT(((*context)->fd >= 0), "Failed to create context fd.", MOD_ERR);
28+
MOD_ASSERT((*context)->fd >= 0, "Failed to create context fd.", MOD_ERR);
2929

3030
(*context)->logger = default_logger;
3131

Lib/module_priv.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
#include "map.h"
33

44
#ifndef NDEBUG
5-
#define MOD_ASSERT(cond, msg, ret) if (!cond) { fprintf(stderr, "%s\n", msg); return ret; }
5+
#define MOD_ASSERT(cond, msg, ret) if (!(cond)) { fprintf(stderr, "%s\n", msg); return ret; }
66
#else
7-
#define MOD_ASSERT(cond, msg, ret) if (!cond) { return ret; }
7+
#define MOD_ASSERT(cond, msg, ret) if (!(cond)) { return ret; }
88
#endif
99

1010
#define MOD_ALLOC_ASSERT(cond) MOD_ASSERT(cond, "Failed to malloc.", MOD_NO_MEM);
11-
#define MOD_PARAM_ASSERT(cond) MOD_ASSERT((cond), #cond, MOD_WRONG_PARAM);
11+
#define MOD_PARAM_ASSERT(cond) MOD_ASSERT(cond, #cond, MOD_WRONG_PARAM);
1212

1313
#ifndef NDEBUG
1414
#define MODULE_DEBUG printf("Libmodule: "); printf

Lib/modules.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module_ret_code modules_ctx_set_logger(const char *ctx_name, const log_cb logger
5050
module_ret_code modules_ctx_loop_events(const char *ctx_name, const int max_events) {
5151
MOD_PARAM_ASSERT(max_events > 0);
5252
FIND_CTX(ctx_name);
53-
MOD_ASSERT((c->num_fds > 0), "No fds to loop on.", MOD_ERR);
53+
MOD_ASSERT(c->num_fds > 0, "No fds to loop on.", MOD_ERR);
5454
MOD_ASSERT(!c->looping, "Context already looping.", MOD_ERR);
5555

5656
if (poll_init_pevents(&c->pevents, max_events) == MOD_OK) {

TODO.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
- [x] Store context name in m_context (strdup'd)
77
- [x] Use them as hashmap key without strudpping again
88

9-
- [ ] Remove cycle between self and module: module shouldn't have a pointer to self.
10-
119
### Api improvements
1210
- [x] Add new MOD_NO_MEM error code
1311
- [x] Add new MOD_WRONG_PARAM error code
@@ -21,7 +19,6 @@
2119
## 3.2.0
2220
- [ ] Actually implement a stack for module_become/unbecome
2321
- [ ] Expose stack through a stack.h public header
24-
- [ ] Expose a list.h too? And use it for module's fds?
2522

2623
## 4.0.0 (?)
2724
- [ ] Prevent other modules from using a module's self_t (as received eg from a PubSub message)

0 commit comments

Comments
 (0)