summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 76c97b2)
raw | patch | inline | side by side (parent: 76c97b2)
author | Max Kellermann <max@duempel.org> | |
Wed, 17 Sep 2008 22:59:40 +0000 (00:59 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 17 Sep 2008 22:59:40 +0000 (00:59 +0200) |
When working with buffer lengths and recv() results, we should declare
size_t and ssize_t variables, otherwise the code may fail on 64 bit
machines.
size_t and ssize_t variables, otherwise the code may fail on 64 bit
machines.
src/libmpdclient.c | patch | blob | history | |
src/libmpdclient.h | patch | blob | history |
diff --git a/src/libmpdclient.c b/src/libmpdclient.c
index 0733ccad101973f76f377c2f3b9ac925366eb7d9..675521f3b67592bd8621f8ab5d7126846dd00b42 100644 (file)
--- a/src/libmpdclient.c
+++ b/src/libmpdclient.c
@@ -417,7 +417,7 @@ mpd_Connection * mpd_newConnection(const char * host, int port, float timeout) {
FD_ZERO(&fds);
FD_SET(connection->sock,&fds);
if((err = select(connection->sock+1,&fds,NULL,NULL,&tv)) == 1) {
- int readed;
+ ssize_t readed;
readed = recv(connection->sock,
&(connection->buffer[connection->buflen]),
MPD_BUFFER_MAX_LENGTH-connection->buflen,0);
fd_set fds;
struct timeval tv;
char * tok = NULL;
- int readed;
+ ssize_t readed;
char * bufferCheck = NULL;
int err;
int pos;
diff --git a/src/libmpdclient.h b/src/libmpdclient.h
index 910699445e712edadd2ae980a7283647cd267f51..e91013b9c1f4e37518c1672de86674ee11748864 100644 (file)
--- a/src/libmpdclient.h
+++ b/src/libmpdclient.h
#endif
#include <sys/time.h>
-#include <stdarg.h>
+#include <stddef.h>
+
#define MPD_BUFFER_MAX_LENGTH 50000
#define MPD_WELCOME_MESSAGE "OK MPD "
/* DON'T TOUCH any of the rest of this stuff */
int sock;
char buffer[MPD_BUFFER_MAX_LENGTH+1];
- int buflen;
- int bufstart;
+ size_t buflen;
+ size_t bufstart;
int doneProcessing;
int listOks;
int doneListOk;