aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-02-02 16:56:31 +0000
committerAndreas Schneider <mail@cynapses.org>2009-02-02 16:56:31 +0000
commit1fd6a2e9e0b57bf861f177e737fd9cbb6458975b (patch)
treed845c12a626a802b6cc2da8d1e98c7bc52194bbc
parent9414b53befc24d462f5e5d00eea112a7b01806a7 (diff)
downloadlibssh-1fd6a2e9e0b57bf861f177e737fd9cbb6458975b.tar.gz
libssh-1fd6a2e9e0b57bf861f177e737fd9cbb6458975b.tar.xz
libssh-1fd6a2e9e0b57bf861f177e737fd9cbb6458975b.zip
Fix build warnings in socket code.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@220 7dcaeef0-15fb-0310-b436-a5af3365683c
-rw-r--r--include/libssh/priv.h7
-rw-r--r--libssh/socket.c31
2 files changed, 22 insertions, 16 deletions
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index a18d23e2..d0babab5 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -455,7 +455,7 @@ int agent_ident_count(struct ssh_session *session);
/* socket.c */
struct socket;
-void ssh_socket_init();
+void ssh_socket_init(void);
struct socket *ssh_socket_new(SSH_SESSION *session);
void ssh_socket_free(struct socket *s);
void ssh_socket_set_fd(struct socket *s, socket_t fd);
@@ -469,8 +469,9 @@ int ssh_socket_write(struct socket *s,const void *buffer, int len);
int ssh_socket_is_open(struct socket *s);
int ssh_socket_fd_isset(struct socket *s, fd_set *set);
void ssh_socket_fd_set(struct socket *s, fd_set *set, int *fd_max);
-int ssh_socket_completeread(struct socket *s, void *buffer, int len);
-int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session,int len);
+int ssh_socket_completeread(struct socket *s, void *buffer, u32 len);
+int ssh_socket_completewrite(struct socket *s, void *buffer, u32 len);
+int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session, u32 len);
int ssh_socket_nonblocking_flush(struct socket *s);
int ssh_socket_blocking_flush(struct socket *s);
int ssh_socket_poll(struct socket *s, int *write, int *except);
diff --git a/libssh/socket.c b/libssh/socket.c
index d4d8e800..a3df513e 100644
--- a/libssh/socket.c
+++ b/libssh/socket.c
@@ -71,7 +71,7 @@ struct socket {
* \internal
* \brief inits the socket system (windows specific)
*/
-void ssh_socket_init(){
+void ssh_socket_init(void){
#ifdef _WIN32
struct WSAData wsaData;
if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
@@ -175,7 +175,7 @@ int ssh_socket_is_open(struct socket *s){
/* \internal
* \brief read len bytes from socket into buffer
*/
-int ssh_socket_unbuffered_read(struct socket *s, void *buffer, int len){
+static int ssh_socket_unbuffered_read(struct socket *s, void *buffer, u32 len) {
int r;
if(s->data_except)
return -1;
@@ -194,7 +194,8 @@ int ssh_socket_unbuffered_read(struct socket *s, void *buffer, int len){
/* \internal
* \brief writes len bytes from buffer to socket
*/
-int ssh_socket_unbuffered_write(struct socket *s,const void *buffer, int len){
+static int ssh_socket_unbuffered_write(struct socket *s,const void *buffer,
+ u32 len) {
int w;
if(s->data_except)
return -1;
@@ -235,10 +236,10 @@ void ssh_socket_fd_set(struct socket *s, fd_set *set, int *fd_max){
/** \internal
* \brief reads blocking until len bytes have been read
*/
-int ssh_socket_completeread(struct socket *s, void *buffer, int len){
+int ssh_socket_completeread(struct socket *s, void *buffer, u32 len){
int r;
- int total=0;
- int toread=len;
+ u32 total=0;
+ u32 toread=len;
if(!ssh_socket_is_open(s))
return SSH_ERROR;
while((r=ssh_socket_unbuffered_read(s,buffer+total,toread))){
@@ -258,10 +259,11 @@ int ssh_socket_completeread(struct socket *s, void *buffer, int len){
* \brief Blocking write of len bytes
*/
-int ssh_socket_completewrite(struct socket *s, void *buffer, int len){
- SSH_SESSION *session=s->session;
- enter_function();
+int ssh_socket_completewrite(struct socket *s, void *buffer, u32 len){
+ SSH_SESSION *session=s->session;
int written;
+
+ enter_function();
if(!ssh_socket_is_open(s)){
leave_function();
return SSH_ERROR;
@@ -286,8 +288,10 @@ int ssh_socket_completewrite(struct socket *s, void *buffer, int len){
*/
int ssh_socket_read(struct socket *s, void *buffer, int len){
SSH_SESSION *session=s->session;
+ int ret;
+
enter_function();
- int ret=ssh_socket_wait_for_data(s,s->session,len);
+ ret = ssh_socket_wait_for_data(s, s->session, len);
if(ret != SSH_OK){
leave_function();
return ret;
@@ -306,8 +310,9 @@ int ssh_socket_read(struct socket *s, void *buffer, int len){
*/
int ssh_socket_write(struct socket *s,const void *buffer, int len){
SSH_SESSION *session=s->session;
- enter_function();
int ret;
+
+ enter_function();
buffer_add_data(s->out_buffer,buffer,len);
if(buffer_get_rest_len(s->out_buffer) > WRITE_BUFFERING_THRESHOLD)
ret=ssh_socket_nonblocking_flush(s);
@@ -327,7 +332,7 @@ int ssh_socket_write(struct socket *s,const void *buffer, int len){
* \returns SSH_AGAIN need to call later for data
* \returns SSH_ERROR error happened
*/
-int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session,int len){
+int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session, u32 len){
int except, can_write;
int to_read;
int r;
@@ -378,7 +383,7 @@ int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session,int len){
leave_function();
return SSH_ERROR;
}
- buffer_add_data(s->in_buffer,buffer,r);
+ buffer_add_data(s->in_buffer,buffer, (u32) r);
} while(buffer_get_rest_len(s->in_buffer)<len);
leave_function();
return SSH_OK;