Skip to content

Commit

Permalink
Fixed some clang spotted warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeDP committed Mar 9, 2019
1 parent 1586139 commit 8e5199f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
16 changes: 8 additions & 8 deletions Samples/SharedSrc/mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ static void A_recv(const msg_t *msg, const void *userdata) {
switch (tolower(c)) {
case 'c':
module_log(selfA, "Doggo, come here!\n");
module_tell(selfA, selfB, "ComeHere", strlen("ComeHere"));
module_tell(selfA, selfB, (unsigned char *)"ComeHere", strlen("ComeHere"));
break;
case 'q':
module_log(selfA, "I have to go now!\n");
module_publish(selfA, "leaving", "ByeBye", strlen("ByeBye"));
module_publish(selfA, "leaving", (unsigned char *)"ByeBye", strlen("ByeBye"));
modules_ctx_quit("test", 0);
break;
default:
Expand All @@ -118,23 +118,23 @@ static void A_recv_ready(const msg_t *msg, const void *userdata) {
switch (tolower(c)) {
case 'p':
module_log(selfA, "Doggo, let's play a bit!\n");
module_tell(selfA, selfB, "LetsPlay", strlen("LetsPlay"));
module_tell(selfA, selfB, (unsigned char *)"LetsPlay", strlen("LetsPlay"));
break;
case 's':
module_log(selfA, "Doggo, you should sleep a bit!\n");
module_tell(selfA, selfB, "LetsSleep", strlen("LetsSleep"));
module_tell(selfA, selfB, (unsigned char *)"LetsSleep", strlen("LetsSleep"));
break;
case 'f':
module_log(selfA, "Doggo, you want some of these?\n");
module_tell(selfA, selfB, "LetsEat", strlen("LetsEat"));
module_tell(selfA, selfB, (unsigned char *)"LetsEat", strlen("LetsEat"));
break;
case 'w':
module_log(selfA, "Doggo, wake up!\n");
module_tell(selfA, selfB, "WakeUp", strlen("WakeUp"));
module_tell(selfA, selfB, (unsigned char *)"WakeUp", strlen("WakeUp"));
break;
case 'q':
module_log(selfA, "I have to go now!\n");
module_publish(selfA, "leaving", "ByeBye", strlen("ByeBye"));
module_publish(selfA, "leaving", (unsigned char *)"ByeBye", strlen("ByeBye"));
modules_ctx_quit("test", 0);
break;
default:
Expand All @@ -156,7 +156,7 @@ static void B_recv(const msg_t *msg, const void *userdata) {
case USER:
if (!strcmp((char *)msg->pubsub_msg->message, "ComeHere")) {
module_log(selfB, "Running...\n");
module_tell(selfB, msg->pubsub_msg->sender, "BauBau", strlen("BauBau"));
module_tell(selfB, msg->pubsub_msg->sender, (unsigned char *)"BauBau", strlen("BauBau"));
} else if (!strcmp((char *)msg->pubsub_msg->message, "LetsPlay")) {
module_log(selfB, "BauBau BauuBauuu!\n");
} else if (!strcmp((char *)msg->pubsub_msg->message, "LetsEat")) {
Expand Down
11 changes: 10 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
## 4.1.0
- [ ] PoisonPill message to automatically stop another module?

### New features
- [ ] Add an API to integrate module loop inside another loop
- [ ] modules_get_fd(const char *ctx)
- [ ] int num = modules_dispatch(ctx)
- [ ] fd should not be closed by client app (offer an api to close it?)
- [ ] Update Doc

### Fixes
- [x] In stack_clear and map_clear, avoid unsetting dtor
- [ ] Fix bsd build!

## Ideas
- [ ] Let contexts talk together? Eg: broadcast(msg, bool global) to send a message to all modules in every context; module_publish message in another context? etc etc
Expand Down
24 changes: 12 additions & 12 deletions tests/test_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@ void test_module_ref(void **state) {
void test_module_tell_NULL_recipient(void **state) {
(void) state; /* unused */

module_ret_code ret = module_tell(self, NULL, "hi!", strlen("hi!"));
module_ret_code ret = module_tell(self, NULL, (unsigned char *)"hi!", strlen("hi!"));
assert_false(ret == MOD_OK);
}

void test_module_tell_NULL_self(void **state) {
(void) state; /* unused */

module_ret_code ret = module_tell(NULL, testSelf, "hi!", strlen("hi!"));
module_ret_code ret = module_tell(NULL, testSelf, (unsigned char *)"hi!", strlen("hi!"));
assert_false(ret == MOD_OK);
}

Expand All @@ -346,21 +346,21 @@ void test_module_tell_NULL_msg(void **state) {
void test_module_tell_wrong_size(void **state) {
(void) state; /* unused */

module_ret_code ret = module_tell(self, testSelf, "hi!", -1);
module_ret_code ret = module_tell(self, testSelf, (unsigned char *)"hi!", -1);
assert_false(ret == MOD_OK);
}

void test_module_tell(void **state) {
(void) state; /* unused */

module_ret_code ret = module_tell(self, testSelf, "hi1!", strlen("hi!"));
module_ret_code ret = module_tell(self, testSelf, (unsigned char *)"hi1!", strlen("hi!"));
assert_true(ret == MOD_OK);
}

void test_module_publish_NULL_self(void **state) {
(void) state; /* unused */

module_ret_code ret = module_publish(NULL, "topic", "hi!", strlen("hi!"));
module_ret_code ret = module_publish(NULL, "topic", (unsigned char *)"hi!", strlen("hi!"));
assert_false(ret == MOD_OK);
}

Expand All @@ -374,35 +374,35 @@ void test_module_publish_NULL_msg(void **state) {
void test_module_publish_NULL_topic(void **state) {
(void) state; /* unused */

module_ret_code ret = module_publish(self, NULL, "hi!", strlen("hi!"));
module_ret_code ret = module_publish(self, NULL, (unsigned char *)"hi!", strlen("hi!"));
assert_false(ret == MOD_OK);
}

void test_module_publish_nonexistent_topic(void **state) {
(void) state; /* unused */

module_ret_code ret = module_publish(self, "topic", "hi!", strlen("hi!"));
module_ret_code ret = module_publish(self, "topic", (unsigned char *)"hi!", strlen("hi!"));
assert_false(ret == MOD_OK);
}

void test_module_publish_wrong_size(void **state) {
(void) state; /* unused */

module_ret_code ret = module_publish(self, "topic", "hi!", -1);
module_ret_code ret = module_publish(self, "topic", (unsigned char *)"hi!", -1);
assert_false(ret == MOD_OK);
}

void test_module_publish(void **state) {
(void) state; /* unused */

module_ret_code ret = module_publish(self, "topic", "hi2!", strlen("hi!"));
module_ret_code ret = module_publish(self, "topic", (unsigned char *)"hi2!", strlen("hi!"));
assert_true(ret == MOD_OK);
}

void test_module_broadcast_NULL_self(void **state) {
(void) state; /* unused */

module_ret_code ret = module_broadcast(NULL, "hi!", strlen("hi!"));
module_ret_code ret = module_broadcast(NULL, (unsigned char *)"hi!", strlen("hi!"));
assert_false(ret == MOD_OK);
}

Expand All @@ -416,14 +416,14 @@ void test_module_broadcast_NULL_msg(void **state) {
void test_module_broadcast_wrong_size(void **state) {
(void) state; /* unused */

module_ret_code ret = module_broadcast(self, "hi!", -1);
module_ret_code ret = module_broadcast(self, (unsigned char *)"hi!", -1);
assert_false(ret == MOD_OK);
}

void test_module_broadcast(void **state) {
(void) state; /* unused */

module_ret_code ret = module_broadcast(self, "hi3!", strlen("hi!"));
module_ret_code ret = module_broadcast(self, (unsigned char *)"hi3!", strlen("hi!"));
assert_true(ret == MOD_OK);
}

Expand Down

0 comments on commit 8e5199f

Please sign in to comment.