aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-03-26 10:38:48 +0000
committerEric Wong <normalperson@yhbt.net>2008-03-26 10:38:48 +0000
commit1d97bbbdd9d6015246b6b894dcc41209e7cce369 (patch)
tree7dd16d8e8f34fff4939a5cc058c4199f9af91921
parente4779fa752e7426a25715c843b18c1fd95e77b9a (diff)
downloadmpd-1d97bbbdd9d6015246b6b894dcc41209e7cce369.tar.gz
mpd-1d97bbbdd9d6015246b6b894dcc41209e7cce369.tar.xz
mpd-1d97bbbdd9d6015246b6b894dcc41209e7cce369.zip
unsigned counters
Use unsigned variables for storing the count of items or for iteration variables. Since there can never be a negative number of items, it makes sense to use an unsigned data type here. This change is safe because the unsigned values are only used for adddressing array items. git-svn-id: https://svn.musicpd.org/mpd/trunk@7214 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--src/interface.c22
-rw-r--r--src/state_file.c4
2 files changed, 13 insertions, 13 deletions
diff --git a/src/interface.c b/src/interface.c
index bfc50cd37..a36131cec 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -42,7 +42,7 @@
#define INTERFACE_MAX_OUTPUT_BUFFER_SIZE_DEFAULT (8192*1024)
/* set this to zero to indicate we have no possible interfaces */
-static int interface_max_connections; /*INTERFACE_MAX_CONNECTIONS_DEFAULT; */
+static unsigned int interface_max_connections; /*INTERFACE_MAX_CONNECTIONS_DEFAULT; */
static int interface_timeout = INTERFACE_TIMEOUT_DEFAULT;
static size_t interface_max_command_list_size =
INTERFACE_MAX_COMMAND_LIST_DEFAULT;
@@ -73,7 +73,7 @@ typedef struct _Interface {
size_t deferred_bytes; /* mem deferred_send consumes */
int expired; /* set whether this interface should be closed on next
check of old interfaces */
- int num; /* interface number */
+ unsigned int num; /* interface number */
char *send_buf;
size_t send_buf_used; /* bytes used this instance */
@@ -237,7 +237,7 @@ static void closeInterface(Interface * interface)
void openAInterface(int fd, struct sockaddr *addr)
{
- int i;
+ unsigned int i;
for (i = 0; i < interface_max_connections
&& interfaces[i].fd >= 0; i++) /* nothing */ ;
@@ -421,7 +421,7 @@ static int interfaceReadInput(Interface * interface)
static void addInterfacesReadyToReadAndListenSocketToFdSet(fd_set * fds,
int *fdmax)
{
- int i;
+ unsigned int i;
FD_ZERO(fds);
addListenSocketsToFdSet(fds, fdmax);
@@ -438,7 +438,7 @@ static void addInterfacesReadyToReadAndListenSocketToFdSet(fd_set * fds,
static void addInterfacesForBufferFlushToFdSet(fd_set * fds, int *fdmax)
{
- int i;
+ unsigned int i;
FD_ZERO(fds);
@@ -456,7 +456,7 @@ static void closeNextErroredInterface(void)
{
fd_set fds;
struct timeval tv;
- int i;
+ unsigned int i;
tv.tv_sec = 0;
tv.tv_usec = 0;
@@ -478,7 +478,7 @@ int doIOForInterfaces(void)
fd_set rfds;
fd_set wfds;
fd_set efds;
- int i;
+ unsigned int i;
int selret;
int fdmax;
@@ -532,7 +532,7 @@ int doIOForInterfaces(void)
void initInterfaces(void)
{
- int i;
+ unsigned int i;
char *test;
ConfigParam *param;
@@ -597,7 +597,7 @@ void initInterfaces(void)
static void closeAllInterfaces(void)
{
- int i;
+ unsigned int i;
for (i = 0; i < interface_max_connections; i++) {
if (interfaces[i].fd >= 0)
@@ -619,7 +619,7 @@ void freeAllInterfaces(void)
void closeOldInterfaces(void)
{
- int i;
+ unsigned int i;
for (i = 0; i < interface_max_connections; i++) {
if (interfaces[i].fd >= 0) {
@@ -685,7 +685,7 @@ static void flushInterfaceBuffer(Interface * interface)
int interfacePrintWithFD(int fd, char *buffer, size_t buflen)
{
- static int i;
+ static unsigned int i;
size_t copylen;
Interface *interface;
diff --git a/src/state_file.c b/src/state_file.c
index a4b2c108f..3bc4f8f0c 100644
--- a/src/state_file.c
+++ b/src/state_file.c
@@ -50,7 +50,7 @@ static void get_state_file_path(void)
void write_state_file(void)
{
- int i;
+ unsigned int i;
FILE *fp;
if (!sfpath)
@@ -72,7 +72,7 @@ void write_state_file(void)
void read_state_file(void)
{
struct stat st;
- int i;
+ unsigned int i;
FILE *fp;
get_state_file_path();