const pointers

The usual bunch of pointer arguments which should be const.
This commit is contained in:
Max Kellermann 2008-08-28 20:02:17 +02:00
parent 801c71ed1c
commit bc1c8835c6
6 changed files with 16 additions and 16 deletions

View File

@ -234,7 +234,7 @@ static void closeInterface(Interface * interface)
SECURE("interface %i: closed\n", interface->num);
}
void openAInterface(int fd, struct sockaddr *addr)
void openAInterface(int fd, const struct sockaddr *addr)
{
unsigned int i;
@ -249,7 +249,7 @@ void openAInterface(int fd, struct sockaddr *addr)
switch (addr->sa_family) {
#ifdef HAVE_TCP
case AF_INET:
hostname = (const char *)inet_ntoa(((struct sockaddr_in *)
hostname = (const char *)inet_ntoa(((const struct sockaddr_in *)
addr)->sin_addr);
if (!hostname)
hostname = "error getting ipv4 address";
@ -259,8 +259,8 @@ void openAInterface(int fd, struct sockaddr *addr)
{
static char host[INET6_ADDRSTRLEN + 1];
memset(host, 0, INET6_ADDRSTRLEN + 1);
if (inet_ntop(AF_INET6, (void *)
&(((struct sockaddr_in6 *)addr)->
if (inet_ntop(AF_INET6, (const void *)
&(((const struct sockaddr_in6 *)addr)->
sin6_addr), host,
INET6_ADDRSTRLEN)) {
hostname = (const char *)host;
@ -689,7 +689,7 @@ static void flushInterfaceBuffer(Interface * interface)
}
}
int interfacePrintWithFD(int fd, char *buffer, size_t buflen)
int interfacePrintWithFD(int fd, const char *buffer, size_t buflen)
{
static unsigned int i;
size_t copylen;

View File

@ -22,10 +22,10 @@
#include "os_compat.h"
void initInterfaces(void);
void openAInterface(int fd, struct sockaddr *addr);
void openAInterface(int fd, const struct sockaddr *addr);
void freeAllInterfaces(void);
void closeOldInterfaces(void);
int interfacePrintWithFD(int fd, char *buffer, size_t len);
int interfacePrintWithFD(int fd, const char *buffer, size_t len);
int doIOForInterfaces(void);

View File

@ -34,22 +34,22 @@ struct strnode *new_strnode(char *s)
return x;
}
struct strnode *new_strnode_dup(char *s, const size_t size)
struct strnode *new_strnode_dup(const char *s, const size_t size)
{
struct strnode *x = xmalloc(sizeof(struct strnode) + size);
x->next = NULL;
x->data = ((char *)x + sizeof(struct strnode));
memcpy((void *)x->data, (void*)s, size);
memcpy((void *)x->data, (const void*)s, size);
return x;
}
struct sllnode *new_sllnode(void *s, const size_t size)
struct sllnode *new_sllnode(const void *s, const size_t size)
{
struct sllnode *x = xmalloc(sizeof(struct sllnode) + size);
x->next = NULL;
x->size = size;
x->data = ((char *)x + sizeof(struct sllnode));
memcpy(x->data, (void *)s, size);
memcpy(x->data, (const void *)s, size);
return x;
}

View File

@ -42,11 +42,11 @@ struct sllnode {
struct strnode *new_strnode(char *s);
struct strnode *new_strnode_dup(char *s, const size_t size);
struct strnode *new_strnode_dup(const char *s, const size_t size);
struct strnode *dup_strlist(struct strnode *old);
struct sllnode *new_sllnode(void *s, const size_t size);
struct sllnode *new_sllnode(const void *s, const size_t size);
#endif /* SLLIST_H */

View File

@ -697,7 +697,7 @@ int mpdTagsAreEqual(MpdTag * tag1, MpdTag * tag2)
}
static void appendToTagItems(MpdTag * tag, enum tag_type type,
char *value, size_t len)
const char *value, size_t len)
{
unsigned int i = tag->numOfItems;
char *duplicated = xmalloc(len + 1);
@ -718,7 +718,7 @@ static void appendToTagItems(MpdTag * tag, enum tag_type type,
}
void addItemToMpdTagWithLen(MpdTag * tag, enum tag_type itemType,
char *value, size_t len)
const char *value, size_t len)
{
if (ignoreTagItems[itemType])
{

View File

@ -73,7 +73,7 @@ void clearItemsFromMpdTag(MpdTag * tag, enum tag_type itemType);
void freeMpdTag(MpdTag * tag);
void addItemToMpdTagWithLen(MpdTag * tag, enum tag_type itemType,
char *value, size_t len);
const char *value, size_t len);
#define addItemToMpdTag(tag, itemType, value) \
addItemToMpdTagWithLen(tag, itemType, value, strlen(value))