Skip to content

netutils/ntpclient: fix a warning if CONFIG_NETUTILS_DHCPC not defined#3466

Open
masc2008 wants to merge 1 commit intoapache:masterfrom
masc2008:fix/ntpclient-dhcpc-guards
Open

netutils/ntpclient: fix a warning if CONFIG_NETUTILS_DHCPC not defined#3466
masc2008 wants to merge 1 commit intoapache:masterfrom
masc2008:fix/ntpclient-dhcpc-guards

Conversation

@masc2008
Copy link
Copy Markdown
Contributor

Summary

This change fixes a warning in netutils/ntpclient/ntpclient.c when
CONFIG_NETUTILS_DHCPC is not enabled.

ntpc_set_servers_from_dhcp() is only used from the DHCP notification
path, but it and its local helper ntpc_dup_server_list() were compiled
unconditionally. In non-DHCP builds this can leave unused static helpers
and trigger compiler warnings.

This patch wraps the DHCP-only declaration and helper definitions with
#ifdef CONFIG_NETUTILS_DHCPC and keeps the shared startup logic
unchanged. ntpc_select_server_list() remains unconditional because it
is still used by the normal ntpc_start() path.

Impact

This change is limited to netutils/ntpclient.

It does not change runtime behavior when CONFIG_NETUTILS_DHCPC is
enabled. For builds without CONFIG_NETUTILS_DHCPC, it removes
unnecessary DHCP-only code from compilation and avoids warning noise.

There is no API change and no documentation update is needed for this
internal warning fix.

Testing

Build-tested change only.

Host:

  • Ubuntu Linux
  • Compiler: GCC

Target / config:

  • a configuration with CONFIG_NETUTILS_DHCPC=y
  • a configuration with CONFIG_NETUTILS_DHCPC not set

Verification:

  • confirmed the DHCP-enabled build still compiles with the DHCP callback path
  • confirmed the non-DHCP build no longer compiles the DHCP-only helpers

Runtime testing on hardware was not performed for this warning fix.

Signed-off-by: Jerry Ma <masc2008@gmail.com>
@masc2008
Copy link
Copy Markdown
Contributor Author

sorry to introduced this warning, not sure if this needs to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant