From 1e8e54a3bad1bebd802cc2f7dd2ab0374232f452 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 20 Mar 2023 14:32:51 +1100 Subject: [PATCH 01/10] 71 add cfg to IpcResponse --- examples/example_client.c | 6 +++--- inc/ipc.h | 3 ++- src/client.c | 5 ++++- src/ipc.c | 2 ++ src/marshalling.cpp | 7 ++++++- src/server.c | 4 ++-- tst/marshalling/cfg-all.yaml | 1 + tst/marshalling/ipc-request-cfg-set.yaml | 1 + tst/marshalling/ipc-request-get.yaml | 1 + tst/marshalling/ipc-response-ok.yaml | 1 + tst/tst-marshalling.c | 19 +++++++++++-------- 11 files changed, 34 insertions(+), 16 deletions(-) diff --git a/examples/example_client.c b/examples/example_client.c index 745d602..e009469 100644 --- a/examples/example_client.c +++ b/examples/example_client.c @@ -104,7 +104,7 @@ CFG:\n\ execute(CFG_DEL, request); } -void usage(void) { +void example_usage(void) { fprintf(stderr, "Usage: example_client \n"); exit(1); } @@ -114,7 +114,7 @@ main(int argc, char **argv) { log_set_threshold(DEBUG, true); if (argc != 2) { - usage(); + example_usage(); } void (*fn)(void); @@ -127,7 +127,7 @@ main(int argc, char **argv) { } else if (strcmp(argv[1], ipc_request_op_name(CFG_DEL)) == 0) { fn = cfg_del; } else { - usage(); + example_usage(); } if (!getenv("WAYLAND_DISPLAY")) { diff --git a/inc/ipc.h b/inc/ipc.h index f9ab058..0a7c175 100644 --- a/inc/ipc.h +++ b/inc/ipc.h @@ -29,7 +29,8 @@ struct IpcResponse { int rc; int fd; bool messages; - bool status; + bool state; + struct Cfg *cfg; }; int ipc_request_send(struct IpcRequest *request); diff --git a/src/client.c b/src/client.c index 3e96cba..393649c 100644 --- a/src/client.c +++ b/src/client.c @@ -42,13 +42,16 @@ int client(struct IpcRequest *ipc_request) { if (ipc_response) { rc = ipc_response->rc; done = ipc_response->done; - ipc_response_free(ipc_response); } else { rc = IPC_RC_BAD_RESPONSE; done = true; } } + if (ipc_response) { + ipc_response_free(ipc_response); + } + close(fd); end: diff --git a/src/ipc.c b/src/ipc.c index c3c2e3c..8176de8 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -121,6 +121,8 @@ void ipc_response_free(struct IpcResponse *response) { return; } + cfg_free(response->cfg); + free(response); } diff --git a/src/marshalling.cpp b/src/marshalling.cpp index d50e537..8b88e98 100644 --- a/src/marshalling.cpp +++ b/src/marshalling.cpp @@ -498,7 +498,7 @@ char *marshal_ipc_response(struct IpcResponse *response) { e << YAML::Key << "DONE" << YAML::Value << response->done; - if (response->status) { + if (response->state) { if (cfg) { e << YAML::Key << "CFG" << YAML::BeginMap; // CFG e << *cfg; @@ -607,6 +607,11 @@ struct IpcResponse *unmarshal_ipc_response(char *yaml) { } } } + + if (i->first.as() == "CFG") { + response->cfg = (struct Cfg*)calloc(1, sizeof(struct Cfg)); + cfg_parse_node(response->cfg, i->second); + } } } catch (const std::exception &e) { diff --git a/src/server.c b/src/server.c index b7570d2..bf6a908 100644 --- a/src/server.c +++ b/src/server.c @@ -85,11 +85,11 @@ void handle_ipc_request(int fd_sock) { ipc_response->fd = ipc_request->fd; ipc_response->done = true; ipc_response->messages = true; - ipc_response->status = true; + ipc_response->state = true; if (ipc_request->bad) { ipc_response->rc = IPC_RC_BAD_REQUEST; - ipc_response->status = false; + ipc_response->state = false; goto send; } diff --git a/tst/marshalling/cfg-all.yaml b/tst/marshalling/cfg-all.yaml index 01317cb..ed3c8b4 100644 --- a/tst/marshalling/cfg-all.yaml +++ b/tst/marshalling/cfg-all.yaml @@ -25,3 +25,4 @@ DISABLED: - EIGHT - nine LOG_THRESHOLD: ERROR + diff --git a/tst/marshalling/ipc-request-cfg-set.yaml b/tst/marshalling/ipc-request-cfg-set.yaml index 0f73b7a..0038e94 100644 --- a/tst/marshalling/ipc-request-cfg-set.yaml +++ b/tst/marshalling/ipc-request-cfg-set.yaml @@ -27,3 +27,4 @@ CFG: - EIGHT - nine LOG_THRESHOLD: ERROR + diff --git a/tst/marshalling/ipc-request-get.yaml b/tst/marshalling/ipc-request-get.yaml index f4ee8b4..14d74b3 100644 --- a/tst/marshalling/ipc-request-get.yaml +++ b/tst/marshalling/ipc-request-get.yaml @@ -1 +1,2 @@ OP: GET + diff --git a/tst/marshalling/ipc-response-ok.yaml b/tst/marshalling/ipc-response-ok.yaml index 7435112..7b1c0c8 100644 --- a/tst/marshalling/ipc-response-ok.yaml +++ b/tst/marshalling/ipc-response-ok.yaml @@ -67,3 +67,4 @@ MESSAGES: WARNING: war ERROR: err RC: 2 + diff --git a/tst/tst-marshalling.c b/tst/tst-marshalling.c index c27a823..7a3bb8b 100644 --- a/tst/tst-marshalling.c +++ b/tst/tst-marshalling.c @@ -38,7 +38,7 @@ char *read_file(const char *path) { char *out = calloc(len, sizeof(char)); - memcpy(out, mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0), sizeof(char) * len); + memcpy(out, mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0), sizeof(char) * len - 1); close(fd); @@ -64,7 +64,6 @@ int after_each(void **state) { cfg = NULL; free(lid); lid = NULL; - slist_free(&heads); return 0; } @@ -181,15 +180,15 @@ void unmarshal_cfg_from_file__bad(void **state) { } void marshal_cfg__ok(void **state) { - struct Cfg *cfg = cfg_all(); + struct Cfg *cfg_actual = cfg_all(); - char *actual = marshal_cfg(cfg); + char *actual = marshal_cfg(cfg_actual); char *expected = read_file("tst/marshalling/cfg-all.yaml"); assert_string_equal(actual, expected); - cfg_free(cfg); + cfg_free(cfg_actual); free(actual); free(expected); } @@ -222,8 +221,7 @@ void marshal_ipc_request__cfg_set(void **state) { struct IpcRequest *ipc_request = calloc(1, sizeof(struct IpcRequest)); ipc_request->op = CFG_SET; - struct Cfg *cfg = cfg_all(); - ipc_request->cfg = cfg; + ipc_request->cfg = cfg_all(); char *actual = marshal_ipc_request(ipc_request); @@ -241,7 +239,7 @@ void marshal_ipc_response__ok(void **state) { ipc_response->done = true; ipc_response->rc = 1; ipc_response->messages = true; - ipc_response->status = true; + ipc_response->state = true; cfg = cfg_all(); @@ -307,6 +305,7 @@ void marshal_ipc_response__ok(void **state) { free(actual); free(expected); slist_free(&head.modes); + slist_free(&heads); } void unmarshal_ipc_request__empty(void **state) { @@ -419,8 +418,12 @@ void unmarshal_ipc_response__ok(void **state) { assert_true(actual->done); assert_int_equal(actual->rc, 2); + struct Cfg *cfg_expected = cfg_all(); + assert_equal_cfg(actual->cfg, cfg_expected); + ipc_response_free(actual); free(yaml); + cfg_free(cfg_expected); } int main(void) { From 24227b57c09093fe7f861b81d1dee2effe046246 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 20 Mar 2023 14:51:11 +1100 Subject: [PATCH 02/10] 71 fix test memory leaks --- src/cli.c | 3 +++ tst/tst-cli.c | 18 ++++++++++++++---- tst/tst-head.c | 15 +++++++++++++++ tst/tst-layout.c | 3 +++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/cli.c b/src/cli.c index 4fa1ecf..991cd0e 100644 --- a/src/cli.c +++ b/src/cli.c @@ -134,6 +134,9 @@ struct Cfg *parse_element(enum IpcRequestOperation op, enum CfgElement element, bp += snprintf(bp, sizeof(buf) - (bp - buf), " %s", argv[i]); } log_error("invalid %s%s", cfg_element_name(element), buf); + if (cfg) { + cfg_free(cfg); + } wd_exit(EXIT_FAILURE); return NULL; } diff --git a/tst/tst-cli.c b/tst/tst-cli.c index d4e7006..e8b3202 100644 --- a/tst/tst-cli.c +++ b/tst/tst-cli.c @@ -197,7 +197,8 @@ void parse_element__mode_set_max(void **state) { cfg_free(actual); - slist_free(&expected.user_scales); + slist_free(&expected.user_modes); + cfg_user_mode_free(expectedUserMode); } void parse_element__mode_set_res(void **state) { @@ -219,7 +220,8 @@ void parse_element__mode_set_res(void **state) { cfg_free(actual); - slist_free(&expected.user_scales); + slist_free(&expected.user_modes); + cfg_user_mode_free(expectedUserMode); } void parse_element__mode_set_res_refresh(void **state) { @@ -242,7 +244,8 @@ void parse_element__mode_set_res_refresh(void **state) { cfg_free(actual); - slist_free(&expected.user_scales); + slist_free(&expected.user_modes); + cfg_user_mode_free(expectedUserMode); } void parse_element__mode_del_ok(void **state) { @@ -262,7 +265,8 @@ void parse_element__mode_del_ok(void **state) { cfg_free(actual); - slist_free(&expected.user_scales); + slist_free(&expected.user_modes); + cfg_user_mode_free(expectedUserMode); } void parse_element__disabled_ok(void **state) { @@ -316,6 +320,8 @@ void parse_write__ok(void **state) { assert_non_null(request); assert_int_equal(request->op, CFG_WRITE); + + ipc_request_free(request); } void parse_set__mode_nargs(void **state) { @@ -403,6 +409,8 @@ void parse_set__ok(void **state) { assert_non_null(request); assert_int_equal(request->op, CFG_SET); + + ipc_request_free(request); } void parse_del__mode_nargs(void **state) { @@ -455,6 +463,8 @@ void parse_del__ok(void **state) { assert_non_null(request); assert_int_equal(request->op, CFG_DEL); + + ipc_request_free(request); } void parse_log_threshold__invalid(void **state) { diff --git a/tst/tst-head.c b/tst/tst-head.c index 025ee23..68ff273 100644 --- a/tst/tst-head.c +++ b/tst/tst-head.c @@ -139,6 +139,9 @@ void head_find_mode__none(void **state) { slist_append(&head.modes, &mode); slist_append(&head.modes_failed, &mode); assert_null(head_find_mode(&head)); + + slist_free(&head.modes); + slist_free(&head.modes_failed); } void head_find_mode__user_available(void **state) { @@ -160,6 +163,9 @@ void head_find_mode__user_available(void **state) { will_return(__wrap_mode_user_mode, &expected); assert_ptr_equal(head_find_mode(&head), &expected); + + slist_free(&head.modes); + free(head.name); } void head_find_mode__user_failed(void **state) { @@ -194,6 +200,9 @@ void head_find_mode__user_failed(void **state) { // no notices this time assert_ptr_equal(head_find_mode(&head), &mode); + + slist_free(&head.modes); + free(head.name); } void head_find_mode__preferred(void **state) { @@ -203,6 +212,8 @@ void head_find_mode__preferred(void **state) { slist_append(&head.modes, &mode); assert_ptr_equal(head_find_mode(&head), &mode); + + slist_free(&head.modes); } void head_find_mode__max_preferred_refresh(void **state) { @@ -217,6 +228,8 @@ void head_find_mode__max_preferred_refresh(void **state) { will_return(__wrap_mode_max_preferred, &mode); assert_ptr_equal(head_find_mode(&head), &mode); + + slist_free(&head.modes); } void head_find_mode__max(void **state) { @@ -232,6 +245,8 @@ void head_find_mode__max(void **state) { // no notice assert_ptr_equal(head_find_mode(&head), &mode); + + slist_free(&head.modes); } int main(void) { diff --git a/tst/tst-layout.c b/tst/tst-layout.c index a51a280..75596e7 100644 --- a/tst/tst-layout.c +++ b/tst/tst-layout.c @@ -133,6 +133,7 @@ void order_heads__exact_partial_regex(void **state) { slist_free_vals(&order_name_desc, NULL); slist_free(&heads); + slist_free(&expected); slist_free(&heads_ordered); } @@ -175,6 +176,7 @@ void order_heads__exact_regex_catchall(void **state) { slist_free_vals(&order_name_desc, NULL); slist_free(&heads); + slist_free(&expected); slist_free(&heads_ordered); } @@ -188,6 +190,7 @@ void order_heads__no_order(void **state) { struct SList *heads_ordered = order_heads(NULL, heads); assert_heads_equal(heads_ordered, heads); + slist_free(&heads_ordered); slist_free(&heads); } From b873eb33ededcfa8a9bf12f5ad17ca10c83b6498 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 20 Mar 2023 15:36:30 +1100 Subject: [PATCH 03/10] 71 use macros for logs for better error discoverability --- tst/expects.h | 45 ++++++++++++++-- tst/tst-cfg.c | 18 +++---- tst/tst-marshalling.c | 12 ++--- tst/wrap-log.c | 116 ------------------------------------------ 4 files changed, 55 insertions(+), 136 deletions(-) diff --git a/tst/expects.h b/tst/expects.h index 64433bc..6c8ed3b 100644 --- a/tst/expects.h +++ b/tst/expects.h @@ -10,10 +10,45 @@ #include "log.h" -void expect_log_(enum LogThreshold threshold, const char *__restrict __format, const void *arg1, const void *arg2, const void *arg3, const void *arg4, ...); -void expect_log_info(const char *__restrict __format, const void *arg1, const void *arg2, const void *arg3, const void *arg4, ...); -void expect_log_warn(const char *__restrict __format, const void *arg1, const void *arg2, const void *arg3, const void *arg4, ...); -void expect_log_error(const char *__restrict __format, const void *arg1, const void *arg2, const void *arg3, const void *arg4, ...); -void expect_log_error_nocap(const char *__restrict __format, const void *arg1, const void *arg2, const void *arg3, const void *arg4, ...); +#define expect_log(fn, f, a1, a2, a3, a4) \ + if (f) \ + expect_string(fn, __format, f); \ + else \ + expect_any(fn, __format); \ + if (a1) \ + expect_string(fn, arg1, a1); \ + else \ + expect_any(fn, arg1); \ + if (a2) \ + expect_string(fn, arg2, a2); \ + else \ + expect_any(fn, arg2); \ + if (a3) \ + expect_string(fn, arg3, a3); \ + else \ + expect_any(fn, arg3); \ + if (a4) \ + expect_string(fn, arg4, a4); \ + else \ + expect_any(fn, arg4); + +#define expect_log_debug(f, a1, a2, a3, a4) \ + expect_log(__wrap_log_debug, f, a1, a2, a3, a4) + +#define expect_log_info(f, a1, a2, a3, a4) \ + expect_log(__wrap_log_info, f, a1, a2, a3, a4) + +#define expect_log_warn(f, a1, a2, a3, a4) \ + expect_log(__wrap_log_warn, f, a1, a2, a3, a4) + +#define expect_log_error(f, a1, a2, a3, a4) \ + expect_log(__wrap_log_error, f, a1, a2, a3, a4) + +#define expect_log_error_nocap(f, a1, a2, a3, a4) \ + expect_log(__wrap_log_error_nocap, f, a1, a2, a3, a4) + +#define expect_log_(t, f, a1, a2, a3, a4) \ + expect_value(__wrap_log_, threshold, t); \ + expect_log(__wrap_log_, f, a1, a2, a3, a4) #endif // EXPECTS_H diff --git a/tst/tst-cfg.c b/tst/tst-cfg.c index c5b1ee6..8beefda 100644 --- a/tst/tst-cfg.c +++ b/tst/tst-cfg.c @@ -255,15 +255,15 @@ void validate_fix__row(void **state) { void validate_fix__scale(void **state) { struct State *s = *state; - char FMT[] = "\nIgnoring non-positive SCALE %s %.3f"; + char *fmt = "\nIgnoring non-positive SCALE %s %.3f"; slist_append(&s->from->user_scales, cfg_user_scale_init("ok", 1)); slist_append(&s->from->user_scales, cfg_user_scale_init("neg", -1)); - expect_log_warn(FMT, "neg", NULL, NULL, NULL); + expect_log_warn(fmt, "neg", NULL, NULL, NULL); slist_append(&s->from->user_scales, cfg_user_scale_init("zero", 0)); - expect_log_warn(FMT, "zero", NULL, NULL, NULL); + expect_log_warn(fmt, "zero", NULL, NULL, NULL); validate_fix(s->from); @@ -304,27 +304,27 @@ void validate_fix__mode(void **state) { void validate_warn__(void **state) { struct State *s = *state; - char FMT[] = "\n%s '%s' is less than 4 characters, which may result in some unwanted matches."; + char *fmt = "\n%s '%s' is less than 4 characters, which may result in some unwanted matches."; slist_append(&s->expected->user_scales, cfg_user_scale_init("sss", 1)); slist_append(&s->expected->user_scales, cfg_user_scale_init("ssssssss", 2)); - expect_log_warn(FMT, "SCALE", "sss", NULL, NULL); + expect_log_warn(fmt, "SCALE", "sss", NULL, NULL); slist_append(&s->expected->user_modes, cfg_user_mode_init("mmm", false, 1, 1, 1, false)); slist_append(&s->expected->user_modes, cfg_user_mode_init("mmmmmmmm", false, 1, 1, 1, false)); - expect_log_warn(FMT, "MODE", "mmm", NULL, NULL); + expect_log_warn(fmt, "MODE", "mmm", NULL, NULL); slist_append(&s->expected->order_name_desc, strdup("ooo")); slist_append(&s->expected->order_name_desc, strdup("oooooooooo")); - expect_log_warn(FMT, "ORDER", "ooo", NULL, NULL); + expect_log_warn(fmt, "ORDER", "ooo", NULL, NULL); slist_append(&s->expected->max_preferred_refresh_name_desc, strdup("ppp")); slist_append(&s->expected->max_preferred_refresh_name_desc, strdup("pppppppppp")); - expect_log_warn(FMT, "MAX_PREFERRED_REFRESH", "ppp", NULL, NULL); + expect_log_warn(fmt, "MAX_PREFERRED_REFRESH", "ppp", NULL, NULL); slist_append(&s->expected->disabled_name_desc, strdup("ddd")); slist_append(&s->expected->disabled_name_desc, strdup("dddddddddd")); - expect_log_warn(FMT, "DISABLED", "ddd", NULL, NULL); + expect_log_warn(fmt, "DISABLED", "ddd", NULL, NULL); validate_warn(s->expected); } diff --git a/tst/tst-marshalling.c b/tst/tst-marshalling.c index 7a3bb8b..6ece081 100644 --- a/tst/tst-marshalling.c +++ b/tst/tst-marshalling.c @@ -309,7 +309,7 @@ void marshal_ipc_response__ok(void **state) { } void unmarshal_ipc_request__empty(void **state) { - char yaml[] = ""; + char *yaml = ""; expect_log_error(NULL, "empty request", NULL, NULL, NULL); expect_log_error_nocap(NULL, yaml, NULL, NULL, NULL); @@ -320,7 +320,7 @@ void unmarshal_ipc_request__empty(void **state) { } void unmarshal_ipc_request__bad_op(void **state) { - char yaml[] = "OP: aoeu"; + char *yaml = "OP: aoeu"; expect_log_error(NULL, "invalid OP 'aoeu'", NULL, NULL, NULL); expect_log_error_nocap(NULL, yaml, NULL, NULL, NULL); @@ -331,7 +331,7 @@ void unmarshal_ipc_request__bad_op(void **state) { } void unmarshal_ipc_request__no_op(void **state) { - char yaml[] = "FOO: BAR"; + char *yaml = "FOO: BAR"; expect_log_error(NULL, "missing OP", NULL, NULL, NULL); expect_log_error_nocap(NULL, yaml, NULL, NULL, NULL); @@ -372,7 +372,7 @@ void unmarshal_ipc_request__cfg_set(void **state) { } void unmarshal_ipc_response__empty(void **state) { - char yaml[] = ""; + char *yaml = ""; expect_log_error(NULL, "invalid response", NULL, NULL, NULL); expect_log_error_nocap(NULL, yaml, NULL, NULL, NULL); @@ -383,7 +383,7 @@ void unmarshal_ipc_response__empty(void **state) { } void unmarshal_ipc_response__no_done(void **state) { - char yaml[] = "RC: 0"; + char *yaml = "RC: 0"; expect_log_error(NULL, "DONE missing", NULL, NULL, NULL); expect_log_error_nocap(NULL, yaml, NULL, NULL, NULL); @@ -394,7 +394,7 @@ void unmarshal_ipc_response__no_done(void **state) { } void unmarshal_ipc_response__no_rc(void **state) { - char yaml[] = "DONE: TRUE"; + char *yaml = "DONE: TRUE"; expect_log_error(NULL, "RC missing", NULL, NULL, NULL); expect_log_error_nocap(NULL, yaml, NULL, NULL, NULL); diff --git a/tst/wrap-log.c b/tst/wrap-log.c index e1dd33a..4254492 100644 --- a/tst/wrap-log.c +++ b/tst/wrap-log.c @@ -73,119 +73,3 @@ void __wrap_log_error_nocap(const char *__restrict __format, const void *arg1, c check_expected(arg4); } -// mucking about with macros here is not worth the trouble -void expect_log_(enum LogThreshold threshold, const char *__restrict __format, const void *arg1, const void *arg2, const void *arg3, const void *arg4, ...) { - expect_value(__wrap_log_, threshold, threshold); - if (__format) - expect_string(__wrap_log_, __format, __format); - else - expect_any(__wrap_log_, __format); - if (arg1) - expect_string(__wrap_log_, arg1, arg1); - else - expect_any(__wrap_log_, arg1); - if (arg2) - expect_string(__wrap_log_, arg2, arg2); - else - expect_any(__wrap_log_, arg2); - if (arg3) - expect_string(__wrap_log_, arg3, arg3); - else - expect_any(__wrap_log_, arg3); - if (arg4) - expect_string(__wrap_log_, arg4, arg4); - else - expect_any(__wrap_log_, arg4); -} - -void expect_log_info(const char *__restrict __format, const void *arg1, const void *arg2, const void *arg3, const void *arg4, ...) { - if (__format) - expect_string(__wrap_log_info, __format, __format); - else - expect_any(__wrap_log_info, __format); - if (arg1) - expect_string(__wrap_log_info, arg1, arg1); - else - expect_any(__wrap_log_info, arg1); - if (arg2) - expect_string(__wrap_log_info, arg2, arg2); - else - expect_any(__wrap_log_info, arg2); - if (arg3) - expect_string(__wrap_log_info, arg3, arg3); - else - expect_any(__wrap_log_info, arg3); - if (arg4) - expect_string(__wrap_log_info, arg4, arg4); - else - expect_any(__wrap_log_info, arg4); -} - -void expect_log_warn(const char *__restrict __format, const void *arg1, const void *arg2, const void *arg3, const void *arg4, ...) { - if (__format) - expect_string(__wrap_log_warn, __format, __format); - else - expect_any(__wrap_log_warn, __format); - if (arg1) - expect_string(__wrap_log_warn, arg1, arg1); - else - expect_any(__wrap_log_warn, arg1); - if (arg2) - expect_string(__wrap_log_warn, arg2, arg2); - else - expect_any(__wrap_log_warn, arg2); - if (arg3) - expect_string(__wrap_log_warn, arg3, arg3); - else - expect_any(__wrap_log_warn, arg3); - if (arg4) - expect_string(__wrap_log_warn, arg4, arg4); - else - expect_any(__wrap_log_warn, arg4); -} - -void expect_log_error(const char *__restrict __format, const void *arg1, const void *arg2, const void *arg3, const void *arg4, ...) { - if (__format) - expect_string(__wrap_log_error, __format, __format); - else - expect_any(__wrap_log_error, __format); - if (arg1) - expect_string(__wrap_log_error, arg1, arg1); - else - expect_any(__wrap_log_error, arg1); - if (arg2) - expect_string(__wrap_log_error, arg2, arg2); - else - expect_any(__wrap_log_error, arg2); - if (arg3) - expect_string(__wrap_log_error, arg3, arg3); - else - expect_any(__wrap_log_error, arg3); - if (arg4) - expect_string(__wrap_log_error, arg4, arg4); - else - expect_any(__wrap_log_error, arg4); -} - -void expect_log_error_nocap(const char *__restrict __format, const void *arg1, const void *arg2, const void *arg3, const void *arg4, ...) { - if (__format) - expect_string(__wrap_log_error_nocap, __format, __format); - else - expect_any(__wrap_log_error_nocap, __format); - if (arg1) - expect_string(__wrap_log_error_nocap, arg1, arg1); - else - expect_any(__wrap_log_error_nocap, arg1); - if (arg2) - expect_string(__wrap_log_error_nocap, arg2, arg2); - else - expect_any(__wrap_log_error_nocap, arg2); - if (arg3) - expect_string(__wrap_log_error_nocap, arg3, arg3); - else - expect_any(__wrap_log_error_nocap, arg3); - if (arg4) - expect_string(__wrap_log_error_nocap, arg4, arg4); - else - expect_any(__wrap_log_error_nocap, arg4); -} From 0e1f2f28c1da1c768e8a37f86f87922186162aec Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 20 Mar 2023 15:46:23 +1100 Subject: [PATCH 04/10] 71 cppcheck suppressions for tests --- .cppcheck.supp | 2 ++ way-displays.supp => .vg.supp | 0 GNUmakefile | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .cppcheck.supp rename way-displays.supp => .vg.supp (100%) diff --git a/.cppcheck.supp b/.cppcheck.supp new file mode 100644 index 0000000..489e08e --- /dev/null +++ b/.cppcheck.supp @@ -0,0 +1,2 @@ +incorrectStringBooleanError:tst/tst-*.c +unusedFunction:tst/wrap-*.c diff --git a/way-displays.supp b/.vg.supp similarity index 100% rename from way-displays.supp rename to .vg.supp diff --git a/GNUmakefile b/GNUmakefile index 6c80814..002a1a7 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -68,7 +68,7 @@ iwyu: clean $(SRC_O) $(TST_O) IWYU = /usr/bin/include-what-you-use -Xiwyu --no_fwd_decls -Xiwyu --no_comments -Xiwyu --verbose=2 cppcheck: $(SRC_C) $(SRC_CXX) $(INC_H) $(EXAMPLE_C) $(TST_H) $(TST_C) - cppcheck $(^) --enable=warning,unusedFunction,performance,portability $(CPPFLAGS) + cppcheck $(^) --enable=warning,unusedFunction,performance,portability --suppressions-list=.cppcheck.supp $(CPPFLAGS) test: $(MAKE) -f tst/GNUmakefile tst-all From aded95e98f3dd3574c79138502f3328b23af7f28 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 20 Mar 2023 15:57:04 +1100 Subject: [PATCH 05/10] 71 iwyu --- tst/tst-head.c | 1 + tst/wrap-log.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tst/tst-head.c b/tst/tst-head.c index 68ff273..6d8dd7d 100644 --- a/tst/tst-head.c +++ b/tst/tst-head.c @@ -3,6 +3,7 @@ #include "expects.h" #include +#include #include #include #include diff --git a/tst/wrap-log.c b/tst/wrap-log.c index 4254492..d4209a4 100644 --- a/tst/wrap-log.c +++ b/tst/wrap-log.c @@ -1,5 +1,4 @@ #include "tst.h" // IWYU pragma: keep -#include "expects.h" #include #include From 6f8608542ff0cfc03095516e4f8fda23164a51ce Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 20 Mar 2023 16:01:57 +1100 Subject: [PATCH 06/10] 71 iwyu --- inc/mode.h | 4 ++-- src/head.c | 4 ++-- src/mode.c | 16 ++++++++-------- tst/tst-head.c | 8 +++++--- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/inc/mode.h b/inc/mode.h index 385c3ee..77c8f57 100644 --- a/inc/mode.h +++ b/inc/mode.h @@ -25,9 +25,9 @@ struct ModesResRefresh { struct SList *modes; }; -struct Mode *mode_preferred(struct Head *head); +struct Mode *mode_preferred(struct SList *modes, struct SList *modes_failed); -struct Mode *mode_max_preferred(struct Head *head); +struct Mode *mode_max_preferred(struct SList *modes, struct SList *modes_failed); int32_t mhz_to_hz(int32_t mhz); diff --git a/src/head.c b/src/head.c index 2042d32..6176433 100644 --- a/src/head.c +++ b/src/head.c @@ -201,9 +201,9 @@ struct Mode *head_find_mode(struct Head *head) { // always preferred if (!mode) { if (head_is_max_preferred_refresh(head)) { - mode = mode_max_preferred(head); + mode = mode_max_preferred(head->modes, head->modes_failed); } else { - mode = mode_preferred(head); + mode = mode_preferred(head->modes, head->modes_failed); } if (!mode && !head->warned_no_preferred) { head->warned_no_preferred = true; diff --git a/src/mode.c b/src/mode.c index fe4e39b..01b63ac 100644 --- a/src/mode.c +++ b/src/mode.c @@ -8,17 +8,17 @@ #include "head.h" #include "list.h" -struct Mode *mode_preferred(struct Head *head) { - if (!head) +struct Mode *mode_preferred(struct SList *modes, struct SList *modes_failed) { + if (!modes) return NULL; struct Mode *mode = NULL; - for (struct SList *i = head->modes; i; i = i->nex) { + for (struct SList *i = modes; i; i = i->nex) { if (!i->val) continue; mode = i->val; - if (mode->preferred && !slist_find_equal(head->modes_failed, NULL, mode)) { + if (mode->preferred && !slist_find_equal(modes_failed, NULL, mode)) { return mode; } } @@ -26,20 +26,20 @@ struct Mode *mode_preferred(struct Head *head) { return NULL; } -struct Mode *mode_max_preferred(struct Head *head) { - struct Mode *preferred = mode_preferred(head); +struct Mode *mode_max_preferred(struct SList *modes, struct SList *modes_failed) { + struct Mode *preferred = mode_preferred(modes, modes_failed); if (!preferred) return NULL; struct Mode *mode = NULL, *max = NULL; - for (struct SList *i = head->modes; i; i = i->nex) { + for (struct SList *i = modes; i; i = i->nex) { if (!i->val) continue; mode = i->val; - if (slist_find_equal(head->modes_failed, NULL, mode)) { + if (slist_find_equal(modes_failed, NULL, mode)) { continue; } diff --git a/tst/tst-head.c b/tst/tst-head.c index 6d8dd7d..a656d72 100644 --- a/tst/tst-head.c +++ b/tst/tst-head.c @@ -28,8 +28,9 @@ struct Mode *__wrap_mode_user_mode(struct SList *modes, struct SList *modes_fail return (struct Mode *)mock(); } -struct Mode *__wrap_mode_max_preferred(struct Head *head) { - check_expected(head); +struct Mode *__wrap_mode_max_preferred(struct SList *modes, struct SList *modes_failed) { + check_expected(modes); + check_expected(modes_failed); return (struct Mode *)mock(); } @@ -225,7 +226,8 @@ void head_find_mode__max_preferred_refresh(void **state) { slist_append(&head.modes, &mode); - expect_value(__wrap_mode_max_preferred, head, &head); + expect_value(__wrap_mode_max_preferred, modes, head.modes); + expect_value(__wrap_mode_max_preferred, modes_failed, head.modes_failed); will_return(__wrap_mode_max_preferred, &mode); assert_ptr_equal(head_find_mode(&head), &mode); From 0deeea44fd0121292158593a1543e4e5eddae4e2 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 20 Mar 2023 17:27:54 +1100 Subject: [PATCH 07/10] 71 add --yaml client option --- inc/cli.h | 4 ++- inc/client.h | 4 ++- inc/ipc.h | 3 ++- src/cli.c | 9 +++++-- src/client.c | 62 ++++++++++++++++++++++++++++++++----------- src/ipc.c | 18 ++++++------- src/main.c | 6 +++-- src/marshalling.cpp | 5 ---- src/sockets.c | 1 - tst/tst-marshalling.c | 4 --- 10 files changed, 74 insertions(+), 42 deletions(-) diff --git a/inc/cli.h b/inc/cli.h index 4084087..f13a4ef 100644 --- a/inc/cli.h +++ b/inc/cli.h @@ -1,8 +1,10 @@ #ifndef CLI_H #define CLI_H +#include + #include "ipc.h" -void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **cfg_path); +void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **cfg_path, bool *yaml); #endif // CLI_H diff --git a/inc/client.h b/inc/client.h index f95b558..369a5f6 100644 --- a/inc/client.h +++ b/inc/client.h @@ -1,9 +1,11 @@ #ifndef CLIENT_H #define CLIENT_H +#include + #include "ipc.h" -int client(struct IpcRequest *ipc_request); +int client(struct IpcRequest *ipc_request, bool yaml); #endif // CLIENT_H diff --git a/inc/ipc.h b/inc/ipc.h index 0a7c175..db8764c 100644 --- a/inc/ipc.h +++ b/inc/ipc.h @@ -30,13 +30,14 @@ struct IpcResponse { int fd; bool messages; bool state; - struct Cfg *cfg; }; int ipc_request_send(struct IpcRequest *request); void ipc_response_send(struct IpcResponse *response); +char *ipc_receive_fd(int fd); + struct IpcRequest *ipc_request_receive(int fd_sock); struct IpcResponse *ipc_response_receive(int fd); diff --git a/src/cli.c b/src/cli.c index 991cd0e..d5f0673 100644 --- a/src/cli.c +++ b/src/cli.c @@ -22,6 +22,7 @@ void usage(FILE *stream) { "OPTIONS\n" " -L, --l[og-threshold] \n" " -c, --c[onfig] \n" + " -y, --y[aml] YAML client output\n" "COMMANDS\n" " -h, --h[elp] show this message\n" " -v, --v[ersion] display version information\n" @@ -254,7 +255,7 @@ bool parse_log_threshold(char *optarg) { return true; } -void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **cfg_path) { +void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **cfg_path, bool *yaml) { static struct option long_options[] = { { "config", required_argument, 0, 'c' }, { "delete", required_argument, 0, 'd' }, @@ -264,9 +265,10 @@ void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **c { "set", required_argument, 0, 's' }, { "version", no_argument, 0, 'v' }, { "write", no_argument, 0, 'w' }, + { "yaml", no_argument, 0, 'y' }, { 0, 0, 0, 0 } }; - static char *short_options = "c:d:ghL:s:vw"; + static char *short_options = "c:d:ghL:s:vwy"; int c; while (1) { @@ -292,6 +294,9 @@ void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **c log_info("way-displays version %s", VERSION); wd_exit(EXIT_SUCCESS); return; + case 'y': + *yaml = true; + break; case 'g': *ipc_request = parse_get(argc, argv); return; diff --git a/src/client.c b/src/client.c index 393649c..2814f61 100644 --- a/src/client.c +++ b/src/client.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -10,12 +11,52 @@ #include "log.h" #include "process.h" +int handle_yaml(int fd) { + int rc = EXIT_SUCCESS; + + char *yaml = ipc_receive_fd(fd); + while (yaml) { + fprintf(stdout, "%s", yaml); + free(yaml); + yaml = ipc_receive_fd(fd); + } + + return rc; +} + +int handle_human(int fd) { + int rc = EXIT_SUCCESS; + + struct IpcResponse *ipc_response; + bool done = false; + + while (!done) { + ipc_response = ipc_response_receive(fd); + if (ipc_response) { + rc = ipc_response->rc; + done = ipc_response->done; + } else { + rc = IPC_RC_BAD_RESPONSE; + done = true; + } + } + + if (ipc_response) { + ipc_response_free(ipc_response); + } + + return rc; +} -int client(struct IpcRequest *ipc_request) { +int client(struct IpcRequest *ipc_request, bool yaml) { if (!ipc_request) { return EXIT_FAILURE; } + if (yaml) { + log_set_threshold(ERROR, true); + } + log_set_times(false); int rc = EXIT_SUCCESS; @@ -35,21 +76,10 @@ int client(struct IpcRequest *ipc_request) { goto end; } - struct IpcResponse *ipc_response; - bool done = false; - while (!done) { - ipc_response = ipc_response_receive(fd); - if (ipc_response) { - rc = ipc_response->rc; - done = ipc_response->done; - } else { - rc = IPC_RC_BAD_RESPONSE; - done = true; - } - } - - if (ipc_response) { - ipc_response_free(ipc_response); + if (yaml) { + rc = handle_yaml(fd); + } else { + rc = handle_human(fd); } close(fd); diff --git a/src/ipc.c b/src/ipc.c index 8176de8..09c5d28 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -85,19 +85,21 @@ struct IpcRequest *ipc_request_receive(int fd_sock) { return request; } -struct IpcResponse *ipc_response_receive(int fd) { - struct IpcResponse *response = NULL; +char *ipc_receive_fd(int fd) { char *yaml = NULL; - if (fd == -1) { - log_error("invalid fd for ipc response receive"); - return NULL; - } - if (!(yaml = socket_read(fd))) { return NULL; } + return yaml; +} + +struct IpcResponse *ipc_response_receive(int fd) { + struct IpcResponse *response = NULL; + + char *yaml = ipc_receive_fd(fd); + log_debug_nocap("========received server response========\n%s\n----------------------------------------", yaml); response = unmarshal_ipc_response(yaml); @@ -121,8 +123,6 @@ void ipc_response_free(struct IpcResponse *response) { return; } - cfg_free(response->cfg); - free(response); } diff --git a/src/main.c b/src/main.c index 94a447e..ee613b0 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,4 @@ +#include #include #include @@ -18,11 +19,12 @@ main(int argc, char **argv) { // consumer frees struct IpcRequest *ipc_request = NULL; char *cfg_path = NULL; + bool yaml = false; - parse_args(argc, argv, &ipc_request, &cfg_path); + parse_args(argc, argv, &ipc_request, &cfg_path, &yaml); if (ipc_request) { - return client(ipc_request); + return client(ipc_request, yaml); } else { return server(cfg_path); } diff --git a/src/marshalling.cpp b/src/marshalling.cpp index 8b88e98..6900351 100644 --- a/src/marshalling.cpp +++ b/src/marshalling.cpp @@ -607,11 +607,6 @@ struct IpcResponse *unmarshal_ipc_response(char *yaml) { } } } - - if (i->first.as() == "CFG") { - response->cfg = (struct Cfg*)calloc(1, sizeof(struct Cfg)); - cfg_parse_node(response->cfg, i->second); - } } } catch (const std::exception &e) { diff --git a/src/sockets.c b/src/sockets.c index 16d4540..1b1a8ab 100644 --- a/src/sockets.c +++ b/src/sockets.c @@ -59,7 +59,6 @@ char *socket_read(int fd) { return NULL; } if (n == 0) { - log_error("\nSocket no data"); return NULL; } diff --git a/tst/tst-marshalling.c b/tst/tst-marshalling.c index 6ece081..f7f5262 100644 --- a/tst/tst-marshalling.c +++ b/tst/tst-marshalling.c @@ -418,12 +418,8 @@ void unmarshal_ipc_response__ok(void **state) { assert_true(actual->done); assert_int_equal(actual->rc, 2); - struct Cfg *cfg_expected = cfg_all(); - assert_equal_cfg(actual->cfg, cfg_expected); - ipc_response_free(actual); free(yaml); - cfg_free(cfg_expected); } int main(void) { From 57ae54ba7538d7798f01efe3646e42a3e33aee5c Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Tue, 21 Mar 2023 09:52:24 +1100 Subject: [PATCH 08/10] 71 remove --yaml client option --- inc/cli.h | 2 +- inc/client.h | 2 +- src/cli.c | 12 ++--------- src/client.c | 59 ++++++++++++--------------------------------------- src/ipc.c | 16 ++++++-------- src/main.c | 5 ++--- src/sockets.c | 1 + 7 files changed, 27 insertions(+), 70 deletions(-) diff --git a/inc/cli.h b/inc/cli.h index f13a4ef..454935a 100644 --- a/inc/cli.h +++ b/inc/cli.h @@ -5,6 +5,6 @@ #include "ipc.h" -void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **cfg_path, bool *yaml); +void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **cfg_path); #endif // CLI_H diff --git a/inc/client.h b/inc/client.h index 369a5f6..4c3813a 100644 --- a/inc/client.h +++ b/inc/client.h @@ -5,7 +5,7 @@ #include "ipc.h" -int client(struct IpcRequest *ipc_request, bool yaml); +int client(struct IpcRequest *ipc_request); #endif // CLIENT_H diff --git a/src/cli.c b/src/cli.c index d5f0673..4fa1ecf 100644 --- a/src/cli.c +++ b/src/cli.c @@ -22,7 +22,6 @@ void usage(FILE *stream) { "OPTIONS\n" " -L, --l[og-threshold] \n" " -c, --c[onfig] \n" - " -y, --y[aml] YAML client output\n" "COMMANDS\n" " -h, --h[elp] show this message\n" " -v, --v[ersion] display version information\n" @@ -135,9 +134,6 @@ struct Cfg *parse_element(enum IpcRequestOperation op, enum CfgElement element, bp += snprintf(bp, sizeof(buf) - (bp - buf), " %s", argv[i]); } log_error("invalid %s%s", cfg_element_name(element), buf); - if (cfg) { - cfg_free(cfg); - } wd_exit(EXIT_FAILURE); return NULL; } @@ -255,7 +251,7 @@ bool parse_log_threshold(char *optarg) { return true; } -void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **cfg_path, bool *yaml) { +void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **cfg_path) { static struct option long_options[] = { { "config", required_argument, 0, 'c' }, { "delete", required_argument, 0, 'd' }, @@ -265,10 +261,9 @@ void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **c { "set", required_argument, 0, 's' }, { "version", no_argument, 0, 'v' }, { "write", no_argument, 0, 'w' }, - { "yaml", no_argument, 0, 'y' }, { 0, 0, 0, 0 } }; - static char *short_options = "c:d:ghL:s:vwy"; + static char *short_options = "c:d:ghL:s:vw"; int c; while (1) { @@ -294,9 +289,6 @@ void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **c log_info("way-displays version %s", VERSION); wd_exit(EXIT_SUCCESS); return; - case 'y': - *yaml = true; - break; case 'g': *ipc_request = parse_get(argc, argv); return; diff --git a/src/client.c b/src/client.c index 2814f61..3e96cba 100644 --- a/src/client.c +++ b/src/client.c @@ -1,5 +1,4 @@ #include -#include #include #include @@ -11,52 +10,12 @@ #include "log.h" #include "process.h" -int handle_yaml(int fd) { - int rc = EXIT_SUCCESS; - - char *yaml = ipc_receive_fd(fd); - while (yaml) { - fprintf(stdout, "%s", yaml); - free(yaml); - yaml = ipc_receive_fd(fd); - } - - return rc; -} - -int handle_human(int fd) { - int rc = EXIT_SUCCESS; - - struct IpcResponse *ipc_response; - bool done = false; - - while (!done) { - ipc_response = ipc_response_receive(fd); - if (ipc_response) { - rc = ipc_response->rc; - done = ipc_response->done; - } else { - rc = IPC_RC_BAD_RESPONSE; - done = true; - } - } - - if (ipc_response) { - ipc_response_free(ipc_response); - } - - return rc; -} -int client(struct IpcRequest *ipc_request, bool yaml) { +int client(struct IpcRequest *ipc_request) { if (!ipc_request) { return EXIT_FAILURE; } - if (yaml) { - log_set_threshold(ERROR, true); - } - log_set_times(false); int rc = EXIT_SUCCESS; @@ -76,10 +35,18 @@ int client(struct IpcRequest *ipc_request, bool yaml) { goto end; } - if (yaml) { - rc = handle_yaml(fd); - } else { - rc = handle_human(fd); + struct IpcResponse *ipc_response; + bool done = false; + while (!done) { + ipc_response = ipc_response_receive(fd); + if (ipc_response) { + rc = ipc_response->rc; + done = ipc_response->done; + ipc_response_free(ipc_response); + } else { + rc = IPC_RC_BAD_RESPONSE; + done = true; + } } close(fd); diff --git a/src/ipc.c b/src/ipc.c index 09c5d28..c3c2e3c 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -85,20 +85,18 @@ struct IpcRequest *ipc_request_receive(int fd_sock) { return request; } -char *ipc_receive_fd(int fd) { +struct IpcResponse *ipc_response_receive(int fd) { + struct IpcResponse *response = NULL; char *yaml = NULL; - if (!(yaml = socket_read(fd))) { + if (fd == -1) { + log_error("invalid fd for ipc response receive"); return NULL; } - return yaml; -} - -struct IpcResponse *ipc_response_receive(int fd) { - struct IpcResponse *response = NULL; - - char *yaml = ipc_receive_fd(fd); + if (!(yaml = socket_read(fd))) { + return NULL; + } log_debug_nocap("========received server response========\n%s\n----------------------------------------", yaml); diff --git a/src/main.c b/src/main.c index ee613b0..44d91b8 100644 --- a/src/main.c +++ b/src/main.c @@ -19,12 +19,11 @@ main(int argc, char **argv) { // consumer frees struct IpcRequest *ipc_request = NULL; char *cfg_path = NULL; - bool yaml = false; - parse_args(argc, argv, &ipc_request, &cfg_path, &yaml); + parse_args(argc, argv, &ipc_request, &cfg_path); if (ipc_request) { - return client(ipc_request, yaml); + return client(ipc_request); } else { return server(cfg_path); } diff --git a/src/sockets.c b/src/sockets.c index 1b1a8ab..16d4540 100644 --- a/src/sockets.c +++ b/src/sockets.c @@ -59,6 +59,7 @@ char *socket_read(int fd) { return NULL; } if (n == 0) { + log_error("\nSocket no data"); return NULL; } From 10565608bdb7e616ecca84b6ca8e79b7c5d3cb7e Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Tue, 21 Mar 2023 09:54:18 +1100 Subject: [PATCH 09/10] 71 remove --yaml client option --- inc/cli.h | 2 -- inc/client.h | 2 -- inc/ipc.h | 2 -- src/main.c | 1 - 4 files changed, 7 deletions(-) diff --git a/inc/cli.h b/inc/cli.h index 454935a..4084087 100644 --- a/inc/cli.h +++ b/inc/cli.h @@ -1,8 +1,6 @@ #ifndef CLI_H #define CLI_H -#include - #include "ipc.h" void parse_args(int argc, char **argv, struct IpcRequest **ipc_request, char **cfg_path); diff --git a/inc/client.h b/inc/client.h index 4c3813a..f95b558 100644 --- a/inc/client.h +++ b/inc/client.h @@ -1,8 +1,6 @@ #ifndef CLIENT_H #define CLIENT_H -#include - #include "ipc.h" int client(struct IpcRequest *ipc_request); diff --git a/inc/ipc.h b/inc/ipc.h index db8764c..4007fd2 100644 --- a/inc/ipc.h +++ b/inc/ipc.h @@ -36,8 +36,6 @@ int ipc_request_send(struct IpcRequest *request); void ipc_response_send(struct IpcResponse *response); -char *ipc_receive_fd(int fd); - struct IpcRequest *ipc_request_receive(int fd_sock); struct IpcResponse *ipc_response_receive(int fd); diff --git a/src/main.c b/src/main.c index 44d91b8..94a447e 100644 --- a/src/main.c +++ b/src/main.c @@ -1,4 +1,3 @@ -#include #include #include From 9d25bd480e9eae70fc55904fc94b84e33bfe8a3f Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Tue, 21 Mar 2023 09:55:41 +1100 Subject: [PATCH 10/10] 71 remove --yaml client option --- src/mode.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mode.c b/src/mode.c index 01b63ac..60ac3eb 100644 --- a/src/mode.c +++ b/src/mode.c @@ -9,10 +9,8 @@ #include "list.h" struct Mode *mode_preferred(struct SList *modes, struct SList *modes_failed) { - if (!modes) - return NULL; - struct Mode *mode = NULL; + for (struct SList *i = modes; i; i = i->nex) { if (!i->val) continue;