Skip to content

Commit 86a9466

Browse files
committed
Renamed userhook type to userhook_t.
1 parent 29aa0c9 commit 86a9466

File tree

9 files changed

+16
-15
lines changed

9 files changed

+16
-15
lines changed

Lib/module.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ module_ret_code stop(mod_t *mod, const bool stop) {
258258

259259
/** Public API **/
260260

261-
module_ret_code module_register(const char *name, const char *ctx_name, self_t **self, const userhook *hook) {
261+
module_ret_code module_register(const char *name, const char *ctx_name, self_t **self, const userhook_t *hook) {
262262
MOD_PARAM_ASSERT(name);
263263
MOD_PARAM_ASSERT(ctx_name);
264264
MOD_PARAM_ASSERT(self);
@@ -281,7 +281,7 @@ module_ret_code module_register(const char *name, const char *ctx_name, self_t *
281281
while (true) {
282282
mod->name = name;
283283

284-
memcpy(&mod->hook, hook, sizeof(userhook));
284+
memcpy(&mod->hook, hook, sizeof(userhook_t));
285285
mod->state = IDLE;
286286
mod->fds = NULL;
287287

Lib/priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ typedef struct {
9696

9797
/* Struct that holds data for each module */
9898
struct _module {
99-
userhook hook; // module's user defined callbacks
99+
userhook_t hook; // module's user defined callbacks
100100
stack_t *recvs; // Stack of recv functions for module_become/unbecome
101101
const void *userdata; // module's user defined data
102102
enum module_states state; // module's state

Lib/public/module/module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern "C"{
99
#endif
1010

1111
/* Module registration */
12-
_public_ module_ret_code module_register(const char *name, const char *ctx_name, self_t **self, const userhook *hook);
12+
_public_ module_ret_code module_register(const char *name, const char *ctx_name, self_t **self, const userhook_t *hook);
1313
_public_ module_ret_code module_deregister(self_t **self);
1414

1515
/* External shared object module runtime loading */

Lib/public/module/module_cmn.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ typedef struct {
8989
evaluate_cb evaluate; // module's state changed function
9090
recv_cb recv; // module's recv function
9191
destroy_cb destroy; // module's destroy function
92-
} userhook;
92+
} userhook_t;
9393

9494
/* Struct that holds user defined memory functions */
9595
typedef struct {

Lib/public/module/module_easy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static void destroy(void); \
1414
static const self_t *_self = NULL; \
1515
static void _ctor3_ constructor(void) { \
1616
if (check()) { \
17-
userhook hook = { init, evaluate, receive, destroy }; \
17+
userhook_t hook = { init, evaluate, receive, destroy }; \
1818
module_register(name, ctx, (self_t **)&self(), &hook); \
1919
} \
2020
} \

Samples/SharedSrc/mod.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ static self_t *selfA, *selfB;
2424
* These modules can share some callbacks.
2525
*/
2626
void create_modules(const char *ctx_name) {
27-
userhook hookA = (userhook) { A_init, evaluate, A_recv, destroy };
28-
userhook hookB = (userhook) { B_init, evaluate, B_recv, destroy };
27+
userhook_t hookA = (userhook_t) { A_init, evaluate, A_recv, destroy };
28+
userhook_t hookB = (userhook_t) { B_init, evaluate, B_recv, destroy };
2929

3030
module_register("Pippo", ctx_name, &selfA, &hookA);
3131
module_register("Doggo", ctx_name, &selfB, &hookB);

TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ conversely to module_stop that should stop module right away freeing all its enq
7272
- [x] Rename module_poll_t to fd_priv_t
7373
- [x] FIX: avoid sending with MODULE_STOPPED pubsub message a not-exishtent reference to mod->self when deregistering, as module gets freed right after. Send NULL.
7474
- [x] FIX: when deregistering, remove module from context before stopping it
75+
- [x] Rename userhook to userhook_t, following other types
7576

7677
### Doc
7778
- [x] module_dump

docs/src/data_structures.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Types
6969
evaluate_cb evaluate; // module's state changed function
7070
recv_cb recv; // module's recv function
7171
destroy_cb destroy; // module's destroy function
72-
} userhook;
72+
} userhook_t;
7373
7474
/* Struct that holds user defined memory functions */
7575
typedef struct {

tests/test_module.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const self_t *testSelf = NULL;
1818
void test_module_register_NULL_name(void **state) {
1919
(void) state; /* unused */
2020

21-
userhook hook = (userhook) { init, evaluate, recv, destroy };
21+
userhook_t hook = (userhook_t) { init, evaluate, recv, destroy };
2222
module_ret_code ret = module_register(NULL, CTX, &self, &hook);
2323
assert_false(ret == MOD_OK);
2424
assert_null(self);
@@ -27,7 +27,7 @@ void test_module_register_NULL_name(void **state) {
2727
void test_module_register_NULL_ctx(void **state) {
2828
(void) state; /* unused */
2929

30-
userhook hook = (userhook) { init, evaluate, recv, destroy };
30+
userhook_t hook = (userhook_t) { init, evaluate, recv, destroy };
3131
module_ret_code ret = module_register("testName", NULL, &self, &hook);
3232
assert_false(ret == MOD_OK);
3333
assert_null(self);
@@ -36,7 +36,7 @@ void test_module_register_NULL_ctx(void **state) {
3636
void test_module_register_NULL_self(void **state) {
3737
(void) state; /* unused */
3838

39-
userhook hook = (userhook) { init, evaluate, recv, destroy };
39+
userhook_t hook = (userhook_t) { init, evaluate, recv, destroy };
4040
module_ret_code ret = module_register("testName", CTX, NULL, &hook);
4141
assert_false(ret == MOD_OK);
4242
assert_null(self);
@@ -53,7 +53,7 @@ void test_module_register_NULL_hook(void **state) {
5353
void test_module_register(void **state) {
5454
(void) state; /* unused */
5555

56-
userhook hook = (userhook) { init, evaluate, recv, destroy };
56+
userhook_t hook = (userhook_t) { init, evaluate, recv, destroy };
5757
module_ret_code ret = module_register("testName", CTX, &self, &hook);
5858
assert_true(ret == MOD_OK);
5959
assert_non_null(self);
@@ -63,7 +63,7 @@ void test_module_register(void **state) {
6363
void test_module_register_already_registered(void **state) {
6464
(void) state; /* unused */
6565

66-
userhook hook = (userhook) { init, evaluate, recv, destroy };
66+
userhook_t hook = (userhook_t) { init, evaluate, recv, destroy };
6767
module_ret_code ret = module_register("testName", CTX, &self, &hook);
6868
assert_false(ret == MOD_OK);
6969
assert_non_null(self);
@@ -75,7 +75,7 @@ void test_module_register_same_name(void **state) {
7575

7676
self_t *self2 = NULL;
7777

78-
userhook hook = (userhook) { init, evaluate, recv, destroy };
78+
userhook_t hook = (userhook_t) { init, evaluate, recv, destroy };
7979
module_ret_code ret = module_register("testName", CTX, &self2, &hook);
8080
assert_false(ret == MOD_OK);
8181
assert_null(self2);

0 commit comments

Comments
 (0)