Skip to content

Commit

Permalink
Remove the need for dynamically sized array on the stack
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj committed Nov 28, 2024
1 parent ad166de commit 87c1e50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ target_compile_options(reactor-uc PRIVATE -Wall -Wextra -Werror)

# Disable selected warnings
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(reactor-uc PUBLIC -Wno-zero-length-bounds -Wno-stack-usage)
target_compile_options(reactor-uc PRIVATE -Wno-zero-length-bounds)
endif()

add_compile_options (-fdiagnostics-color=always)
Expand Down
8 changes: 2 additions & 6 deletions src/federated.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
#include "reactor-uc/logging.h"
#include "reactor-uc/platform.h"

// #pragma GCC diagnostic ignored "-Wstack-usage="

// TODO: Refactor so this function is available
void LogicalConnection_trigger_downstreams(Connection *self, const void *value, size_t value_size);

void FederatedConnectionBundle_connect_to_peers(FederatedConnectionBundle **bundles, size_t bundles_size) {
bool connected[bundles_size];
lf_ret_t ret;
Environment *env = bundles[0]->parent->env;

for (size_t i = 0; i < bundles_size; i++) {
connected[i] = false;
FederatedConnectionBundle *bundle = bundles[i];
NetworkChannel *chan = bundle->net_channel;
ret = chan->open_connection(chan);
Expand All @@ -29,11 +25,11 @@ void FederatedConnectionBundle_connect_to_peers(FederatedConnectionBundle **bund
for (size_t i = 0; i < bundles_size; i++) {
FederatedConnectionBundle *bundle = bundles[i];
NetworkChannel *chan = bundle->net_channel;
if (!connected[i]) {
NetworkChannelState state = chan->get_connection_state(chan);
if (state != NETWORK_CHANNEL_STATE_CONNECTED) {
ret = chan->try_connect(chan);
switch (ret) {
case LF_OK:
connected[i] = true;
bundle->network_channel_state_changed(bundle);
break;
case LF_IN_PROGRESS:
Expand Down

0 comments on commit 87c1e50

Please sign in to comment.