# HG changeset patch # User John Calcote # Date 1491588156 21600 # Fri Apr 07 12:02:36 2017 -0600 # Node ID 51ed69107d096c5b9886954d89e0709975d5aa15 # Parent c1c294ce953e35f757020b01314cfc49556ccc0c BUG#149: cleanup libslp namespace; fix ctype function calls throughout. diff --git a/openslp/common/slp_compare.c b/openslp/common/slp_compare.c --- a/openslp/common/slp_compare.c +++ b/openslp/common/slp_compare.c @@ -83,9 +83,10 @@ * * @internal */ -int strncasecmp(const char * s1, const char * s2, size_t len) +int slp_strncasecmp(const char * s1, const char * s2, size_t len) { - while (*s1 && (*s1 == *s2 || tolower(*s1) == tolower(*s2))) + while (*s1 && (*s1 == *s2 + || tolower((unsigned char)*s1) == tolower((unsigned char)*s2))) { len--; if (len == 0) @@ -93,7 +94,7 @@ s1++; s2++; } - return len? (int)(*(unsigned char *)s1 - (int)*(unsigned char *)s2): 0; + return len? (unsigned char)*s1 - (unsigned char)*s2: 0; } # endif @@ -113,11 +114,12 @@ * * @internal */ -int strcasecmp(const char * s1, const char * s2) +int slp_strcasecmp(const char * s1, const char * s2) { - while (*s1 && (*s1 == *s2 || tolower(*s1) == tolower(*s2))) + while (*s1 && (*s1 == *s2 + || tolower((unsigned char)*s1) == tolower((unsigned char)*s2))) s1++, s2++; - return (int)(*(unsigned char *)s1 - (int)*(unsigned char *)s2); + return (unsigned char)*s1 - (unsigned char)*s2; } # endif #endif @@ -202,13 +204,13 @@ char * p = str, * ep = str + len; while (p < ep) { - if (isspace(*p)) + if (isspace((unsigned char)*p)) { - char * ws2p = ++p; /* Point ws2p to the second ws char. */ - while (p < ep && isspace(*p)) /* Scan till we hit a non-ws char. */ + char * ws2p = ++p; /* Point ws2p to the second ws char. */ + while (p < ep && isspace((unsigned char)*p)) /* Scan till we hit a non-ws char. */ p++; - len -= p - ws2p; /* Reduce the length by extra ws. */ - memmove(ws2p, p, ep - p); /* Overwrite the extra white space. */ + len -= p - ws2p; /* Reduce the length by extra ws. */ + memmove(ws2p, p, ep - p); /* Overwrite the extra white space. */ } p++; } @@ -276,9 +278,9 @@ char *upd = dststr; while (len > 0 && *srcstr) { - if (isspace(*srcstr)) + if (isspace((unsigned char)*srcstr)) { - while (isspace(*srcstr) && len > 0) + while (isspace((unsigned char)*srcstr) && len > 0) { ++srcstr, --len; } @@ -311,7 +313,7 @@ } else { - *upd++ = (char)tolower(*srcstr++); + *upd++ = (char)tolower((unsigned char)*srcstr++); --len; } } @@ -340,15 +342,15 @@ char * cpy1, * cpy2; /* Remove leading white space. */ - while (str1len && isspace(*str1)) + while (str1len && isspace((unsigned char)*str1)) str1++, str1len--; - while (str2len && isspace(*str2)) + while (str2len && isspace((unsigned char)*str2)) str2++, str2len--; /* Remove trailing white space. */ - while (str1len && isspace(str1[str1len - 1])) + while (str1len && isspace((unsigned char)str1[str1len - 1])) str1len--; - while (str2len && isspace(str2[str2len - 1])) + while (str2len && isspace((unsigned char)str2[str2len - 1])) str2len--; /*A quick check for empty strings before we start xmemduping and xfreeing*/ diff --git a/openslp/common/slp_compare.h b/openslp/common/slp_compare.h --- a/openslp/common/slp_compare.h +++ b/openslp/common/slp_compare.h @@ -52,10 +52,12 @@ #ifndef _WIN32 # ifndef HAVE_STRNCASECMP -int strncasecmp(const char * s1, const char * s2, size_t len); +int slp_strncasecmp(const char * s1, const char * s2, size_t len); +# define strncasecmp slp_strncasecmp # endif # ifndef HAVE_STRCASECMP -int strcasecmp(const char * s1, const char * s2); +int slp_strcasecmp(const char * s1, const char * s2); +# define strcasecmp slp_strcasecmp # endif #endif diff --git a/openslp/common/slp_dhcp.c b/openslp/common/slp_dhcp.c --- a/openslp/common/slp_dhcp.c +++ b/openslp/common/slp_dhcp.c @@ -405,7 +405,7 @@ * ENOTCONN (read error), ETIMEDOUT (read timeout), ENOMEM (out of * memory), or EINVAL (on parse error). */ -int DHCPGetOptionInfo(unsigned char * dhcpOptCodes, int dhcpOptCodeCnt, +int slp_DHCPGetOptionInfo(unsigned char * dhcpOptCodes, int dhcpOptCodeCnt, DHCPInfoCallBack * dhcpInfoCB, void * context) { uint32_t xid; @@ -539,7 +539,7 @@ * @return Zero on success, or a non-zero value to stop the caller from * continuing to parse the buffer and call this routine. */ -int DHCPParseSLPTags(int tag, void * optdata, size_t optdatasz, +int slp_DHCPParseSLPTags(int tag, void * optdata, size_t optdatasz, void * context) { size_t cpysz, bufsz, dasize; @@ -707,8 +707,8 @@ ctx.scopelistlen = 0; ctx.addrlistlen = 0; - if ((err = DHCPGetOptionInfo(dhcpOpts, sizeof(dhcpOpts), - DHCPParseSLPTags, &ctx)) != 0) + if ((err = slp_DHCPGetOptionInfo(dhcpOpts, sizeof(dhcpOpts), + slp_DHCPParseSLPTags, &ctx)) != 0) return FAIL; printf("ScopeList: [%.*s]\n", ctx.scopelistlen, ctx.scopelist); diff --git a/openslp/common/slp_dhcp.h b/openslp/common/slp_dhcp.h --- a/openslp/common/slp_dhcp.h +++ b/openslp/common/slp_dhcp.h @@ -131,10 +131,10 @@ typedef int DHCPInfoCallBack(int tag, void * optdata, size_t optdatasz, void * context); -int DHCPGetOptionInfo(unsigned char * dhcpOptCodes, int dhcpOptCodeCnt, +int slp_DHCPGetOptionInfo(unsigned char * dhcpOptCodes, int dhcpOptCodeCnt, DHCPInfoCallBack * dhcpInfoCB, void * context); -int DHCPParseSLPTags(int tag, void * optdata, size_t optdatasz, +int slp_DHCPParseSLPTags(int tag, void * optdata, size_t optdatasz, void * context); /** DHCP interface context structure */ diff --git a/openslp/common/slp_iface.c b/openslp/common/slp_iface.c --- a/openslp/common/slp_iface.c +++ b/openslp/common/slp_iface.c @@ -645,7 +645,7 @@ * * @internal */ -int sizeof_ifreq(struct ifreq* ifr) +static int sizeof_ifreq(struct ifreq* ifr) { #ifdef HAVE_SOCKADDR_STORAGE_SS_LEN int len = ifr->ifr_addr.sa_len + sizeof(ifr->ifr_name); diff --git a/openslp/common/slp_message.c b/openslp/common/slp_message.c --- a/openslp/common/slp_message.c +++ b/openslp/common/slp_message.c @@ -58,7 +58,7 @@ * @return A 16-bit unsigned value in native format; the buffer pointer * is moved ahead by 2 bytes on return. */ -uint16_t GetUINT16(uint8_t ** cpp) +uint16_t slp_GetUINT16(uint8_t ** cpp) { uint16_t rv = AS_UINT16(*cpp); *cpp += 2; @@ -72,7 +72,7 @@ * @return A 32-bit unsigned value in native format; the buffer pointer * is moved ahead by 3 bytes on return. */ -uint32_t GetUINT24(uint8_t ** cpp) +uint32_t slp_GetUINT24(uint8_t ** cpp) { uint32_t rv = AS_UINT24(*cpp); *cpp += 3; @@ -86,7 +86,7 @@ * @return A 32-bit unsigned value in native format; the buffer pointer * is moved ahead by 4 bytes on return. */ -uint32_t GetUINT32(uint8_t ** cpp) +uint32_t slp_GetUINT32(uint8_t ** cpp) { uint32_t rv = AS_UINT32(*cpp); *cpp += 4; @@ -106,7 +106,7 @@ * @p cppstring pointer; the buffer pointer is moved ahead by @p len bytes * on return. */ -char * GetStrPtr(uint8_t ** cpp, size_t len) +char * slp_GetStrPtr(uint8_t ** cpp, size_t len) { char * sp = (char *)*cpp; *cpp += len; @@ -120,7 +120,7 @@ * * @note The buffer address is moved ahead by 2 bytes on return. */ -void PutUINT16(uint8_t ** cpp, size_t val) +void slp_PutUINT16(uint8_t ** cpp, size_t val) { TO_UINT16(*cpp, val); *cpp += 2; @@ -133,7 +133,7 @@ * * @note The buffer address is moved ahead by 3 bytes on return. */ -void PutUINT24(uint8_t ** cpp, size_t val) +void slp_PutUINT24(uint8_t ** cpp, size_t val) { TO_UINT24(*cpp, val); *cpp += 3; @@ -146,7 +146,7 @@ * * @note The buffer address is moved ahead by 4 bytes on return. */ -void PutUINT32(uint8_t ** cpp, size_t val) +void slp_PutUINT32(uint8_t ** cpp, size_t val) { TO_UINT32(*cpp, val); *cpp += 4; diff --git a/openslp/common/slp_message.h b/openslp/common/slp_message.h --- a/openslp/common/slp_message.h +++ b/openslp/common/slp_message.h @@ -188,14 +188,23 @@ #define PEEK_LENGTH(p) ((*p == 2) ? AS_UINT24(p + 2) : (*p == 1) ? AS_UINT16(p + 2) : 1) /* buffer-based wire routines */ -uint16_t GetUINT16(uint8_t ** cpp); -uint32_t GetUINT24(uint8_t ** cpp); -uint32_t GetUINT32(uint8_t ** cpp); -char * GetStrPtr(uint8_t ** cpp, size_t length); +uint16_t slp_GetUINT16(uint8_t ** cpp); +uint32_t slp_GetUINT24(uint8_t ** cpp); +uint32_t slp_GetUINT32(uint8_t ** cpp); +char * slp_GetStrPtr(uint8_t ** cpp, size_t length); + +void slp_PutUINT16(uint8_t ** cpp, size_t val); +void slp_PutUINT24(uint8_t ** cpp, size_t val); +void slp_PutUINT32(uint8_t ** cpp, size_t val); -void PutUINT16(uint8_t ** cpp, size_t val); -void PutUINT24(uint8_t ** cpp, size_t val); -void PutUINT32(uint8_t ** cpp, size_t val); +#define GetUINT16 slp_GetUINT16 +#define GetUINT24 slp_GetUINT24 +#define GetUINT32 slp_GetUINT32 +#define GetStrPtr slp_GetStrPtr + +#define PutUINT16 slp_PutUINT16 +#define PutUINT24 slp_PutUINT24 +#define PutUINT32 slp_PutUINT32 /** SLPHeader structure and associated functions */ typedef struct _SLPHeader diff --git a/openslp/common/slp_net.c b/openslp/common/slp_net.c --- a/openslp/common/slp_net.c +++ b/openslp/common/slp_net.c @@ -76,18 +76,20 @@ #endif /** IPv6 SLP address constants */ -const struct in6_addr in6addr_srvloc_node = IN6ADDR_SRVLOC_NODE_INIT; -const struct in6_addr in6addr_srvloc_link = IN6ADDR_SRVLOC_LINK_INIT; -const struct in6_addr in6addr_srvloc_site = IN6ADDR_SRVLOC_SITE_INIT; -const struct in6_addr in6addr_srvlocda_node = IN6ADDR_SRVLDA_NODE_INIT; -const struct in6_addr in6addr_srvlocda_link = IN6ADDR_SRVLDA_LINK_INIT; -const struct in6_addr in6addr_srvlocda_site = IN6ADDR_SRVLDA_SITE_INIT; -const struct in6_addr in6addr_service_node_mask = IN6ADDR_SVCNOD_MASK_INIT; -const struct in6_addr in6addr_service_link_mask = IN6ADDR_SVCLNK_MASK_INIT; -const struct in6_addr in6addr_service_site_mask = IN6ADDR_SVCSIT_MASK_INIT; -const struct in6_addr slp_in6addr_any = SLP_IN6ADDR_ANY_INIT; -const struct in6_addr slp_in6addr_loopback = SLP_IN6ADDR_LOOPBACK_INIT; +const struct in6_addr in6addr_srvloc_node = IN6ADDR_SRVLOC_NODE_INIT; +const struct in6_addr in6addr_srvloc_link = IN6ADDR_SRVLOC_LINK_INIT; +const struct in6_addr in6addr_srvloc_site = IN6ADDR_SRVLOC_SITE_INIT; +const struct in6_addr in6addr_srvlocda_node = IN6ADDR_SRVLDA_NODE_INIT; +const struct in6_addr in6addr_srvlocda_link = IN6ADDR_SRVLDA_LINK_INIT; +const struct in6_addr in6addr_srvlocda_site = IN6ADDR_SRVLDA_SITE_INIT; + +const struct in6_addr slp_in6addr_any = SLP_IN6ADDR_ANY_INIT; +const struct in6_addr slp_in6addr_loopback = SLP_IN6ADDR_LOOPBACK_INIT; + +static const struct in6_addr in6addr_service_node_mask = IN6ADDR_SVCNOD_MASK_INIT; +static const struct in6_addr in6addr_service_link_mask = IN6ADDR_SVCLNK_MASK_INIT; +static const struct in6_addr in6addr_service_site_mask = IN6ADDR_SVCSIT_MASK_INIT; /** Returns the scope embedded in the IPv6 multicast address. * diff --git a/openslp/common/slp_net.h b/openslp/common/slp_net.h --- a/openslp/common/slp_net.h +++ b/openslp/common/slp_net.h @@ -65,9 +65,6 @@ extern const struct in6_addr in6addr_srvlocda_node; extern const struct in6_addr in6addr_srvlocda_link; extern const struct in6_addr in6addr_srvlocda_site; -extern const struct in6_addr in6addr_service_node_mask; -extern const struct in6_addr in6addr_service_link_mask; -/* extern const struct in6_addr in6addr_service_site_mask; */ /** IN6 "Any" and "Loopback" address initializer macros */ #ifdef _AIX diff --git a/openslp/common/slp_network.c b/openslp/common/slp_network.c --- a/openslp/common/slp_network.c +++ b/openslp/common/slp_network.c @@ -364,7 +364,7 @@ * @returns A const pointer to @p dst on success; or NULL on failure, * and sets @a errno to EAFNOSUPPORT. */ -const char * saddr_ntop(const void * src, char * dst, size_t dstsz) +const char * slp_saddr_ntop(const void * src, char * dst, size_t dstsz) { switch (((const struct sockaddr *)src)->sa_family) { diff --git a/openslp/common/slp_network.h b/openslp/common/slp_network.h --- a/openslp/common/slp_network.h +++ b/openslp/common/slp_network.h @@ -62,7 +62,7 @@ size_t bufsz, void * peeraddr, struct timeval * timeout); int SLPNetworkRecvMessage(sockfd_t sockfd, int socktype, SLPBuffer * buf, void * peeraddr, struct timeval * timeout); -const char * saddr_ntop(const void * src, char * dst, size_t dstsz); +const char * slp_saddr_ntop(const void * src, char * dst, size_t dstsz); void SLPNetworkSetSndRcvBuf(sockfd_t sock); /*! @} */ diff --git a/openslp/common/slp_v1message.c b/openslp/common/slp_v1message.c --- a/openslp/common/slp_v1message.c +++ b/openslp/common/slp_v1message.c @@ -275,10 +275,10 @@ || (tmp = strstr(srvreg->attrlist, "scope")) != 0) { tmp += 5; - while (*tmp && (isspace(*tmp) || *tmp == '=')) + while (*tmp && (isspace((unsigned char)*tmp) || *tmp == '=')) tmp++; /* Find start of scope string. */ srvreg->scopelist = tmp; - while (*tmp && !isspace(*tmp) && *tmp != ')') + while (*tmp && !isspace((unsigned char)*tmp) && *tmp != ')') tmp++; /* Find end of scope string. */ srvreg->scopelistlen = tmp - srvreg->scopelist; /** @todo Should we convert to UTF-8 here? */ diff --git a/openslp/common/slp_xmalloc.c b/openslp/common/slp_xmalloc.c --- a/openslp/common/slp_xmalloc.c +++ b/openslp/common/slp_xmalloc.c @@ -106,7 +106,7 @@ * * @return A pointer to the newly allocated memory block. */ -void * _xmalloc(const char * file, int line, size_t size) +void * slp_xmalloc(const char * file, int line, size_t size) { xallocation_t * x; @@ -161,10 +161,10 @@ * * @return A pointer to the newly allocated and cleared memory block. */ -void * _xcalloc(const char * file, int line, int numblks, size_t size) +void * slp_xcalloc(const char * file, int line, int numblks, size_t size) { size_t blksz = numblks * size; - void * ptr = _xmalloc(file, line, blksz); + void * ptr = slp_xmalloc(file, line, blksz); if (ptr) memset(ptr, 0, blksz); return ptr; @@ -183,16 +183,16 @@ * NULL for @p buf actually allocates a new buffer, passing 0 * for @p size actually allocates a new buffer. */ -void * _xrealloc(const char * file, int line, void * ptr, size_t size) +void * slp_xrealloc(const char * file, int line, void * ptr, size_t size) { xallocation_t * x; if (!ptr) - return _xmalloc(file, line, size); + return slp_xmalloc(file, line, size); if (!size) { - _xfree(file, line, ptr); + slp_xfree(file, line, ptr); return 0; } @@ -202,9 +202,9 @@ void * newptr = ptr; if (x->size != size) { - newptr = _xmalloc(file, line, size); + newptr = slp_xmalloc(file, line, size); memcpy(newptr, ptr, x->size); - _xfree(file, line, x); + slp_xfree(file, line, x); } return newptr; } @@ -225,10 +225,10 @@ * @return A pointer to the duplicated string, or NULL on memory * allocation failure. */ -char * _xstrdup(const char * file, int line, const char * str) +char * slp_xstrdup(const char * file, int line, const char * str) { size_t strsz = strlen(str) + 1; - char * ptr = _xmalloc(file, line, strsz); + char * ptr = slp_xmalloc(file, line, strsz); if (ptr) memcpy(ptr, str, strsz); return ptr; @@ -244,9 +244,9 @@ * @return A pointer to the duplicated memory block, or NULL on memory * allocation failure. */ -void * _xmemdup(const char * file, int line, const void * ptr, size_t size) +void * slp_xmemdup(const char * file, int line, const void * ptr, size_t size) { - void * cpy = _xmalloc(file, line, size); + void * cpy = slp_xmalloc(file, line, size); if (cpy) memcpy(cpy, ptr, size); return cpy; @@ -258,7 +258,7 @@ * @param[in] line - The line number where @e xfree was called. * @param[in] ptr - The address of the block to be free'd. */ -void _xfree(const char * file, int line, void * ptr) +void slp_xfree(const char * file, int line, void * ptr) { xallocation_t * x; @@ -290,7 +290,7 @@ * @return A boolean true (1) on success, or false (0) the log file * fails to open. */ -int xmalloc_init(const char * filename, size_t freemem) +int slp_xmalloc_init(const char * filename, size_t freemem) { G_xmalloc_fh = fopen(filename, "w"); if (G_xmalloc_fh == 0) @@ -303,7 +303,7 @@ * * @return 0 */ -int xmalloc_report(void) +int slp_xmalloc_report(void) { xallocation_t * x; @@ -325,7 +325,7 @@ /** Deinitialize the debug memory allocator. */ -void xmalloc_deinit(void) +void slp_xmalloc_deinit(void) { xmalloc_report(); @@ -350,7 +350,7 @@ * @return A pointer to the duplicated memory block, or NULL on memory * allocation failure. */ -void * _xmemdup(const void * ptr, size_t size) +void * slp_xmemdup(const void * ptr, size_t size) { void * cpy = malloc(size); if (cpy) diff --git a/openslp/common/slp_xmalloc.h b/openslp/common/slp_xmalloc.h --- a/openslp/common/slp_xmalloc.h +++ b/openslp/common/slp_xmalloc.h @@ -63,34 +63,38 @@ size_t size; } xallocation_t; -void * _xmalloc(const char * file, int line, size_t size); -void * _xcalloc(const char * file, int line, int numblks, size_t size); -void * _xrealloc(const char * file, int line, void * ptr, size_t size); -char * _xstrdup(const char * file, int line, const char * str); -void * _xmemdup(const char * file, int line, const void * ptr, size_t size); -void _xfree(const char * file, int line, void * ptr); +void * slp_xmalloc(const char * file, int line, size_t size); +void * slp_xcalloc(const char * file, int line, int numblks, size_t size); +void * slp_xrealloc(const char * file, int line, void * ptr, size_t size); +char * slp_xstrdup(const char * file, int line, const char * str); +void * slp_xmemdup(const char * file, int line, const void * ptr, size_t size); +void slp_xfree(const char * file, int line, void * ptr); + +int slp_xmalloc_init(const char * filename, size_t freemem); +int slp_xmalloc_report(void); +void slp_xmalloc_deinit(void); -int xmalloc_init(const char * filename, size_t freemem); -int xmalloc_report(void); -void xmalloc_deinit(void); +#define xmalloc(s) slp_xmalloc(__FILE__,__LINE__,(s)) +#define xcalloc(n,s) slp_xcalloc(__FILE__,__LINE__,(n),(s)) +#define xrealloc(p,s) slp_xrealloc(__FILE__,__LINE__,(p),(s)) +#define xfree(p) slp_xfree(__FILE__,__LINE__,(p)) +#define xstrdup(p) slp_xstrdup(__FILE__,__LINE__,(p)) +#define xmemdup(p,s) slp_xmemdup(__FILE__,__LINE__,(p),(s)) -#define xmalloc(s) _xmalloc(__FILE__,__LINE__,(s)) -#define xcalloc(n,s) _xcalloc(__FILE__,__LINE__,(n),(s)) -#define xrealloc(p,s) _xrealloc(__FILE__,__LINE__,(p),(s)) -#define xfree(p) _xfree(__FILE__,__LINE__,(p)) -#define xstrdup(p) _xstrdup(__FILE__,__LINE__,(p)) -#define xmemdup(p,s) _xmemdup(__FILE__,__LINE__,(p),(s)) +#define xmalloc_init slp_xmalloc_init +#define xmalloc_report slp_xmalloc_report +#define xmalloc_deinit slp_xmalloc_deinit #else /* ?DEBUG */ -void * _xmemdup(const void * ptr, size_t srclen); +void * slp_xmemdup(const void * ptr, size_t srclen); #define xmalloc malloc #define xcalloc calloc #define xrealloc realloc #define xfree free #define xstrdup strdup -#define xmemdup _xmemdup +#define xmemdup slp_xmemdup #endif /* ?DEBUG */ diff --git a/openslp/libslp/libslp.h b/openslp/libslp/libslp.h --- a/openslp/libslp/libslp.h +++ b/openslp/libslp/libslp.h @@ -263,11 +263,15 @@ void KnownDAFreeAll(void); -void PutL16String(uint8_t ** cpp, const char * str, size_t strsz); -size_t SizeofURLEntry(size_t urllen, size_t urlauthlen); -void PutURLEntry(uint8_t ** cpp, uint16_t lifetime, const char * url, +void slp_PutL16String(uint8_t ** cpp, const char * str, size_t strsz); +size_t slp_SizeofURLEntry(size_t urllen, size_t urlauthlen); +void slp_PutURLEntry(uint8_t ** cpp, uint16_t lifetime, const char * url, size_t urllen, const uint8_t * urlauth, size_t urlauthlen); +#define PutL16String slp_PutL16String +#define SizeofURLEntry slp_SizeofURLEntry +#define PutURLEntry slp_PutURLEntry + int LIBSLPPropertyInit(char const * gconffile); void LIBSLPPropertyCleanup(); diff --git a/openslp/libslp/libslp_knownda.c b/openslp/libslp/libslp_knownda.c --- a/openslp/libslp/libslp_knownda.c +++ b/openslp/libslp/libslp_knownda.c @@ -520,7 +520,7 @@ *ctx.scopelist = 0; ctx.addrlistlen = 0; - DHCPGetOptionInfo(dhcpOpts, sizeof(dhcpOpts), DHCPParseSLPTags, &ctx); + slp_DHCPGetOptionInfo(dhcpOpts, sizeof(dhcpOpts), slp_DHCPParseSLPTags, &ctx); if (!*ctx.scopelist) { diff --git a/openslp/libslp/libslp_network.c b/openslp/libslp/libslp_network.c --- a/openslp/libslp/libslp_network.c +++ b/openslp/libslp/libslp_network.c @@ -142,7 +142,7 @@ * * @internal */ -void timeval_subtract(struct timeval *lhs, struct timeval *rhs) +static void timeval_subtract(struct timeval *lhs, struct timeval *rhs) { lhs->tv_sec -= rhs->tv_sec; lhs->tv_usec -= rhs->tv_usec; @@ -162,7 +162,7 @@ * * @internal */ -void timeval_add(struct timeval *lhs, struct timeval *rhs) +static void timeval_add(struct timeval *lhs, struct timeval *rhs) { lhs->tv_sec += rhs->tv_sec; lhs->tv_usec += rhs->tv_usec; @@ -183,7 +183,7 @@ * * @return the size */ -size_t CalcBufferSize(int v1, char buftype, size_t langsize, size_t prlistlen, size_t bufsize) +static size_t CalcBufferSize(int v1, char buftype, size_t langsize, size_t prlistlen, size_t bufsize) { size_t size = 0; diff --git a/openslp/libslp/libslp_parse.c b/openslp/libslp/libslp_parse.c --- a/openslp/libslp/libslp_parse.c +++ b/openslp/libslp/libslp_parse.c @@ -102,10 +102,10 @@ * next buffer position after the URL Entry written on exit. * * @remarks Currently OpenSLP only handles a single authentication - * block. To handle more than this, PutURLEntry would have to take + * block. To handle more than this, slp_PutURLEntry would have to take * arrays of @p urlauth and @p urlauthlen values. */ -void PutURLEntry(uint8_t ** cpp, uint16_t lifetime, const char * url, +void slp_PutURLEntry(uint8_t ** cpp, uint16_t lifetime, const char * url, size_t urllen, const uint8_t * urlauth, size_t urlauthlen) { uint8_t * curpos = *cpp; diff --git a/openslp/libslpattr/libslpattr.c b/openslp/libslpattr/libslpattr.c --- a/openslp/libslpattr/libslpattr.c +++ b/openslp/libslpattr/libslpattr.c @@ -134,8 +134,8 @@ */ static char unescape(char d1, char d2) { - SLP_ASSERT(isxdigit((int) d1)); - SLP_ASSERT(isxdigit((int) d2)); + SLP_ASSERT(isxdigit((unsigned char)d1)); + SLP_ASSERT(isxdigit((unsigned char)d2)); if ((d1 >= 'A') && (d1 <= 'F')) d1 = d1 - 'A' + 0x0A; @@ -184,8 +184,8 @@ /*** Check that the characters are legal, and that the value has * not been truncated. ***/ - if ((i + 2 < len) && isxdigit((int) src[i + 1]) && isxdigit((int) - src[i + 2])) + if ((i + 2 < len) && isxdigit((unsigned char)src[i + 1]) + && isxdigit((unsigned char)src[i + 2])) { *write = unescape(src[i + 1], src[i + 2]); i += 2; @@ -2049,14 +2049,14 @@ /***** Check integer *****/ - if (*val == '-' || isdigit((int) * val)) + if (*val == '-' || isdigit((unsigned char)*val)) { /*** Verify. ***/ SLPBoolean is_int = SLP_TRUE; /* Flag true if the attr is an int. */ for (i = 1; i < len; i++) { /* We start at 1 since first char has already been checked. */ - if (!isdigit((int) val[i])) + if (!isdigit((unsigned char)val[i])) { is_int = SLP_FALSE; break; diff --git a/openslp/slpd/slpd_knownda.c b/openslp/slpd/slpd_knownda.c --- a/openslp/slpd/slpd_knownda.c +++ b/openslp/slpd/slpd_knownda.c @@ -488,7 +488,7 @@ *ctx.scopelist = 0; ctx.addrlistlen = 0; - DHCPGetOptionInfo(dhcpOpts, sizeof(dhcpOpts), DHCPParseSLPTags, &ctx); + slp_DHCPGetOptionInfo(dhcpOpts, sizeof(dhcpOpts), slp_DHCPParseSLPTags, &ctx); alp = ctx.addrlist; while (ctx.addrlistlen >= 4) diff --git a/openslp/slpd/slpd_main.c b/openslp/slpd/slpd_main.c --- a/openslp/slpd/slpd_main.c +++ b/openslp/slpd/slpd_main.c @@ -358,10 +358,11 @@ if (fd) { memset(pidstr,0,14); - (void)fread(pidstr,13,1,fd); - pid = atoi(pidstr); - if (pid && kill(pid, 0) == 0) - return -1; /* we are already running */ + if (fread(pidstr,13,1,fd) > 0) { + pid = atoi(pidstr); + if (pid && kill(pid, 0) == 0) + return -1; /* we are already running */ + } fclose(fd); } return 0; @@ -449,7 +450,8 @@ int i; /* change directory to root */ - (void)chdir("/"); + if (chdir("/") != 0) + ; /* TODO: ... */ /* close all open file handles */ for (i = 0; i < 8192; i++) diff --git a/openslp/slpd/slpd_predicate.c b/openslp/slpd/slpd_predicate.c --- a/openslp/slpd/slpd_predicate.c +++ b/openslp/slpd/slpd_predicate.c @@ -161,7 +161,7 @@ /* Verify escape sequences. */ if (seq_pos == 1 || seq_pos == 2) { - if (!isxdigit((int) escaped[i])) + if (!isxdigit((unsigned char)escaped[i])) return 0; if (seq_pos == 2) @@ -198,7 +198,7 @@ */ static int unescape_check(char d1, char d2, char * val) { - if (!isxdigit((int) d1) || !isxdigit((int) d2)) + if (!isxdigit((unsigned char)d1) || !isxdigit((unsigned char)d2)) return 0; if ((d1 >= 'A') && (d1 <= 'F')) @@ -285,10 +285,10 @@ if (unesc != verbatim[ver_i]) /* quick check for equality*/ { - if (!isascii(unesc) /* case insensitive check */ - || !isalpha(unesc) - || !isalpha(verbatim[ver_i]) - || tolower(unesc) != tolower(verbatim[ver_i])) + if (!isascii((unsigned char)unesc) /* case insensitive check */ + || !isalpha((unsigned char)unesc) + || !isalpha((unsigned char)verbatim[ver_i]) + || tolower((unsigned char)unesc) != tolower((unsigned char)verbatim[ver_i])) return FR_EVAL_FALSE; } @@ -866,7 +866,7 @@ int i; for (i = 0; str[i] != 0; i++) - if (!((!isdigit((int) str[i])) || str[i] == '-')) + if (!((!isdigit((unsigned char)str[i])) || str[i] == '-')) return 0; return 1;