mirror of
https://github.com/libssh2/libssh2.git
synced 2025-07-29 13:01:14 +03:00
examples: fix various compiler warnings
This commit is contained in:
@ -262,10 +262,10 @@ int main(int argc, char *argv[])
|
|||||||
gettimeofday(&end, NULL);
|
gettimeofday(&end, NULL);
|
||||||
|
|
||||||
time_ms = tvdiff(end, start);
|
time_ms = tvdiff(end, start);
|
||||||
fprintf(stderr, "Got " LIBSSH2_STRUCT_STAT_SIZE_FORMAT " bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
fprintf(stderr, "Got %ld bytes in %ld ms = %.1f bytes/sec spin: %d\n", (long)total,
|
||||||
time_ms, total/(time_ms/1000.0), spin);
|
time_ms, total/(time_ms/1000.0), spin);
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "Got " LIBSSH2_STRUCT_STAT_SIZE_FORMAT " bytes spin: %d\n", total, spin);
|
fprintf(stderr, "Got %ld bytes spin: %d\n", (long)total, spin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
libssh2_channel_free(channel);
|
libssh2_channel_free(channel);
|
||||||
|
@ -90,6 +90,7 @@ int main(int argc, char *argv[])
|
|||||||
char mem[1000];
|
char mem[1000];
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
fd_set fd;
|
fd_set fd;
|
||||||
|
fd_set fd2;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
WSADATA wsadata;
|
WSADATA wsadata;
|
||||||
@ -253,11 +254,12 @@ int main(int argc, char *argv[])
|
|||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
|
|
||||||
FD_ZERO(&fd);
|
FD_ZERO(&fd);
|
||||||
|
FD_ZERO(&fd2);
|
||||||
FD_SET(sock, &fd);
|
FD_SET(sock, &fd);
|
||||||
|
FD_SET(sock, &fd2);
|
||||||
|
|
||||||
/* wait for readable or writeable */
|
/* wait for readable or writeable */
|
||||||
rc = select(sock+1, &fd, &fd, NULL, &timeout);
|
rc = select(sock+1, &fd, &fd2, NULL, &timeout);
|
||||||
if(rc <= 0) {
|
if(rc <= 0) {
|
||||||
/* negative is error
|
/* negative is error
|
||||||
0 is timeout */
|
0 is timeout */
|
||||||
@ -312,11 +314,12 @@ int main(int argc, char *argv[])
|
|||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
|
|
||||||
FD_ZERO(&fd);
|
FD_ZERO(&fd);
|
||||||
|
FD_ZERO(&fd2);
|
||||||
FD_SET(sock, &fd);
|
FD_SET(sock, &fd);
|
||||||
|
FD_SET(sock, &fd2);
|
||||||
|
|
||||||
/* wait for readable or writeable */
|
/* wait for readable or writeable */
|
||||||
rc = select(sock+1, &fd, &fd, NULL, &timeout);
|
rc = select(sock+1, &fd, &fd2, NULL, &timeout);
|
||||||
if(rc <= 0) {
|
if(rc <= 0) {
|
||||||
/* negative is error
|
/* negative is error
|
||||||
0 is timeout */
|
0 is timeout */
|
||||||
|
@ -36,21 +36,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
/* last resort for systems not defining PRIu64 in inttypes.h */
|
|
||||||
#ifndef __PRI64_PREFIX
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define __PRI64_PREFIX "I64"
|
#define __FILESIZE "I64"
|
||||||
#else
|
#else
|
||||||
#if __WORDSIZE == 64
|
#define __FILESIZE "llu"
|
||||||
#define __PRI64_PREFIX "l"
|
#endif
|
||||||
#else
|
|
||||||
#define __PRI64_PREFIX "ll"
|
|
||||||
#endif /* __WORDSIZE */
|
|
||||||
#endif /* WIN32 */
|
|
||||||
#endif /* !__PRI64_PREFIX */
|
|
||||||
#ifndef PRIu64
|
|
||||||
#define PRIu64 __PRI64_PREFIX "u"
|
|
||||||
#endif /* PRIu64 */
|
|
||||||
|
|
||||||
const char *keyfile1="~/.ssh/id_rsa.pub";
|
const char *keyfile1="~/.ssh/id_rsa.pub";
|
||||||
const char *keyfile2="~/.ssh/id_rsa";
|
const char *keyfile2="~/.ssh/id_rsa";
|
||||||
@ -274,7 +264,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) {
|
if(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) {
|
||||||
printf("%8" PRIu64 " ", attrs.filesize);
|
printf("%8" __FILESIZE " ", attrs.filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s\n", mem);
|
printf("%s\n", mem);
|
||||||
|
@ -36,21 +36,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
/* last resort for systems not defining PRIu64 in inttypes.h */
|
|
||||||
#ifndef __PRI64_PREFIX
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define __PRI64_PREFIX "I64"
|
#define __FILESIZE "I64"
|
||||||
#else
|
#else
|
||||||
#if __WORDSIZE == 64
|
#define __FILESIZE "llu"
|
||||||
#define __PRI64_PREFIX "l"
|
#endif
|
||||||
#else
|
|
||||||
#define __PRI64_PREFIX "ll"
|
|
||||||
#endif /* __WORDSIZE */
|
|
||||||
#endif /* WIN32 */
|
|
||||||
#endif /* !__PRI64_PREFIX */
|
|
||||||
#ifndef PRIu64
|
|
||||||
#define PRIu64 __PRI64_PREFIX "u"
|
|
||||||
#endif /* PRIu64 */
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -217,7 +207,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) {
|
if(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) {
|
||||||
printf("%8" PRIu64 " ", attrs.filesize);
|
printf("%8" __FILESIZE " ", attrs.filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s\n", mem);
|
printf("%s\n", mem);
|
||||||
|
@ -115,7 +115,10 @@ static void x11_callback(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel,
|
|||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
struct chan_X11_list *new;
|
struct chan_X11_list *new;
|
||||||
struct chan_X11_list *chan_iter;
|
struct chan_X11_list *chan_iter;
|
||||||
|
(void)session;
|
||||||
|
(void)shost;
|
||||||
|
(void)sport;
|
||||||
|
(void)abstract;
|
||||||
/*
|
/*
|
||||||
* Connect to the display
|
* Connect to the display
|
||||||
* Inspired by x11_connect_display in openssh
|
* Inspired by x11_connect_display in openssh
|
||||||
@ -319,9 +322,13 @@ main (int argc, char *argv[])
|
|||||||
if (set_debug_on == 1)
|
if (set_debug_on == 1)
|
||||||
libssh2_trace(session, LIBSSH2_TRACE_CONN);
|
libssh2_trace(session, LIBSSH2_TRACE_CONN);
|
||||||
|
|
||||||
|
/* ignore pedantic warnings by gcc on the callback argument */
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||||
/* Set X11 Callback */
|
/* Set X11 Callback */
|
||||||
libssh2_session_callback_set(session, LIBSSH2_CALLBACK_X11,
|
libssh2_session_callback_set(session, LIBSSH2_CALLBACK_X11,
|
||||||
(void *)x11_callback);
|
(void *)x11_callback);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
/* Authenticate via password */
|
/* Authenticate via password */
|
||||||
rc = libssh2_userauth_password(session, username, password);
|
rc = libssh2_userauth_password(session, username, password);
|
||||||
|
Reference in New Issue
Block a user