mirror of
https://github.com/libssh2/libssh2.git
synced 2025-07-29 13:01:14 +03:00
tidy-up: replace exit()
with return
In examples and the manual page for `libssh2_version()`. Closes #1541
This commit is contained in:
@ -28,7 +28,7 @@ To make sure you run with the correct libssh2 version:
|
|||||||
.nf
|
.nf
|
||||||
if(!libssh2_version(LIBSSH2_VERSION_NUM)) {
|
if(!libssh2_version(LIBSSH2_VERSION_NUM)) {
|
||||||
fprintf(stderr, \&"Runtime libssh2 version too old.\&");
|
fprintf(stderr, \&"Runtime libssh2 version too old.\&");
|
||||||
exit(1);
|
return -1; /* return error */
|
||||||
}
|
}
|
||||||
.fi
|
.fi
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ int main(int argc, char *argv[])
|
|||||||
} while(1);
|
} while(1);
|
||||||
if(!channel) {
|
if(!channel) {
|
||||||
fprintf(stderr, "Error\n");
|
fprintf(stderr, "Error\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
while((rc = libssh2_channel_request_auth_agent(channel)) ==
|
while((rc = libssh2_channel_request_auth_agent(channel)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN) {
|
LIBSSH2_ERROR_EAGAIN) {
|
||||||
@ -218,7 +218,7 @@ int main(int argc, char *argv[])
|
|||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Error, could not request auth agent, "
|
fprintf(stderr, "Error, could not request auth agent, "
|
||||||
"error code %d.\n", rc);
|
"error code %d.\n", rc);
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stdout, "Agent forwarding request succeeded.\n");
|
fprintf(stdout, "Agent forwarding request succeeded.\n");
|
||||||
@ -229,7 +229,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Error\n");
|
fprintf(stderr, "Error\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
for(;;) {
|
for(;;) {
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
|
@ -196,7 +196,7 @@ int main(int argc, char *argv[])
|
|||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by password failed.\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ int main(int argc, char *argv[])
|
|||||||
} while(1);
|
} while(1);
|
||||||
if(!channel) {
|
if(!channel) {
|
||||||
fprintf(stderr, "Error\n");
|
fprintf(stderr, "Error\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
while((rc = libssh2_channel_exec(channel, commandline)) ==
|
while((rc = libssh2_channel_exec(channel, commandline)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN) {
|
LIBSSH2_ERROR_EAGAIN) {
|
||||||
@ -221,7 +221,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "exec error\n");
|
fprintf(stderr, "exec error\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LIBSSH2_POLLFD *fds = NULL;
|
LIBSSH2_POLLFD *fds = NULL;
|
||||||
@ -241,7 +241,7 @@ int main(int argc, char *argv[])
|
|||||||
fds = malloc(sizeof(LIBSSH2_POLLFD));
|
fds = malloc(sizeof(LIBSSH2_POLLFD));
|
||||||
if(!fds) {
|
if(!fds) {
|
||||||
fprintf(stderr, "malloc failed\n");
|
fprintf(stderr, "malloc failed\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fds[0].type = LIBSSH2_POLLFD_CHANNEL;
|
fds[0].type = LIBSSH2_POLLFD_CHANNEL;
|
||||||
@ -266,7 +266,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if(n < 0) {
|
else if(n < 0) {
|
||||||
fprintf(stderr, "read failed\n");
|
fprintf(stderr, "read failed\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
totread += (size_t)n;
|
totread += (size_t)n;
|
||||||
@ -291,7 +291,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if(n < 0) {
|
else if(n < 0) {
|
||||||
fprintf(stderr, "write failed\n");
|
fprintf(stderr, "write failed\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
totwritten += (size_t)n;
|
totwritten += (size_t)n;
|
||||||
@ -312,7 +312,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if(rc < 0) {
|
else if(rc < 0) {
|
||||||
fprintf(stderr, "send eof failed\n");
|
fprintf(stderr, "send eof failed\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "sent eof\n");
|
fprintf(stderr, "sent eof\n");
|
||||||
@ -353,7 +353,7 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "\n*** FAIL bytes written: "
|
fprintf(stderr, "\n*** FAIL bytes written: "
|
||||||
"%lu bytes read: %lu ***\n",
|
"%lu bytes read: %lu ***\n",
|
||||||
(unsigned long)totwritten, (unsigned long)totread);
|
(unsigned long)totwritten, (unsigned long)totread);
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ int main(int argc, char *argv[])
|
|||||||
} while(1);
|
} while(1);
|
||||||
if(!channel) {
|
if(!channel) {
|
||||||
fprintf(stderr, "Error\n");
|
fprintf(stderr, "Error\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
while((rc = libssh2_channel_exec(channel, commandline)) ==
|
while((rc = libssh2_channel_exec(channel, commandline)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN) {
|
LIBSSH2_ERROR_EAGAIN) {
|
||||||
@ -240,7 +240,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "exec error\n");
|
fprintf(stderr, "exec error\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
for(;;) {
|
for(;;) {
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
|
Reference in New Issue
Block a user