Skip to content

lws_get_addr_scope() compiled on LWS_PLAT_FREERTOS but never called — guard mismatch with lws_socket_bind() IPv6 path #3645

Description

@aksilicon

Summary
In lib/core-net/network.c, lws_get_addr_scope() is only used from the IPv6 branch of lws_socket_bind(), but that call site and the function definition use different preprocessor guards.

Call site (lws_socket_bind(), AF_INET6 case): guarded by LWS_WITH_IPV6 && !LWS_PLAT_FREERTOS
Definition (lws_get_addr_scope()): guarded only by LWS_WITH_IPV6
Declaration (private-lib-core-net.h): guarded only by LWS_WITH_IPV6
On FreeRTOS builds with IPv6 enabled, lws_get_addr_scope() is compiled and linked, but there is no in-tree caller. This looks like an incomplete port rather than intentional public API.

Location:-
Caller (excluded on FreeRTOS):

#if defined(LWS_WITH_IPV6) && !defined(LWS_PLAT_FREERTOS)
    case AF_INET6:
        ...
        if (iface) {
            ...
            serv_addr6.sin6_scope_id = (unsigned int)htonl((uint32_t)
                    lws_get_addr_scope(wsi, iface));
        }
        ...
#endif

Definition (still compiled on FreeRTOS):

#if defined(LWS_WITH_IPV6)
unsigned long
lws_get_addr_scope(struct lws *wsi, const char *ifname_or_ipaddr)
{
    ...
}
#endif

A repo-wide search shows lws_get_addr_scope() is only referenced from this one call site in network.c. It is not part of the public API (include/libwebsockets/).
Can below guard be applied for lws_get_addr_scope function body in network.c.

#if defined(LWS_WITH_IPV6) && !defined(LWS_PLAT_FREERTOS)
unsigned long
lws_get_addr_scope(struct lws *wsi, const char *ifname_or_ipaddr);
#endif

Environment
Platform: FreeRTOS (embedded, lwIP)
Feature: LWS_WITH_IPV6 enabled
File: lib/core-net/network.c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions