From 920ee2d07ee50d24e8d1fe01c207587f26d07a53 Mon Sep 17 00:00:00 2001 From: Joel Cunningham Date: Wed, 13 Dec 2017 11:34:48 -0600 Subject: [PATCH] sntp: use const for servername This adds const to the sntp servername get/set API and internal storage SNTP's usage of this name is read only and SNTP only passes it to dns_gethostbyname() This was found by compiling with GCC -Wwrite-strings which makes the literal SNTP_SERVER_ADDRESS a const string. This then produced warnings with sntp_init()'s call to sntp_setservername() --- src/apps/sntp/sntp.c | 6 +++--- src/include/lwip/apps/sntp.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/apps/sntp/sntp.c b/src/apps/sntp/sntp.c index 8040cd4b..1bb741e8 100644 --- a/src/apps/sntp/sntp.c +++ b/src/apps/sntp/sntp.c @@ -228,7 +228,7 @@ static struct udp_pcb *sntp_pcb; /** Names/Addresses of servers */ struct sntp_server { #if SNTP_SERVER_DNS - char *name; + const char *name; #endif /* SNTP_SERVER_DNS */ ip_addr_t addr; }; @@ -796,7 +796,7 @@ sntp_getserver(u8_t idx) * @param dnsserver DNS name of the NTP server to set, to be resolved at contact time */ void -sntp_setservername(u8_t idx, char *server) +sntp_setservername(u8_t idx, const char *server) { if (idx < SNTP_MAX_SERVERS) { sntp_servers[idx].name = server; @@ -810,7 +810,7 @@ sntp_setservername(u8_t idx, char *server) * @return IP address of the indexed NTP server or NULL if the NTP * server has not been configured by name (or at all) */ -char * +const char * sntp_getservername(u8_t idx) { if (idx < SNTP_MAX_SERVERS) { diff --git a/src/include/lwip/apps/sntp.h b/src/include/lwip/apps/sntp.h index 40df9cc5..bb44bc7f 100644 --- a/src/include/lwip/apps/sntp.h +++ b/src/include/lwip/apps/sntp.h @@ -59,8 +59,8 @@ void sntp_setserver(u8_t idx, const ip_addr_t *addr); const ip_addr_t* sntp_getserver(u8_t idx); #if SNTP_SERVER_DNS -void sntp_setservername(u8_t idx, char *server); -char *sntp_getservername(u8_t idx); +void sntp_setservername(u8_t idx, const char *server); +const char *sntp_getservername(u8_t idx); #endif /* SNTP_SERVER_DNS */ #if SNTP_GET_SERVERS_FROM_DHCP