From dd5cdda64b5fd3966718af62d417117942e2f323 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Mon, 19 Dec 2016 15:27:34 -0200 Subject: [PATCH] more eo simplified to use Eina_Slice instead of pointer to. Working directly with Eina_Slice is easier than a pointer to it, requires no validation of the pointers and is cheap since it's just putting together size_t + void*. However we can't hint the user of 'const(Eina.Slice)' properties as Eolian is incorrectly generating getters as: const Eina_Slice class_property_get(...) which is makes compilers complain about ignored qualifiers: ../src/lib/ecore/efl_io_copier.eo.h:329:7: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers] Leave some TODO so @q66 can fix those. --- .../ecore/efl_io_buffered_stream_example.c | 2 +- src/examples/ecore/efl_io_copier_example.c | 2 +- src/examples/ecore/efl_io_queue_example.c | 4 +- src/examples/ecore/efl_net_control_example.c | 2 +- .../ecore/efl_net_dialer_simple_example.c | 2 +- .../ecore/efl_net_ip_address_example.c | 8 +-- src/lib/ecore/efl_io_buffered_stream.c | 8 +-- src/lib/ecore/efl_io_buffered_stream.eo | 5 +- src/lib/ecore/efl_io_copier.c | 15 +++-- src/lib/ecore/efl_io_copier.eo | 5 +- src/lib/ecore_con/efl_net_dialer_simple.c | 18 +++--- src/lib/ecore_con/efl_net_ip_address.c | 17 +++--- src/lib/ecore_con/efl_net_ip_address.eo | 3 +- .../ecore_con_test_efl_net_ip_address.c | 56 +++++++++---------- 14 files changed, 71 insertions(+), 76 deletions(-) diff --git a/src/examples/ecore/efl_io_buffered_stream_example.c b/src/examples/ecore/efl_io_buffered_stream_example.c index 9e1a7ec7f1..1017b2731e 100644 --- a/src/examples/ecore/efl_io_buffered_stream_example.c +++ b/src/examples/ecore/efl_io_buffered_stream_example.c @@ -266,7 +266,7 @@ main(int argc, char **argv) stream = efl_add(EFL_IO_BUFFERED_STREAM_CLASS, loop, efl_name_set(efl_added, "stream"), efl_io_buffered_stream_inner_io_set(efl_added, dialer), /* mandatory! */ - efl_io_buffered_stream_line_delimiter_set(efl_added, &line_delimiter), + efl_io_buffered_stream_line_delimiter_set(efl_added, line_delimiter), efl_io_buffered_stream_max_queue_size_input_set(efl_added, buffer_limit), efl_io_buffered_stream_max_queue_size_output_set(efl_added, buffer_limit), efl_event_callback_array_add(efl_added, stream_cbs(), NULL)); diff --git a/src/examples/ecore/efl_io_copier_example.c b/src/examples/ecore/efl_io_copier_example.c index 50295bf30c..5e5cbebc66 100644 --- a/src/examples/ecore/efl_io_copier_example.c +++ b/src/examples/ecore/efl_io_copier_example.c @@ -880,7 +880,7 @@ main(int argc, char **argv) copier = efl_add(EFL_IO_COPIER_CLASS, ecore_main_loop_get(), efl_io_copier_source_set(efl_added, input), /* mandatory */ efl_io_copier_destination_set(efl_added, output), /* optional, see :none: */ - efl_io_copier_line_delimiter_set(efl_added, &line_delm_slice), /* optional */ + efl_io_copier_line_delimiter_set(efl_added, line_delm_slice), /* optional */ efl_io_copier_buffer_limit_set(efl_added, buffer_limit), /* optional, defaults to unlimited */ efl_io_copier_read_chunk_size_set(efl_added, read_chunk_size), /* optional, defaults to 4096 */ efl_io_copier_timeout_inactivity_set(efl_added, timeout), /* optional, defaults to 0.0 (disabled) */ diff --git a/src/examples/ecore/efl_io_queue_example.c b/src/examples/ecore/efl_io_queue_example.c index d1097efe36..8242a71e3b 100644 --- a/src/examples/ecore/efl_io_queue_example.c +++ b/src/examples/ecore/efl_io_queue_example.c @@ -301,7 +301,7 @@ main(int argc, char **argv) /* sender: send_queue->network */ sender = efl_add(EFL_IO_COPIER_CLASS, loop, efl_name_set(efl_added, "sender"), - efl_io_copier_line_delimiter_set(efl_added, &line_delimiter), + efl_io_copier_line_delimiter_set(efl_added, line_delimiter), efl_io_copier_source_set(efl_added, send_queue), efl_io_copier_destination_set(efl_added, dialer), efl_event_callback_array_add(efl_added, copier_cbs(), NULL)); @@ -315,7 +315,7 @@ main(int argc, char **argv) /* receiver: network->receive_queue */ receiver = efl_add(EFL_IO_COPIER_CLASS, loop, efl_name_set(efl_added, "receiver"), - efl_io_copier_line_delimiter_set(efl_added, &line_delimiter), + efl_io_copier_line_delimiter_set(efl_added, line_delimiter), efl_io_copier_source_set(efl_added, dialer), efl_io_copier_destination_set(efl_added, receive_queue), efl_event_callback_array_add(efl_added, copier_cbs(), NULL)); diff --git a/src/examples/ecore/efl_net_control_example.c b/src/examples/ecore/efl_net_control_example.c index 5d5efa5c0c..952d0d9b98 100644 --- a/src/examples/ecore/efl_net_control_example.c +++ b/src/examples/ecore/efl_net_control_example.c @@ -1416,7 +1416,7 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED) input = efl_add(EFL_IO_STDIN_CLASS, ecore_main_loop_get()); copier = efl_add(EFL_IO_COPIER_CLASS, ecore_main_loop_get(), efl_io_copier_source_set(efl_added, input), - efl_io_copier_line_delimiter_set(efl_added, &line_delimiter), + efl_io_copier_line_delimiter_set(efl_added, line_delimiter), efl_io_copier_buffer_limit_set(efl_added, 8192), efl_io_copier_read_chunk_size_set(efl_added, 8192), efl_event_callback_add(efl_added, EFL_IO_COPIER_EVENT_LINE, _cmd_line, ctl)); diff --git a/src/examples/ecore/efl_net_dialer_simple_example.c b/src/examples/ecore/efl_net_dialer_simple_example.c index 7411a58b84..bda865c20e 100644 --- a/src/examples/ecore/efl_net_dialer_simple_example.c +++ b/src/examples/ecore/efl_net_dialer_simple_example.c @@ -370,7 +370,7 @@ main(int argc, char **argv) dialer = efl_add(EFL_NET_DIALER_SIMPLE_CLASS, loop, efl_name_set(efl_added, "dialer"), efl_net_dialer_simple_inner_class_set(efl_added, cls), /* alternatively you could create the inner dialer and set with efl_io_buffered_stream_inner_io_set() */ - efl_io_buffered_stream_line_delimiter_set(efl_added, &line_delm_slice), /* optional */ + efl_io_buffered_stream_line_delimiter_set(efl_added, line_delm_slice), /* optional */ efl_io_buffered_stream_max_queue_size_input_set(efl_added, buffer_limit), /* optional, defaults to unlimited */ efl_io_buffered_stream_max_queue_size_output_set(efl_added, buffer_limit), /* optional, defaults to unlimited */ efl_io_buffered_stream_read_chunk_size_set(efl_added, read_chunk_size), /* optional, defaults to 4096 */ diff --git a/src/examples/ecore/efl_net_ip_address_example.c b/src/examples/ecore/efl_net_ip_address_example.c index 8c817c44b7..37cbc2f2e5 100644 --- a/src/examples/ecore/efl_net_ip_address_example.c +++ b/src/examples/ecore/efl_net_ip_address_example.c @@ -12,7 +12,7 @@ static Eina_List *resolving = NULL; static void _print_ip_addr_info(const Eo *o) { - const Eina_Slice *addr; + Eina_Slice addr; const struct sockaddr *sa; char buf[INET6_ADDRSTRLEN] = "?"; uint16_t port; @@ -23,9 +23,9 @@ _print_ip_addr_info(const Eo *o) printf("INFO: - port: %hu\n", efl_net_ip_address_port_get(o)); addr = efl_net_ip_address_get(o); - printf("INFO: - address %zd bytes:", addr->len); - for (i = 0; i < addr->len; i++) - printf(" %#hhx", addr->bytes[i]); + printf("INFO: - address %zd bytes:", addr.len); + for (i = 0; i < addr.len; i++) + printf(" %#hhx", addr.bytes[i]); putchar('\n'); sa = efl_net_ip_address_sockaddr_get(o); diff --git a/src/lib/ecore/efl_io_buffered_stream.c b/src/lib/ecore/efl_io_buffered_stream.c index a54d125b2d..3b7b4d267b 100644 --- a/src/lib/ecore/efl_io_buffered_stream.c +++ b/src/lib/ecore/efl_io_buffered_stream.c @@ -448,20 +448,20 @@ _efl_io_buffered_stream_max_queue_size_output_get(Eo *o EINA_UNUSED, Efl_Io_Buff } EOLIAN static void -_efl_io_buffered_stream_line_delimiter_set(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stream_Data *pd, const Eina_Slice *slice) +_efl_io_buffered_stream_line_delimiter_set(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stream_Data *pd, Eina_Slice slice) { if (!pd->receiver) { - DBG("%p inner_io=%p (%s) is not Efl.Io.Reader, slice=%p ignored", o, pd->inner_io, efl_class_name_get(efl_class_get(pd->inner_io)), slice); + DBG("%p inner_io=%p (%s) is not Efl.Io.Reader, slice=" EINA_SLICE_FMT " ignored", o, pd->inner_io, efl_class_name_get(efl_class_get(pd->inner_io)), EINA_SLICE_PRINT(slice)); return; } efl_io_copier_line_delimiter_set(pd->receiver, slice); } -EOLIAN static const Eina_Slice * +EOLIAN static Eina_Slice _efl_io_buffered_stream_line_delimiter_get(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stream_Data *pd) { - if (!pd->receiver) return NULL; + if (!pd->receiver) return (Eina_Slice){}; return efl_io_copier_line_delimiter_get(pd->receiver); } diff --git a/src/lib/ecore/efl_io_buffered_stream.eo b/src/lib/ecore/efl_io_buffered_stream.eo index e7ebcfa3b8..1e85f85f8f 100644 --- a/src/lib/ecore/efl_io_buffered_stream.eo +++ b/src/lib/ecore/efl_io_buffered_stream.eo @@ -84,10 +84,11 @@ class Efl.Io.Buffered_Stream (Efl.Loop_User, Efl.Io.Reader, Efl.Io.Writer, Efl.I [[If set, incoming data will be checked for the delimiter and "line" events are The line may include the delimiter, unless it's end-of-stream on @.max_queue_size_input was reached.]] get { } set { - [[Change line delimiter to use. If NULL or empty, no delimiter is to be used]] + [[Change line delimiter to use. If empty, no delimiter is to be used]] } values { - slice: ptr(const(Eina.Slice)); [[The contents may contain \0 and will be copied]] + // TODO: eolian generates wrong type for getter with const(Eina.Slice) + slice: Eina.Slice; [[The contents may contain \0 and will be copied]] } } diff --git a/src/lib/ecore/efl_io_copier.c b/src/lib/ecore/efl_io_copier.c index d170a19dce..b6984a2a04 100644 --- a/src/lib/ecore/efl_io_copier.c +++ b/src/lib/ecore/efl_io_copier.c @@ -558,32 +558,31 @@ _efl_io_copier_buffer_limit_get(Eo *o EINA_UNUSED, Efl_Io_Copier_Data *pd) } EOLIAN static void -_efl_io_copier_line_delimiter_set(Eo *o EINA_UNUSED, Efl_Io_Copier_Data *pd, const Eina_Slice *slice) +_efl_io_copier_line_delimiter_set(Eo *o EINA_UNUSED, Efl_Io_Copier_Data *pd, Eina_Slice slice) { - EINA_SAFETY_ON_NULL_RETURN(slice); - if (pd->line_delimiter.mem == slice->mem) + if (pd->line_delimiter.mem == slice.mem) { - pd->line_delimiter.len = slice->len; + pd->line_delimiter.len = slice.len; return; } free((void *)pd->line_delimiter.mem); - if (slice->len == 0) + if (slice.len == 0) { pd->line_delimiter.mem = NULL; pd->line_delimiter.len = 0; } else { - Eina_Rw_Slice rw_slice = eina_slice_dup(*slice); + Eina_Rw_Slice rw_slice = eina_slice_dup(slice); pd->line_delimiter = eina_rw_slice_slice_get(rw_slice); } } -EOLIAN static const Eina_Slice * +EOLIAN static Eina_Slice _efl_io_copier_line_delimiter_get(Eo *o EINA_UNUSED, Efl_Io_Copier_Data *pd) { - return &pd->line_delimiter; + return pd->line_delimiter; } diff --git a/src/lib/ecore/efl_io_copier.eo b/src/lib/ecore/efl_io_copier.eo index 33567c797c..175efcb15f 100644 --- a/src/lib/ecore/efl_io_copier.eo +++ b/src/lib/ecore/efl_io_copier.eo @@ -189,10 +189,11 @@ class Efl.Io.Copier (Efl.Loop_User, Efl.Io.Closer) { [[If there is a line delimiter, the reads will buffer/queue up to the line delimiter before calling @Efl.Io.Writer.write on the @.destination and the event line is emitted with current line. The line may include the delimiter, unless it's end-of-stream on @.source or @.buffer_limit was reached.]] get { } set { - [[Change line delimiter to use. If NULL or empty, no delimiter is to be used]] + [[Change line delimiter to use. If empty, no delimiter is to be used]] } values { - slice: ptr(const(Eina.Slice)); [[The contents may contain \0 and will be copied]] + // TODO: eolian generates wrong type for getter with const(Eina.Slice) + slice: Eina.Slice; [[The contents may contain \0 and will be copied]] } } diff --git a/src/lib/ecore_con/efl_net_dialer_simple.c b/src/lib/ecore_con/efl_net_dialer_simple.c index 317f972862..2aca537318 100644 --- a/src/lib/ecore_con/efl_net_dialer_simple.c +++ b/src/lib/ecore_con/efl_net_dialer_simple.c @@ -155,7 +155,7 @@ _efl_net_dialer_simple_efl_io_buffered_stream_inner_io_set(Eo *o, Efl_Net_Dialer if (pd->pending.line_delimiter) { pd->pending.line_delimiter = EINA_FALSE; - efl_io_buffered_stream_line_delimiter_set(o, &pd->line_delimiter); + efl_io_buffered_stream_line_delimiter_set(o, pd->line_delimiter); free((void *)pd->line_delimiter.mem); pd->line_delimiter.mem = NULL; } @@ -313,14 +313,14 @@ _efl_net_dialer_simple_efl_io_buffered_stream_read_chunk_size_get(Eo *o, Efl_Net EOLIAN static void -_efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_set(Eo *o, Efl_Net_Dialer_Simple_Data *pd, const Eina_Slice *slice) +_efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_set(Eo *o, Efl_Net_Dialer_Simple_Data *pd, Eina_Slice slice) { Eo *inner_io = efl_io_buffered_stream_inner_io_get(o); if (!inner_io) { free((void *)pd->line_delimiter.mem); - if ((!slice) || (!slice->len)) + if (!slice.len) { pd->line_delimiter.mem = NULL; pd->line_delimiter.len = 0; @@ -328,11 +328,11 @@ _efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_set(Eo *o, Efl_Net_ else { char *mem; - pd->line_delimiter.mem = mem = malloc(slice->len + 1); + pd->line_delimiter.mem = mem = malloc(slice.len + 1); EINA_SAFETY_ON_NULL_RETURN(pd->line_delimiter.mem); - memcpy(mem, slice->mem, slice->len); - mem[slice->len] = '\0'; - pd->line_delimiter.len = slice->len; + memcpy(mem, slice.mem, slice.len); + mem[slice.len] = '\0'; + pd->line_delimiter.len = slice.len; } pd->pending.line_delimiter = EINA_TRUE; @@ -341,11 +341,11 @@ _efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_set(Eo *o, Efl_Net_ efl_io_buffered_stream_line_delimiter_set(efl_super(o, MY_CLASS), slice); } -EOLIAN static const Eina_Slice * +EOLIAN static Eina_Slice _efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_get(Eo *o, Efl_Net_Dialer_Simple_Data *pd) { Eo *inner_io = efl_io_buffered_stream_inner_io_get(o); - if (!inner_io) return &pd->line_delimiter; + if (!inner_io) return pd->line_delimiter; return efl_io_buffered_stream_line_delimiter_get(efl_super(o, MY_CLASS)); } diff --git a/src/lib/ecore_con/efl_net_ip_address.c b/src/lib/ecore_con/efl_net_ip_address.c index e76a3834aa..569b18d13e 100644 --- a/src/lib/ecore_con/efl_net_ip_address.c +++ b/src/lib/ecore_con/efl_net_ip_address.c @@ -126,20 +126,19 @@ _efl_net_ip_address_port_get(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd) } EOLIAN static void -_efl_net_ip_address_address_set(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd, const Eina_Slice *address) +_efl_net_ip_address_address_set(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd, Eina_Slice address) { Eina_Rw_Slice rw_slice; size_t i; EINA_SAFETY_ON_TRUE_RETURN(pd->addr.sa_family == 0); - EINA_SAFETY_ON_NULL_RETURN(address); rw_slice.mem = (void *)pd->addr_slice.mem; rw_slice.len = pd->addr_slice.len; - EINA_SAFETY_ON_TRUE_RETURN(rw_slice.len != address->len); + EINA_SAFETY_ON_TRUE_RETURN(rw_slice.len != address.len); - if (eina_slice_compare(eina_rw_slice_slice_get(rw_slice), *address) == 0) + if (eina_slice_compare(eina_rw_slice_slice_get(rw_slice), address) == 0) return; for (i = 0; i < rw_slice.len; i++) @@ -154,7 +153,7 @@ _efl_net_ip_address_address_set(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd, old_str[0] = '?'; old_str[1] = '\0'; } - if (!inet_ntop(pd->addr.sa_family, address->mem, new_str, sizeof(new_str))) + if (!inet_ntop(pd->addr.sa_family, address.mem, new_str, sizeof(new_str))) { new_str[0] = '?'; new_str[1] = '\0'; @@ -164,13 +163,13 @@ _efl_net_ip_address_address_set(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd, } } - eina_rw_slice_copy(rw_slice, *address); + eina_rw_slice_copy(rw_slice, address); } -EOLIAN static const Eina_Slice * +EOLIAN static Eina_Slice _efl_net_ip_address_address_get(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd) { - return &pd->addr_slice; + return pd->addr_slice; } EOLIAN static void @@ -304,7 +303,7 @@ _efl_net_ip_address_create(Eo *cls, void *pd EINA_UNUSED, uint16_t port, const E return efl_add(cls, NULL, efl_net_ip_address_family_set(efl_added, family), efl_net_ip_address_port_set(efl_added, port), - efl_net_ip_address_set(efl_added, &address)); + efl_net_ip_address_set(efl_added, address)); } EOLIAN static Efl_Net_Ip_Address * diff --git a/src/lib/ecore_con/efl_net_ip_address.eo b/src/lib/ecore_con/efl_net_ip_address.eo index a9e2d7b3e3..e70b578038 100644 --- a/src/lib/ecore_con/efl_net_ip_address.eo +++ b/src/lib/ecore_con/efl_net_ip_address.eo @@ -161,7 +161,8 @@ class Efl.Net.Ip.Address (Efl.Object) { Must be set after @.family. ]] values { - address: const(ptr(Eina.Slice)) @nonull; [[Address bytes. If AF_INET it's 4 bytes. If AF_INET6, it's 16 bytes. This matches exactly what is in struct sockaddr_in::sin_addr or struct sockaddr_in6:sin6_addr, see @.sockaddr]] + // TODO: eolian generates wrong type for getter with const(Eina.Slice) + address: Eina.Slice; [[Address bytes. If AF_INET it's 4 bytes. If AF_INET6, it's 16 bytes. This matches exactly what is in struct sockaddr_in::sin_addr or struct sockaddr_in6:sin6_addr, see @.sockaddr]] } } diff --git a/src/tests/ecore_con/ecore_con_test_efl_net_ip_address.c b/src/tests/ecore_con/ecore_con_test_efl_net_ip_address.c index cd2999ce57..9eda9ddf3d 100644 --- a/src/tests/ecore_con/ecore_con_test_efl_net_ip_address.c +++ b/src/tests/ecore_con/ecore_con_test_efl_net_ip_address.c @@ -268,7 +268,7 @@ static void _ipv4_check(Eo *o, const struct sockaddr_in *addr) { Eina_Slice slice = { .mem = &addr->sin_addr, .len = sizeof(addr->sin_addr) }; - const Eina_Slice *rs; + Eina_Slice rs; char buf[INET_ADDRSTRLEN + sizeof(":65536")] = ""; ck_assert_ptr_ne(o, NULL); @@ -277,8 +277,7 @@ _ipv4_check(Eo *o, const struct sockaddr_in *addr) ck_assert_int_eq(efl_net_ip_address_port_get(o), ntohs(addr->sin_port)); rs = efl_net_ip_address_get(o); - ck_assert_ptr_ne(rs, NULL); - ck_assert_int_eq(eina_slice_compare(*rs, slice), 0); + ck_assert_int_eq(eina_slice_compare(rs, slice), 0); inet_ntop(AF_INET, slice.mem, buf, INET_ADDRSTRLEN); @@ -306,7 +305,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_ok) o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, efl_net_ip_address_family_set(efl_added, AF_INET), efl_net_ip_address_port_set(efl_added, ntohs(addr.sin_port)), - efl_net_ip_address_set(efl_added, &slice)); + efl_net_ip_address_set(efl_added, slice)); _ipv4_check(o, &addr); efl_del(o); @@ -315,7 +314,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_ok) o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, efl_net_ip_address_family_set(efl_added, AF_INET), efl_net_ip_address_port_set(efl_added, ntohs(addr.sin_port)), - efl_net_ip_address_set(efl_added, &slice)); + efl_net_ip_address_set(efl_added, slice)); _ipv4_check(o, &addr); efl_del(o); @@ -323,7 +322,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_ok) addr.sin_addr.s_addr = htonl(0x12345678); o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, efl_net_ip_address_family_set(efl_added, AF_INET), - efl_net_ip_address_set(efl_added, &slice)); + efl_net_ip_address_set(efl_added, slice)); _ipv4_check(o, &addr); efl_del(o); @@ -356,7 +355,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_fail) TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: pd->addr.sa_family == 0 is true"); o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, - efl_net_ip_address_set(efl_added, &wrong_slice)); + efl_net_ip_address_set(efl_added, wrong_slice)); ck_assert_ptr_eq(o, NULL); TRAP_ERRORS_FINISH(2); @@ -369,14 +368,14 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_fail) TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: pd->addr.sa_family == 0 is true"); o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, efl_net_ip_address_port_set(efl_added, 1234), - efl_net_ip_address_set(efl_added, &wrong_slice)); + efl_net_ip_address_set(efl_added, wrong_slice)); ck_assert_ptr_eq(o, NULL); TRAP_ERRORS_FINISH(3); - TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address->len is true"); + TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address.len is true"); o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, efl_net_ip_address_family_set(efl_added, AF_INET), - efl_net_ip_address_set(efl_added, &wrong_slice)); + efl_net_ip_address_set(efl_added, wrong_slice)); _ipv4_check(o, &addr); efl_del(o); TRAP_ERRORS_FINISH(1); @@ -386,7 +385,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_fail) o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, efl_net_ip_address_family_set(efl_added, AF_INET), efl_net_ip_address_port_set(efl_added, ntohs(addr.sin_port)), - efl_net_ip_address_set(efl_added, &slice)); + efl_net_ip_address_set(efl_added, slice)); _ipv4_check(o, &addr); TRAP_ERRORS_BEGIN(ecore_con, ERR, "port already set to %hu, new %hu"); @@ -397,24 +396,20 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_fail) efl_net_ip_address_port_set(o, 999); TRAP_ERRORS_FINISH(1); - TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: address == NULL"); - efl_net_ip_address_set(o, NULL); - TRAP_ERRORS_FINISH(1); - - TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address->len is true"); + TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address.len is true"); slice.len = 1; - efl_net_ip_address_set(o, &slice); + efl_net_ip_address_set(o, slice); TRAP_ERRORS_FINISH(1); TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s"); slice.len = sizeof(addr.sin_addr.s_addr); - efl_net_ip_address_set(o, &slice); + efl_net_ip_address_set(o, slice); TRAP_ERRORS_FINISH(0); TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s"); addr.sin_addr.s_addr = htonl(0x12345678); slice.len = sizeof(addr.sin_addr.s_addr); - efl_net_ip_address_set(o, &slice); + efl_net_ip_address_set(o, slice); TRAP_ERRORS_FINISH(1); efl_del(o); @@ -729,7 +724,7 @@ static void _ipv6_check(Eo *o, const struct sockaddr_in6 *addr) { Eina_Slice slice = { .mem = &addr->sin6_addr, .len = sizeof(addr->sin6_addr) }; - const Eina_Slice *rs; + Eina_Slice rs; char buf[INET6_ADDRSTRLEN + sizeof("[]:65536")] = ""; ck_assert_ptr_ne(o, NULL); @@ -738,8 +733,7 @@ _ipv6_check(Eo *o, const struct sockaddr_in6 *addr) ck_assert_int_eq(efl_net_ip_address_port_get(o), ntohs(addr->sin6_port)); rs = efl_net_ip_address_get(o); - ck_assert_ptr_ne(rs, NULL); - ck_assert_int_eq(eina_slice_compare(*rs, slice), 0); + ck_assert_int_eq(eina_slice_compare(rs, slice), 0); buf[0] = '['; inet_ntop(AF_INET6, slice.mem, buf + 1, INET6_ADDRSTRLEN); @@ -777,7 +771,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv6_manual_ok) o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, efl_net_ip_address_family_set(efl_added, AF_INET6), efl_net_ip_address_port_set(efl_added, ntohs(addr.sin6_port)), - efl_net_ip_address_set(efl_added, &slice)); + efl_net_ip_address_set(efl_added, slice)); _ipv6_check(o, &addr); efl_del(o); @@ -786,7 +780,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv6_manual_ok) o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, efl_net_ip_address_family_set(efl_added, AF_INET6), efl_net_ip_address_port_set(efl_added, ntohs(addr.sin6_port)), - efl_net_ip_address_set(efl_added, &slice)); + efl_net_ip_address_set(efl_added, slice)); _ipv6_check(o, &addr); efl_del(o); @@ -808,10 +802,10 @@ START_TEST(ecore_test_efl_net_ip_address_ipv6_manual_fail) /* generic errors checked at ecore_test_efl_net_ip_address_ipv4_manual_fail */ - TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address->len is true"); + TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address.len is true"); o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, efl_net_ip_address_family_set(efl_added, AF_INET6), - efl_net_ip_address_set(efl_added, &wrong_slice)); + efl_net_ip_address_set(efl_added, wrong_slice)); _ipv6_check(o, &addr); efl_del(o); TRAP_ERRORS_FINISH(1); @@ -821,7 +815,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv6_manual_fail) o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, efl_net_ip_address_family_set(efl_added, AF_INET6), efl_net_ip_address_port_set(efl_added, ntohs(addr.sin6_port)), - efl_net_ip_address_set(efl_added, &slice)); + efl_net_ip_address_set(efl_added, slice)); _ipv6_check(o, &addr); TRAP_ERRORS_BEGIN(ecore_con, ERR, "port already set to %hu, new %hu"); @@ -832,20 +826,20 @@ START_TEST(ecore_test_efl_net_ip_address_ipv6_manual_fail) efl_net_ip_address_port_set(o, 999); TRAP_ERRORS_FINISH(1); - TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address->len is true"); + TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address.len is true"); slice.len = 1; - efl_net_ip_address_set(o, &slice); + efl_net_ip_address_set(o, slice); TRAP_ERRORS_FINISH(1); TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s"); slice.len = sizeof(addr.sin6_addr); - efl_net_ip_address_set(o, &slice); + efl_net_ip_address_set(o, slice); TRAP_ERRORS_FINISH(0); TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s"); _ipv6_set(&addr, 1, 2, 3, 4, 5, 6, 7, 8); slice.len = sizeof(addr.sin6_addr); - efl_net_ip_address_set(o, &slice); + efl_net_ip_address_set(o, slice); TRAP_ERRORS_FINISH(1); efl_del(o);